Yeah, it's possible. As the saveState() is a function, it will call all body of the function. Please notice the upvalue of vars.rjroldan1 wrote: 17 Oct 2020, 15:51 can the value of a variable that is in process such as in script:update() would be stored insidr tables even if it is pre-defined from local declaration .... I think it the game should read and used the value of the variable that is in pre-defined in var-declaration than the saved values
Code: Select all Reset
local foo -- declare empty variable local function getStorage() return Util.optStorage(TheoTown.getStorage(), key) end local function saveState() local storage = getStorage() storage.foo = foo end local function loadState() local storage = getStorage() foo = storage.foo or 'value' -- if storage.foo is nil, foo will be set to 'value'. if storage.foo isn't nil, foo will be set to storage.foo end function script:init() loadState() end function script:nextMonth() foo = 'anotherValue' saveState() -- will store the new value of foo to storage.foo end
For simply method, you can use script:finishInformationDialog(x,y,level,dialog)rjroldan1 wrote: 17 Oct 2020, 18:48 Can we use gui on building taps? As substitute to the onClick notif or its info itself
Code: Select all Reset
-- script.lua function script:finishInformationDialog(x,y,_,dialog) dialog.title:setText(...) dialog.content:addListBox{...} dialog.controls:addButton{...} end
Code: Select all Reset
// building.json [ { "id":"buildingId", // body "script":"script.lua" } ]