diff --git a/main.lua b/main.lua index 7c6fbc9..dad317d 100644 --- a/main.lua +++ b/main.lua @@ -137,7 +137,7 @@ function main_scene(do_backdrop, do_logo) selected = true self"sprite".color = vec4(1) if win:mouse_pressed("left") then - vplay_sfx(math.random(1000000000)) + vplay_sfx(math.floor(math.random() * 1000000000)) end else selected = false @@ -148,10 +148,16 @@ function main_scene(do_backdrop, do_logo) group:append(logo) end + local max + if not math.log10 then + max = math.ceil(math.log(HEX_GRID_WIDTH * HEX_GRID_HEIGHT, 10)) + else + max = math.ceil(math.log10(HEX_GRID_WIDTH * HEX_GRID_HEIGHT)) + end local seed_textfield, get_seed_textfield_value = gui_make_textfield{ position = vec2(win.left + 190, 50), dimensions = vec2(90, 40), - max = math.ceil(math.log(HEX_GRID_WIDTH * HEX_GRID_HEIGHT, 10)), + max = max, validate = function(string) return not string.match(string, "%D") end, @@ -177,7 +183,7 @@ function main_scene(do_backdrop, do_logo) { texture = TEXTURES.LOAD_GAME_HEX, action = function() - local save = am.load_state("save", "lua") + local save = am.load_state("save", "json") if save then game_init(save) diff --git a/src/game.lua b/src/game.lua index 904e445..b5e3d65 100644 --- a/src/game.lua +++ b/src/game.lua @@ -22,7 +22,7 @@ local game_scene_menu_options = { { texture = TEXTURES.LOAD_GAME_HEX, action = function() - local save = am.load_state("save", "lua") + local save = am.load_state("save", "json") if save then game_init(save) @@ -741,7 +741,7 @@ function game_end() end function game_save() - am.save_state("save", game_serialize(), "lua") + am.save_state("save", game_serialize(), "json") gui_alert("succesfully saved!") end