Browse Source

fix bug with lua versions other than 5.1 and math.log

master
Nicholas Hayashi 3 years ago
parent
commit
cdb8303746
  1. 12
      main.lua
  2. 4
      src/game.lua

12
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)

4
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

Loading…
Cancel
Save