Time |
Nick |
Message |
03:01 |
|
ShadowNinja joined #minetest-mods |
03:09 |
|
Topic for #minetest-mods is now Welcome to #minetest-mods, a channel dedicated to Minetest modding. | http://minetest.net | http://tinyurl.com/mt-lua-api |
03:10 |
ShadowNinja |
The URL pointed to celeron55's lua_api.txt |
03:29 |
|
NakedFury left #minetest-mods |
11:12 |
|
PilzAdam joined #minetest-mods |
14:37 |
|
BrandonReese joined #minetest-mods |
19:11 |
|
ExcaliburZero joined #minetest-mods |
19:12 |
ExcaliburZero |
I am working on a node for a mod that I am working on that is ice that melts after a few seconds. I was wondering, what do you use to delay an action for a set amount of time? |
19:23 |
kaeza |
ExcaliburZero, node timers are best for that situation |
19:23 |
sfan5 |
ABM's are way easier if you just want to do a simple thing |
19:24 |
* kaeza |
always forgets about ABMs :/ |
19:25 |
ExcaliburZero |
Though would an ABM melt each block of ice after a set amount of time (per block) after they have been placed? |
19:26 |
kaeza |
ABMs are rather random |
19:26 |
sfan5 |
kaeza: you can set the ABM "chanche" to 1 |
19:26 |
kaeza |
if you want exact time, go for node timers |
19:26 |
sfan5 |
then they are not random |
19:26 |
sfan5 |
ExcaliburZero: http://dev.minetest.net/ABM |
19:27 |
kaeza |
sfan5, that would melt *every* ice node every interval seconds |
19:27 |
sfan5 |
kaeza: yeah |
19:27 |
kaeza |
I don't think that's what he wants |
19:28 |
ExcaliburZero |
How exactly would I use a node timer? |
19:28 |
kaeza |
timer = minetest.get_node_timer(pos) |
19:29 |
kaeza |
in the nodedef, you must define 'on_timer(pos)' |
19:29 |
sfan5 |
ExcaliburZero: https://github.com/minetest/minetest/blob/master/games/minimal/mods/experimental/init.lua#L445,L488 |
19:30 |
kaeza |
preferably you would get & start the timer from on_construct |
19:30 |
ExcaliburZero |
How would I get it to run the melting code when it reaches a certain time? |
19:31 |
ExcaliburZero |
Ok, I think I'm starting to understand it. |
19:34 |
ExcaliburZero |
Here is what I currently have: http://codepad.org/XLh1KwKx |
19:37 |
ExcaliburZero |
The code doesn't work. It gives an error. |
19:38 |
sfan5 |
ExcaliburZero: whats the error? |
19:38 |
ExcaliburZero |
ServerError: LuaError: error: ...t-0.4.6\bin\..\mods\minetest\neoblocks/light_ice.lua:8: attempt to call global 'start' (a nil value) |
19:40 |
sfan5 |
in line 8: start(5) |
19:40 |
sfan5 |
which start function should that call? |
19:41 |
ExcaliburZero |
It is supposed to start the node timer. |
19:45 |
ExcaliburZero |
I think I figured out how to correctly set the timer. |
19:48 |
ExcaliburZero |
Nope, didn't work. |
19:48 |
ExcaliburZero |
Here is the current code: http://codepad.org/GwYiX7RE |
19:49 |
ExcaliburZero |
The error was this: |
19:49 |
ExcaliburZero |
ServerError: LuaError: error: ...t-0.4.6\bin\..\mods\minetest\neoblocks/light_ice.lua:8: attempt to call field 'get_node_timer' (a nil value) |
19:50 |
|
ShadowNinja joined #minetest-mods |
20:01 |
ExcaliburZero |
Does anyone know what is causing the error? |
20:09 |
sfan5 |
ExcaliburZero: take a look at lua_api.txt |
20:12 |
ExcaliburZero |
What about it? |
21:57 |
ShadowNinja |
ExcaliburZero: Look for minetest.after. |
22:04 |
ExcaliburZero |
Ok, I'll try using that instead. |
22:14 |
ExcaliburZero |
It works! Thanks! |
22:34 |
|
triplei joined #minetest-mods |