resolving review comments

This commit is contained in:
Chr1Z93 2022-12-16 11:53:11 +01:00
parent 2474660947
commit 2932ac2c31
2 changed files with 10 additions and 18 deletions

View File

@ -50,7 +50,7 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": false, "Locked": false,
"LuaScriptState": "{\"options\":{\"importTrauma\":true,\"removeDrawnLines\":false,\"tidyPlayermats\":true},\"optionsVisible\":false}", "LuaScriptState": "{\"options\":{\"importTrauma\":true,\"removeDrawnLines\":false,\"tidyPlayermats\":true}}",
"LuaScript_path": "Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua", "LuaScript_path": "Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Token", "Name": "Custom_Token",

View File

@ -82,8 +82,7 @@ buttonParameters.function_owner = self
function onSave() function onSave()
return JSON.encode({ return JSON.encode({
options = options, options = options
optionsVisible = optionsVisible
}) })
end end
@ -91,8 +90,10 @@ function onLoad(savedData)
if savedData ~= nil then if savedData ~= nil then
local loadedData = JSON.decode(savedData) local loadedData = JSON.decode(savedData)
options = loadedData.options options = loadedData.options
optionsVisible = loadedData.optionsVisible or false -- update UI to match saved state
updateOptionState() for id, state in pairs(options) do
self.UI.setAttribute(id, "image", state and "option_on" or "option_off")
end
end end
-- index 0: button as label -- index 0: button as label
@ -155,16 +156,6 @@ function showOrHideOptions()
end end
end end
function updateOptionState()
for id, state in pairs(options) do
self.UI.setAttribute(id, "image", state and "option_on" or "option_off")
end
if optionsVisible then
self.UI.show("options")
end
end
--------------------------------------------------------- ---------------------------------------------------------
-- main function -- main function
--------------------------------------------------------- ---------------------------------------------------------
@ -207,7 +198,7 @@ function updateCounters(tableOfGUIDs, tableOfNewValues, info)
if TOKEN ~= nil then if TOKEN ~= nil then
TOKEN.call("updateVal", tableOfNewValues[i]) TOKEN.call("updateVal", tableOfNewValues[i])
else else
printToAll(info .. ": Token number " .. i .. " could not be found and was skipped.", "Yellow") printToAll(info .. ": No. " .. i .. " could not be found.", "Yellow")
end end
end end
end end
@ -220,7 +211,7 @@ function resetSkillTrackers()
if obj ~= nil then if obj ~= nil then
obj.call("updateStats", { 1, 1, 1, 1 }) obj.call("updateStats", { 1, 1, 1, 1 })
else else
printToAll("Skill tracker number " .. i .. " could not be found and was skipped.", "Yellow") printToAll("Skill tracker number " .. i .. " could not be found.", "Yellow")
end end
end end
end end
@ -232,7 +223,7 @@ function resetDoomCounter()
if doomcounter ~= nil then if doomcounter ~= nil then
doomcounter.call("updateVal") doomcounter.call("updateVal")
else else
printToAll("Doom counter could not be found and was skipped.", "Yellow") printToAll("Doom counter could not be found.", "Yellow")
end end
end end
@ -292,6 +283,7 @@ end
-- discard all hand objects -- discard all hand objects
function discardHands() function discardHands()
if not options["tidyPlayermats"] then return end
for i = 1, 4 do for i = 1, 4 do
local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[i]) local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[i])
if trashcan == nil then return end if trashcan == nil then return end