From 289cacf17a5812c5fb6cfc7134dedabfea0d86e7 Mon Sep 17 00:00:00 2001 From: Fernando Carmona Varo Date: Sun, 25 Oct 2015 02:51:44 +0200 Subject: Implemented myhighscores API, and used it in pacmine --- pacmine/gamestate.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'pacmine/gamestate.lua') 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", +}) -- cgit v1.2.3