mirror of
https://github.com/luanti-org/luanti.git
synced 2025-07-22 17:18:39 +00:00
Add minetest.after(time, func)
This commit is contained in:
parent
a2fd8d1db1
commit
37b64ff616
3 changed files with 35 additions and 28 deletions
|
@ -6,38 +6,18 @@
|
|||
|
||||
experimental = {}
|
||||
|
||||
timers_to_add = {}
|
||||
timers = {}
|
||||
minetest.register_globalstep(function(dtime)
|
||||
for indes, timer in ipairs(timers_to_add) do
|
||||
table.insert(timers, timer)
|
||||
end
|
||||
timers_to_add = {}
|
||||
for index, timer in ipairs(timers) do
|
||||
timer.time = timer.time - dtime
|
||||
if timer.time <= 0 then
|
||||
timer.func()
|
||||
timers[index] = nil
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
after = function(time, func)
|
||||
table.insert(timers_to_add, {time=time, func=func})
|
||||
end
|
||||
|
||||
--[[
|
||||
stepsound = -1
|
||||
function test_sound()
|
||||
print("test_sound")
|
||||
stepsound = minetest.sound_play("default_grass_footstep", {gain=1.0})
|
||||
after(2.0, test_sound)
|
||||
--after(0.1, test_sound_stop)
|
||||
minetest.after(2.0, test_sound)
|
||||
--minetest.after(0.1, test_sound_stop)
|
||||
end
|
||||
function test_sound_stop()
|
||||
print("test_sound_stop")
|
||||
minetest.sound_stop(stepsound)
|
||||
after(2.0, test_sound)
|
||||
minetest.after(2.0, test_sound)
|
||||
end
|
||||
test_sound()
|
||||
--]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue