sumo-cd2025/minigame_manager.lua
MisterE123 e24f114e27 fixed server crash
The on_time_tick is necessary to keep the game from crashing (maybe an inconvenience with arena_lib that could be fixed?)
2020-12-19 16:23:34 +00:00

43 lines
1019 B
Lua

arena_lib.on_load("sumo", function(arena)
local item = ItemStack("sumo:pushstick")
for pl_name, stats in pairs(arena.players) do
local player = minetest.get_player_by_name(pl_name)
player:get_inventory():set_stack("main", 1, item)
end
end)
--if the game times out
arena_lib.on_timeout('sumo', function(arena)
local winner_names = {}
for p_name, p_stats in pairs(arena.players) do
table.insert(winner_names, p_name)
end
arena_lib.load_celebration('sumo', arena, winner_names)
end)
arena_lib.on_death('sumo', function(arena, p_name, reason)
arena_lib.remove_player_from_arena(p_name, 1)
end)
--this is necessary beacuse it is required by arena_lib for timed games
arena_lib.on_time_tick('sumo', function(arena)
return
end)
--remove stick if in inv when joinplayer
minetest.register_on_joinplayer(function(player)
local inv = player:get_inventory()
local stack = ItemStack("sumo:pushstick")
local taken = inv:remove_item("main", stack)
end)