summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Carmona Varo <ferkiwi@gmail.com>2015-11-29 11:51:00 +0100
committerFernando Carmona Varo <ferkiwi@gmail.com>2015-11-29 11:51:00 +0100
commitf76be4563596862f97709da97a6f5e6feb9b4203 (patch)
treeb4766f646a5ee953b8a37597c8352b1519d799a8
parent3849c52ba2d7edf09280f3a6666cfd9f62f710d2 (diff)
fix crash when someone manages to get to press the exit block when no game is running
-rw-r--r--mario/init.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/mario/init.lua b/mario/init.lua
index ffa38bd..c9202d0 100644
--- a/mario/init.lua
+++ b/mario/init.lua
@@ -61,8 +61,15 @@ minetest.register_node("mario:exit",{
paramtype = "light",
groups = {cracky = 1,not_in_creative_inventory=1},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
- local game = mario.get_game_by_player(player:get_player_name())
- mario.game_end(game.id)
+ local name = player:get_player_name()
+ local game = mario.get_game_by_player(name)
+ if not game then
+ minetest.chat_send_player(name, "You aren't running a game at the moment")
+ pos.z = pos.z - 3
+ player:moveto(pos)
+ else
+ mario.game_end(game.id)
+ end
end,
})