summaryrefslogtreecommitdiff
path: root/games/mesetint/mods/experimental
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-24 19:01:26 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-03-24 19:01:26 +0200
commit601d1936c9ab4787d43f55d67900ed7c46fd3452 (patch)
treeb328ea7a66ee7dc37fffddd0ee063a0c7b1ea10f /games/mesetint/mods/experimental
parent06e93f8d9508a23e86751dfae2f6a7e550d8e1af (diff)
downloadminetest-601d1936c9ab4787d43f55d67900ed7c46fd3452.tar.gz
minetest-601d1936c9ab4787d43f55d67900ed7c46fd3452.tar.bz2
minetest-601d1936c9ab4787d43f55d67900ed7c46fd3452.zip
Lua API for playing sounds
Diffstat (limited to 'games/mesetint/mods/experimental')
-rw-r--r--games/mesetint/mods/experimental/init.lua36
1 files changed, 36 insertions, 0 deletions
diff --git a/games/mesetint/mods/experimental/init.lua b/games/mesetint/mods/experimental/init.lua
index 364eeb10c..e11086274 100644
--- a/games/mesetint/mods/experimental/init.lua
+++ b/games/mesetint/mods/experimental/init.lua
@@ -6,6 +6,42 @@
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)
+end
+function test_sound_stop()
+ print("test_sound_stop")
+ minetest.sound_stop(stepsound)
+ after(2.0, test_sound)
+end
+test_sound()
+--]]
+
function on_step(dtime)
-- print("experimental on_step")
--[[