aboutsummaryrefslogtreecommitdiff
path: root/games/minimal/mods
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-03-27 00:37:31 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-03-27 00:37:31 +0300
commit37b64ff616df3475e228d6beb3727de2afd2b6c2 (patch)
treedcdb6f5b14213dd5dfdb015c51046a0837e53c57 /games/minimal/mods
parenta2fd8d1db10bc5b018d40d9b9ffd8595c7543112 (diff)
Add minetest.after(time, func)
Diffstat (limited to 'games/minimal/mods')
-rw-r--r--games/minimal/mods/experimental/init.lua26
1 files changed, 3 insertions, 23 deletions
diff --git a/games/minimal/mods/experimental/init.lua b/games/minimal/mods/experimental/init.lua
index e11086274..5dab41354 100644
--- a/games/minimal/mods/experimental/init.lua
+++ b/games/minimal/mods/experimental/init.lua
@@ -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()
--]]
"hl opt">.."label[0.5,1;No route locks set]" form = form.."button_exit[0.5,3.5; 5,1;emplace;Emplace manual lock]" end minetest.show_formspec(pname, "at_il_rtool_"..pts, form) return end -- If not a turnout, check the track section and show a form local node_ok, conns, rail_y=advtrains.get_rail_info_at(pos) if not node_ok then minetest.chat_send_player(pname, "Node is not a track!") return end if advtrains.interlocking.db.get_tcb(pos) then advtrains.interlocking.show_tcb_form(pos, pname) return end local ts_id = advtrains.interlocking.db.check_and_repair_ts_at_pos(pos) if ts_id then advtrains.interlocking.show_ts_form(ts_id, pname) else minetest.chat_send_player(pname, "No track section at this location!") end end local function node_left_click(pos, pname) local node_ok, conns, rail_y=advtrains.get_rail_info_at(pos) if not node_ok then minetest.chat_send_player(pname, "Node is not a track!") return end if advtrains.interlocking.db.get_tcb(pos) then advtrains.interlocking.show_tcb_marker(pos) return end local ts_id = advtrains.interlocking.db.check_and_repair_ts_at_pos(pos) if ts_id then advtrains.interlocking.db.update_rs_cache(ts_id) advtrains.interlocking.highlight_track_section(pos) else minetest.chat_send_player(pname, "No track section at this location!") end end minetest.register_craftitem("advtrains_interlocking:tool",{ description = "Interlocking tool\nPunch: Highlight track section\nPlace: check route locks/show track section info", groups = {cracky=1}, -- key=name, value=rating; rating=1..3. inventory_image = "at_il_tool.png", wield_image = "at_il_tool.png", stack_max = 1, on_place = function(itemstack, player, pointed_thing) local pname = player:get_player_name() if not pname then return end if not minetest.check_player_privs(pname, {interlocking=true}) then minetest.chat_send_player(pname, "Insufficient privileges to use this!") return end if pointed_thing.type=="node" then local pos=pointed_thing.under node_right_click(pos, pname) end end, on_use = function(itemstack, player, pointed_thing) local pname = player:get_player_name() if not pname then return end if not minetest.check_player_privs(pname, {interlocking=true}) then minetest.chat_send_player(pname, "Insufficient privileges to use this!") return end if pointed_thing.type=="node" then local pos=pointed_thing.under node_left_click(pos, pname) end end }) minetest.register_on_player_receive_fields(function(player, formname, fields) local pname = player:get_player_name() if not minetest.check_player_privs(pname, "interlocking") then return end local pos local pts = string.match(formname, "^at_il_rtool_(.+)$") if pts then pos = minetest.string_to_pos(pts) end if pos then if advtrains.is_passive(pos) then if fields.clear then ilrs.remove_route_locks(pts) end if fields.emplace then ilrs.add_manual_route_lock(pts, "Manual lock ("..pname..")") end end end end)