first mod help

Post Reply
skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

first mod help

by skyduskguy » Post

ERROR[Main]: ...netest-0.4.13-98d16e0-win64\bin\..\mods\testing\init.lua:6: '}' expected near '='

Code: Select all

minetest.register_abm(
	{nodenames = {"default:dirt"},
	interval = 5,
	chance = 10,
	action = function(pos)
		local airpos = minetest.find_node_near({x.pos, y.pos=y.pos+1, z.pos}, 1, {"default:air"})
	if airpos==true then
		minetest.env:add_node(airpos, {name="default:sand"})
	end,
})

User avatar
rubenwardy
Moderator
Posts: 6977
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy
Location: Bristol, United Kingdom
Contact:

Re: first mod help

by rubenwardy » Post

The problem is Here: minetest.find_node_near({x.pos, y.pos=y.pos+1, z.pos}, 1, {"default:air"})

Should be

minetest.find_node_near({x = pos.x, y = pos.y +1, z = pos.z}, 1, {"default:air"})

Also, use minetest.add_node not minetest.env:add_node
They're the same function. It's at some point end:add_node was changed to add_node

Also consider using set_node instead of add node. I can't remember what the differences are off the top of my head.
Renewed Tab (my browser add-on) | Donate | Mods | Minetest Modding Book

Hello profile reader

User avatar
Don
Member
Posts: 1643
Joined: Sat May 17, 2014 18:40
GitHub: DonBatman
IRC: Batman
In-game: Batman

Re: first mod help

by Don » Post

add_node is an alias for set_node. They do the same thing. I am not sure if add_node will be depreciated or not.
It would be best to just use set_node just in case.
Many of my mods are now a part of Minetest-mods. A place where you know they are maintained!

A list of my mods can be found here

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

Thanks big time for the help, but now I get

ERROR[Main]: ...netest-0.4.13-98d16e0-win64\bin\..\mods\testing\init.lua:9: unexpected symbol near ','

Code: Select all

minetest.register_abm(
	{nodenames = {"default:dirt"},
	interval = 5,
	chance = 10,
	action = function(pos)
		local airpos = minetest.find_node_near({x = pos.x, y = pos.y +1, z = pos.z}, 1, {"default:air"})
	if airpos==true then
		minetest.set_node(airpos, {name="default:sand"})
	end,
})

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

Adding another end in there shut it up but it doesn't seem to be doing anything now
poop

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

it seems to be WORKING! im excited :P
Big ole TY for the help bros

Code: Select all

minetest.register_abm(
	{nodenames = {"default:dirt"},
	interval = 10,
	chance = 100,
	action = function(pos)
		local airpos = minetest.find_node_near({x = pos.x, y = pos.y +1, z = pos.z}, 1, {"default:air"})
	if airpos~=true then
		minetest.set_node({x=pos.x, y=pos.y +1, z=pos.z}, {name="default:sand"})
		end
	end,
})

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

tried adding a radius limit to the dirt checking but.....this is so hard :(

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

actually its not working, shouldnt be placing stuff where something already exists
i changed the type to wood to watch it easier

Code: Select all

minetest.register_abm(
   {nodenames = {"default:wood"},
   interval = 2,
   chance = 100,
   action = function(pos)
      local airpos = minetest.get_node({x = pos.x, y = (pos.y +1), z = pos.z})
   if airpos ~= "default:air" then
		minetest.set_node({x=pos.x, y=pos.y +1, z=pos.z}, {name="stairsplus:slab_wood"})
		   minetest.chat_send_all(airpos)
      end
   end,
})

User avatar
kaadmy
Member
Posts: 706
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: first mod help

by kaadmy » Post

skyduskguy wrote:actually its not working, shouldnt be placing stuff where something already exists
i changed the type to wood to watch it easier

Code: Select all

minetest.register_abm(
   {nodenames = {"default:wood"},
   interval = 2,
   chance = 100,
   action = function(pos)
      local airpos = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
      if airpos.name == "default:air" then
         minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "stairsplus:slab_wood"})
      end
   end
})
Fixed the code for you ;)

Edit: typo
Never paint white stripes on roads near Zebra crossings.

Pixture

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

nothing seems to be replaced

Code: Select all

minetest.register_abm(
   {nodenames = {"default:wood"},
   interval = 2,
   chance = 1,
   action = function(pos)
      local airpos = minetest.get_node({x = pos.x, y = pos.y + 1, z = pos.z})
      if airpos.name == "default:air" then
	  	     print(dump(airpos))
         minetest.set_node({x = pos.x, y = pos.y + 1, z = pos.z}, {name = "stairsplus:slab_wood"})
      end
   end
})

User avatar
kaadmy
Member
Posts: 706
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: first mod help

by kaadmy » Post

skyduskguy wrote:nothing seems to be replaced

[...]
Make the chance = 1.
Never paint white stripes on roads near Zebra crossings.

Pixture

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

I have, nothing happening in console either

User avatar
kaadmy
Member
Posts: 706
Joined: Thu Aug 27, 2015 23:07
GitHub: kaadmy
IRC: KaadmY
In-game: KaadmY kaadmy NeD

Re: first mod help

by kaadmy » Post

Just say

Code: Select all

if airpos.name == "" then
That might work, because air is handled differently than normal nodes.
Never paint white stripes on roads near Zebra crossings.

Pixture

skyduskguy
Member
Posts: 14
Joined: Mon Jan 04, 2016 04:16

Re: first mod help

by skyduskguy » Post

if airpos.name == "air" then

works after you mentioned that i figured id print the airpos dump earlier in the code to see what it was called
you have all been super helpful <3 <3

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 1 guest