From afece295b680b1db28abd6502d1850354f0eeb9f Mon Sep 17 00:00:00 2001 From: Nicholas Hayashi Date: Sat, 20 Feb 2021 21:11:34 -0500 Subject: [PATCH] if you have no saved games, don't load anything --- main.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/main.lua b/main.lua index f6ae2eb..2545bef 100644 --- a/main.lua +++ b/main.lua @@ -44,6 +44,7 @@ require "src/projectile" require "src/tower" +-- js style popup in the middle of the screen that dissapates function alert(message) win.scene:append( am.scale(3) ^ am.text(message) @@ -93,8 +94,14 @@ function make_main_scene_toolbelt() { texture = TEXTURES.LOAD_GAME_HEX, action = function() - win.scene:remove"menu" - game_init(am.load_state("save", "json")) + local save = am.load_state("save", "json") + + if save then + win.scene:remove"menu" + game_init(save) + else + alert("no saved games") + end end },