[0.16.20] Adding new global variable
Posted: Tue Jan 30, 2018 8:41 pm
My on load function:
My init_all function:
When i add new global variable like this:
I load save game that has pravious version of my mod and this error occured: (when I create new game or load save withaut my mod no error)
Am i doing something wrong with adding new variable?
Code: Select all
script.on_load (function()
init_all()
if debug_timebuttons == 1 then
for _, player in pairs(game.players) do
if player.connected then
player.print("on_load ", debug_color)
end
end
end
end)
Code: Select all
function init_all()
if global.button_count == nil then
global.button_count = 5
end
if global.button_caption == nil then
global.button_caption = {"x0.5", "x1", "x2", "x3", "x5"}
end
if global.button_speed == nil then
global.button_speed = {0.5, 1, 2 ,3 ,5}
end
if global.button_menu_timer == nil then
global.button_menu_timer = 0
end
if global.chspeedoncraftingonoff == nil then
global.chspeedoncraftingonoff = false
end
if global.chspeedonminingonoff == nil then
global.chspeedonminingonoff = false
end
if global.speedatcrafting == nil then
global.speedatcrafting = 2
end
if global.speedatstartcrafting == nil then
global.speedatstartcrafting = 0
end
if global.show_timer == nil then
global.show_timer = 1
end
end
Code: Select all
if global.newwariable == nil then
global.newwariable = 1
end
Am i doing something wrong with adding new variable?