summaryrefslogtreecommitdiff
path: root/pacmine/gamestate.lua
diff options
context:
space:
mode:
authorFernando Carmona Varo <ferkiwi@gmail.com>2015-10-25 02:51:44 +0200
committerFernando Carmona Varo <ferkiwi@gmail.com>2015-10-25 02:51:44 +0200
commit289cacf17a5812c5fb6cfc7134dedabfea0d86e7 (patch)
tree089134beac23e549dd7a020fe1956b3cec6dc90d /pacmine/gamestate.lua
parentebde4407511a7255e1e5b6d897f81188c4fe2eb3 (diff)
Implemented myhighscores API, and used it in pacmine
Diffstat (limited to 'pacmine/gamestate.lua')
-rwxr-xr-xpacmine/gamestate.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/pacmine/gamestate.lua b/pacmine/gamestate.lua
index 718bf02..7bbc0af 100755
--- a/pacmine/gamestate.lua
+++ b/pacmine/gamestate.lua
@@ -64,6 +64,14 @@ function pacmine.game_end(id)
pacmine.remove_hud(player, gamestate.player_name)
player:moveto(vector.add(gamestate.pos,{x=0.5,y=0.5,z=-1.5}))
end
+ -- Save score
+ local ranking = myhighscore.save_score("pacmine", {
+ player = gamestate.player_name,
+ score = gamestate.score
+ })
+ if ranking then
+ minetest.chat_send_player(gamestate.player_name, "You made it to the highscores! Your Ranking: " .. ranking)
+ end
-- Clear the data
pacmine.games[id] = nil
pacmine.players[id] = nil
@@ -314,3 +322,9 @@ minetest.register_chatcommand("pacmine_exit", {
end
end
})
+
+-- Register with the myhighscore mod
+myhighscore.register_game("pacmine", {
+ description = "Pacmine",
+ icon = "pacmine_1.png",
+})