Õ ¿function init(self) msg.post(".", "acquire_input_focus") msg.post("#level2_proxy", "load") self.collection_to_load = "" self.current_collection = "#level2_proxy" local my_file_path = sys.get_save_file("cursegame", "high_scores") self.highscore_table = sys.load(my_file_path) if not next(self.highscore_table) then for i = 1, 10, 1 do table.insert(self.highscore_table, {"---", 0}) end sys.save(my_file_path, self.highscore_table) end self.highscore_position = 0 end function final(self) msg.post(".", "release_input_focus") end function on_message(self, message_id, message, sender) if message_id == hash("proxy_loaded") then msg.post(sender, "enable") elseif message_id == hash("show level1 screen") then msg.post(self.current_collection, "unload") self.collection_to_load = "#level1_proxy" elseif message_id == hash("NoMoreLives") then local show_gameover = true print("dead") print(message.score) for i = 1, 10, 1 do if message.score > self.highscore_table [i][2] then for j = 9, i, -1 do self.highscore_table[j+1][1] = self.highscore_table[j][1] self.highscore_table[j+1][2] = self.highscore_table[j][2] end self.highscore_table [i][2] = message.score self.highscore_position = i local my_file_path = sys.get_save_file("cursegame", "high_scores") sys.save(my_file_path, self.highscore_table) msg.post(self.current_collection, "unload") self.collection_to_load = "#entername_proxy" show_gameover = false break end end if show_gameover == true then msg.post(self.current_collection, "unload") self.collection_to_load = "#gameover_proxy" end elseif message_id == hash("show scoreboard screen") then msg.post(self.current_collection, "unload") self.collection_to_load = "#scoreboard_proxy" elseif message_id == hash("show instructions screen") then msg.post(self.current_collection, "unload") self.collection_to_load = "#instructions_proxy" elseif message_id == hash("show settings screen") then msg.post(self.current_collection, "unload") self.collection_to_load = "#settings_proxy" elseif message_id == hash("escape") then msg.post(self.current_collection, "unload") self.collection_to_load = "#startscreen_proxy" elseif message_id == hash("proxy_unloaded") then msg.post(self.collection_to_load, "load") self.current_collection = self.collection_to_load self.collection_to_load = "" elseif message_id == hash("send_table") then msg.post("scoreboard:/scoreboard#scoreboard", "highscore_table", { high_scores = self.highscore_table}) elseif message_id == hash("save_name") then self.highscore_table[self.highscore_position][1] = message.name local my_file_path = sys.get_save_file("cursegame", "high_scores") sys.save(my_file_path, self.highscore_table) msg.post(self.current_collection, "unload") self.collection_to_load = "#scoreboard_proxy" end end @main/main.script"