Moving Node - code help

Post Reply
Darthon12
Member
Posts: 26
Joined: Thu Nov 21, 2019 19:38

Moving Node - code help

by Darthon12 » Post

Moders and coders I have a conundrum(video of results),
trying make a node move(code below) code works, well minus a few caveats, 1 - once you leave the world and go back in the code doesn't re-run, 2 - if the set_node's X Y Z is in your view the set_node with in the timer doesn't set the node. Anyone have a better way to do this???

https://youtu.be/cZIQwbYsVos

on_timer = function(pos, elapsed)
minetest.set_node(pos, { name = "air", param2 = minetest.get_node(pos).param2 })
minetest.set_node({x=174, y=1, z=347}, { name = "neontraffic:cara", param2 = minetest.get_node(pos).param2 })
end,

on_construct = function(pos, self, staticdata)
timer = minetest.get_node_timer(pos)
timer:start(10)

minetest.after(.2,
function(self)
minetest.set_node(pos, { name = "air", param2 = minetest.get_node(pos).param2 })
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name = "neontraffic:cara" })
end,
self)


end,

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Moving Node - code help

by Termos » Post

Sure there's a better way - use entities. Nodes aren't so great for moving stuff.

Darthon12
Member
Posts: 26
Joined: Thu Nov 21, 2019 19:38

Re: Moving Node - code help

by Darthon12 » Post

Thanks, for pointing me in the right direction! Unfortunately it still utilizes a node and timer to spawn the car...any way around that??

\/ cyber car as entity

https://youtu.be/0o2AhAim3xA

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: Moving Node - code help

by Termos » Post

Well, there are countless ways to spawn, depending on what you want to achieve, it's as simple as calling add_entity().

If you want the car to be spawned always in the same spot then a node timer seems a valid method. You could also use an LBM if you want it to be immediately spawned every time a player comes within range.

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests