Assuming the nodes "xpand:dirt_with_truffle" and "xpand:oak_trunk" are registered.
the following code:
minetest.override_item("default:dirt", {
on_construct = function(pos)
if minetest.find_node_near(pos, 2, "xpand:oak_trunk") ~= nil then
minetest.get_node_timer(pos):start(30)
end
end,
on_timer = function(pos)
local temp = math.random()
if temp > 0.85 then
minetest.set_node(pos, "xpand:dirt_with_truffle")
end
return false
end
})
I thought it would start a 30 seconds timer on every newly placed dirt node, at the end of which there should be a 15% chance that the dirt node will turn into a dirt with truffle node.
The mod starts and I can place dirt nodes correctly. 30 seconds later timers start to trigger.
However when temp is > 0.85 and the line inside the "if" is ran, game crashes with the following message:
2020-08-29 18:12:42: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Node name is not set or is not a string
There are about 20 "player places node default:dirt" log entries in debug.txt prior to the crash, one (not the first-one) from exactly 30 seconds before.
So, what am I doing wrong?
Thank you for reading so far
timer issues
-
- New member
- Posts: 4
- Joined: Fri Aug 21, 2020 21:59
- Nathan.S
- Member
- Posts: 1147
- Joined: Wed Sep 24, 2014 17:47
- GitHub: NathanSalapat
- IRC: NathanS21
- In-game: NathanS21
- Location: Bigsby Texas
- Contact:
Re: timer issues
set_node expects pos, and a table with the node data.
So something like,
will probably work
Code: Select all
* `node`: table `{name=string, param1=number, param2=number}`
Code: Select all
minetest.set_node(pos, {name="xpand:dirt_with_truffle"})
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course
Check out my website, and brand new Minetest Modding Course
-
- New member
- Posts: 4
- Joined: Fri Aug 21, 2020 21:59
Re: timer issues
Your code worked just perfect. Thank you very much NathanNathan.S wrote: ↑Sat Aug 29, 2020 19:13set_node expects pos, and a table with the node data.So something like,Code: Select all
* `node`: table `{name=string, param1=number, param2=number}`
will probably workCode: Select all
minetest.set_node(pos, {name="xpand:dirt_with_truffle"})
Who is online
Users browsing this forum: No registered users and 6 guests