first mod help

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

first mod help

by skyduskguy » Thu Jan 07, 2016 10:03

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: 5863
Joined: Tue Jun 12, 2012 18:11
Location: United Kingdom
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: first mod help

by rubenwardy » Thu Jan 07, 2016 10:11

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.
 

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 » Thu Jan 07, 2016 14:55

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 » Thu Jan 07, 2016 17:01

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 » Thu Jan 07, 2016 17:23

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 » Thu Jan 07, 2016 17:29

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 » Thu Jan 07, 2016 17:47

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 » Thu Jan 07, 2016 19:09

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 » Thu Jan 07, 2016 19:17

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 » Thu Jan 07, 2016 19:37

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 » Thu Jan 07, 2016 19:41

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 » Thu Jan 07, 2016 19:47

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 » Thu Jan 07, 2016 19:51

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

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
 


Return to Modding Discussion



Who is online

Users browsing this forum: No registered users and 3 guests