Page 1 of 1

first mod help

PostPosted: Thu Jan 07, 2016 10:03
by skyduskguy
ERROR[Main]: ...netest-0.4.13-98d16e0-win64\bin\..\mods\testing\init.lua:6: '}' expected near '='


Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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,
})

Re: first mod help

PostPosted: Thu Jan 07, 2016 10:11
by rubenwardy
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.

Re: first mod help

PostPosted: Thu Jan 07, 2016 14:55
by Don
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.

Re: first mod help

PostPosted: Thu Jan 07, 2016 17:01
by skyduskguy
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 ','

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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,
})

Re: first mod help

PostPosted: Thu Jan 07, 2016 17:23
by skyduskguy
Adding another end in there shut it up but it doesn't seem to be doing anything now
poop

Re: first mod help

PostPosted: Thu Jan 07, 2016 17:29
by skyduskguy
it seems to be WORKING! im excited :P
Big ole TY for the help bros

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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,
})

Re: first mod help

PostPosted: Thu Jan 07, 2016 17:47
by skyduskguy
tried adding a radius limit to the dirt checking but.....this is so hard :(

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:09
by skyduskguy
actually its not working, shouldnt be placing stuff where something already exists
i changed the type to wood to watch it easier

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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,
})

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:17
by kaadmy
skyduskguy wrote:actually its not working, shouldnt be placing stuff where something already exists
i changed the type to wood to watch it easier

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:37
by skyduskguy
nothing seems to be replaced

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
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
})

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:41
by kaadmy
skyduskguy wrote:nothing seems to be replaced

[...]

Make the chance = 1.

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:47
by skyduskguy
I have, nothing happening in console either

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:51
by kaadmy
Just say
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
if airpos.name == "" then

That might work, because air is handled differently than normal nodes.

Re: first mod help

PostPosted: Thu Jan 07, 2016 19:59
by skyduskguy
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