diff --git a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.json b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.json
index b2330d86..b2caf18d 100644
--- a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.json
+++ b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.json
@@ -22,7 +22,24 @@
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1850441528393599634/FA79B99F5544D16D38DCC8A26F1CEB3E7D9FED17/",
"WidthScale": 0
},
- "Description": "Cleans up the table for the next scenario.\n\nSee context menu for additional information.",
+ "CustomUIAssets": [
+ {
+ "Type": 1,
+ "Name": "font_teutonic-arkham",
+ "URL": "http://cloud-3.steamusercontent.com/ugc/2027213118467703445/89328E273B4C5180BF491516CE998DE3C604E162/"
+ },
+ {
+ "Type": 0,
+ "Name": "option_on",
+ "URL": "http://cloud-3.steamusercontent.com/ugc/2024961953545431779/1D892EC9A38B06B8D34692642CDEEECF928DCE1C/"
+ },
+ {
+ "Type": 0,
+ "Name": "option_off",
+ "URL": "http://cloud-3.steamusercontent.com/ugc/2024961953545431709/07AD4D32B5C29A3B9F0917924CF7010A29DC3CE4/"
+ }
+ ],
+ "Description": "Cleans up the table for the next scenario during campaign play.\n\nThis includes moving cards and tokens into the trashcans, resetting counters and removing bless/curse tokens from the chaos bag.",
"DragSelectable": true,
"GMNotes": "",
"GUID": "26cf4b",
@@ -33,7 +50,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": false,
- "LuaScriptState": "[true,true,true]",
+ "LuaScriptState": "{\"options\":{\"importTrauma\":true,\"removeDrawnLines\":false,\"tidyPlayermats\":true}}",
"LuaScript_path": "Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua",
"MeasureMovement": false,
"Name": "Custom_Token",
@@ -51,10 +68,10 @@
"rotX": 0,
"rotY": 270,
"rotZ": 0,
- "scaleX": 1.2,
+ "scaleX": 2,
"scaleY": 1,
- "scaleZ": 1.2
+ "scaleZ": 2
},
"Value": 0,
- "XmlUI": ""
+ "XmlUI_path": "Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.xml"
}
diff --git a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua
index 8097141f..b82a6589 100644
--- a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua
+++ b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.ttslua
@@ -1,11 +1,12 @@
--- Clean Up Helper
--- made by: Chr1Z
--- description: Cleans up the table for the next scenario in a campaign:
--- - sets counters to default values (resources and doom) or trauma values (health and sanity, if not disabled) from campaign log
--- - puts everything on playmats and hands into respective trashcans
--- - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")
+--[[
+Cleans up the table for the next scenario in a campaign:
+- sets counters to default values (resources and doom) or trauma values (health and sanity, if not disabled) from campaign log
+- puts everything on playmats and hands into respective trashcans
+- use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")
+--]]
local playAreaApi = require("core/PlayAreaApi")
+
-- enable this for debugging
local SHOW_RAYS = false
@@ -29,24 +30,21 @@ local IGNORE_TAG = "CleanUpHelper_ignore"
-- colors and order for following tables
local COLORS = { "White"; "Orange"; "Green"; "Red"; "Agenda" }
--- counter GUIDS (4x damage, 4x sanity and 4x resource)
-local TOKEN_GUIDS = {
+-- counter GUIDS (4x damage and 4x horror)
+local DAMAGE_HORROR_GUIDS = {
"eb08d6"; "e64eec"; "1f5a0a"; "591a45";
"468e88"; "0257d9"; "7b5729"; "beb964";
- "4406f0"; "816d84"; "cd15ac"; "a4b60d"
}
--- default values (4x damage, 4x horror, 4x resources)
-local DEFAULT_VALUES = {
- 0; 0; 0; 0;
- 0; 0; 0; 0;
- 5; 5; 5; 5
-}
+local RESET_VALUES = {}
-local PLAYERMAT_GUIDS = { "8b081b"; "bd0ff4"; "383d8b"; "0840d5" }
-local TRACKER_GUIDS = { "e598c2"; "b4a5f7"; "af7ed7"; "e74881" }
-local CLUE_GUIDS = { "d86b7c"; "1769ed"; "032300"; "37be78" }
-local TRASHCAN_GUIDS = { "147e80"; "f7b6c8"; "5f896a"; "4b8594"; "70b9f6" }
+-- GUIDS of objects (in order of ownership relating to 'COLORS')
+local PLAYERMAT_GUIDS = { "8b081b"; "bd0ff4"; "383d8b"; "0840d5" }
+local RESOURCE_GUIDS = { "4406f0"; "816d84"; "cd15ac"; "a4b60d" }
+local TRACKER_GUIDS = { "e598c2"; "b4a5f7"; "af7ed7"; "e74881" }
+local CLUE_GUIDS = { "d86b7c"; "1769ed"; "032300"; "37be78" }
+local CLUE_CLICKER_GUIDS = { "db85d6"; "3f22e5"; "891403"; "4111de" }
+local TRASHCAN_GUIDS = { "147e80"; "f7b6c8"; "5f896a"; "4b8594"; "70b9f6" }
-- values for physics.cast (4 entries for player zones, 5th entry for agenda/act deck, 6th for campaign log)
local PHYSICS_POSITION = {
@@ -69,9 +67,11 @@ local PHYSICS_SCALE = {
{ 05.0, 1, 05.0 }
}
-local tidyPlayermats = true
-local importTrauma = true
-local resetResources = true
+local optionsVisible = false
+local options = {}
+options["importTrauma"] = true
+options["tidyPlayermats"] = true
+options["removeDrawnLines"] = false
local buttonParameters = {}
buttonParameters.function_owner = self
@@ -80,88 +80,80 @@ buttonParameters.function_owner = self
-- option loading and GUI setup
---------------------------------------------------------
-function onSave() return JSON.encode({ tidyPlayermats, importTrauma, resetResources }) end
+function onSave()
+ return JSON.encode({
+ options = options
+ })
+end
-function onLoad(saved_data)
- local loaded_data = JSON.decode(saved_data)
- if loaded_data ~= nil then
- tidyPlayermats = loaded_data[1]
- importTrauma = loaded_data[2]
- resetResources = loaded_data[3]
+function onLoad(savedData)
+ if savedData ~= nil then
+ local loadedData = JSON.decode(savedData)
+ options = loadedData.options
+ -- update UI to match saved state
+ for id, state in pairs(options) do
+ self.UI.setAttribute(id, "image", state and "option_on" or "option_off")
+ end
end
- -- context menu and buttons
- self.addContextMenuItem("More Information", function()
- printToAll("------------------------------", "White")
- printToAll("Clean Up Helper by Chr1Z", "Orange")
- printToAll("ignore tag: " .. IGNORE_TAG, "White")
- printToAll("Player order in the campaign log for trauma import:\nWhite, Orange, Green, Red", "White")
- end)
-
-- index 0: button as label
buttonParameters.label = "Clean Up Helper"
buttonParameters.click_function = "none"
- buttonParameters.position = { x = 0, y = 0.1, z = -1.525 }
+ buttonParameters.position = { x = 0, y = 0.1, z = -1.3 }
buttonParameters.height = 0
buttonParameters.width = 0
- buttonParameters.font_size = 165
- buttonParameters.font_color = "Black"
+ buttonParameters.font_size = 230
+ buttonParameters.font_color = Color(0, 0, 0)
self.createButton(buttonParameters)
- -- index 1: option button for playermats
- buttonParameters.label = "Tidy playermats: " .. (tidyPlayermats and "✓" or "✗")
- buttonParameters.color = { 0, 0, 0, 0.95 }
- buttonParameters.click_function = "toggle_tidyPlayermats"
- buttonParameters.position.z = buttonParameters.position.z + 0.7
- buttonParameters.height = 275
- buttonParameters.width = 1550
- buttonParameters.font_size = 165
+ -- index 1: option button
+ buttonParameters.label = "Settings"
+ buttonParameters.click_function = "showOrHideOptions"
+ buttonParameters.color = { 0, 0, 0, 0.96 }
+ buttonParameters.position.z = -0.1
+ buttonParameters.height = 350
+ buttonParameters.width = 1000
+ buttonParameters.font_size = 190
buttonParameters.font_color = "White"
self.createButton(buttonParameters)
- -- index 2: option button for trauma import
- buttonParameters.label = "Import trauma: " .. (importTrauma and "✓" or "✗")
- buttonParameters.click_function = "toggle_importTrauma"
- buttonParameters.position.z = buttonParameters.position.z + 0.7
- self.createButton(buttonParameters)
-
- -- index 3: option button for resources
- buttonParameters.label = "Reset resources: " .. (resetResources and "✓" or "✗")
- buttonParameters.click_function = "toggle_resetResources"
- buttonParameters.position.z = buttonParameters.position.z + 0.7
- self.createButton(buttonParameters)
-
- -- index 4: start button
- buttonParameters.label = "Start!"
+ -- index 2: start button
+ buttonParameters.label = "Reset play areas"
buttonParameters.click_function = "cleanUp"
- buttonParameters.position.z = buttonParameters.position.z + 0.7
- buttonParameters.width = 775
+ buttonParameters.position.z = 1.1
+ buttonParameters.width = 1550
self.createButton(buttonParameters)
-- create single table for ignoring
for _, v in ipairs(CLUE_GUIDS) do table.insert(IGNORE_GUIDS, v) end
+ for _, v in ipairs(CLUE_CLICKER_GUIDS) do table.insert(IGNORE_GUIDS, v) end
+ for _, v in ipairs(RESOURCE_GUIDS) do table.insert(IGNORE_GUIDS, v) end
for _, v in ipairs(TRASHCAN_GUIDS) do table.insert(IGNORE_GUIDS, v) end
for _, v in ipairs(PLAYERMAT_GUIDS) do table.insert(IGNORE_GUIDS, v) end
- for _, v in ipairs(TOKEN_GUIDS) do table.insert(IGNORE_GUIDS, v) end
+ for _, v in ipairs(DAMAGE_HORROR_GUIDS) do table.insert(IGNORE_GUIDS, v) end
end
---------------------------------------------------------
-- click functions for option buttons
---------------------------------------------------------
-function toggle_tidyPlayermats()
- tidyPlayermats = not tidyPlayermats
- self.editButton({ index = 1, label = "Tidy playermats: " .. (tidyPlayermats and "✓" or "✗") })
+-- changes the UI state and the internal variable for the togglebuttons
+function optionButtonClick(_, id)
+ local currentState = options[id]
+ local newState = (currentState and "option_off" or "option_on")
+ options[id] = not currentState
+ self.UI.setAttribute(id, "image", newState)
end
-function toggle_importTrauma()
- importTrauma = not importTrauma
- self.editButton({ index = 2, label = "Import trauma: " .. (importTrauma and "✓" or "✗") })
-end
+-- shows or hides the option panel
+function showOrHideOptions()
+ optionsVisible = not optionsVisible
-function toggle_resetResources()
- resetResources = not resetResources
- self.editButton({ index = 3, label = "Reset resources: " .. (resetResources and "✓" or "✗") })
+ if optionsVisible then
+ self.UI.show("options")
+ else
+ self.UI.hide("options")
+ end
end
---------------------------------------------------------
@@ -174,65 +166,76 @@ function cleanUp()
printToAll("Resetting counters...", "White")
getTrauma()
- resetCounters()
-
- -- bless / curse manager prints removed amounts
+ updateCounters(DAMAGE_HORROR_GUIDS, RESET_VALUES, "Damage / Horror")
+ updateCounters(RESOURCE_GUIDS, 5, "Resources")
+ updateCounters(CLUE_CLICKER_GUIDS, 0, "Clue clickers")
+ resetSkillTrackers()
+ resetDoomCounter()
removeBlessCurse()
-
- printToAll("Removing vector lines...", "White")
removeLines()
-
- printToAll("Discarding player hands...", "White")
discardHands()
- printToAll("Tidying big playmat...", "White")
- startLuaCoroutine(self, "tidyPlaymatCoroutine")
+ printToAll("Tidying main play area...", "White")
+ startLuaCoroutine(self, "tidyPlayareaCoroutine")
end
---------------------------------------------------------
-- modular functions, called by other functions
---------------------------------------------------------
--- set counters to reset values
-function resetCounters()
- for i, guid in ipairs(TOKEN_GUIDS) do
- -- skip this step for resource tokens when option disabled (token number 9-12)
- if resetResources or (i < 9 or i > 12) then
- local TOKEN = getObjectFromGUID(guid)
- if TOKEN ~= nil then
- TOKEN.call("updateVal", RESET_VALUES[i])
- else
- printToAll("Token number " .. i .. " could not be found and was skipped.", "Yellow")
- end
+function updateCounters(tableOfGUIDs, tableOfNewValues, info)
+ if tonumber(tableOfNewValues) then
+ local value = tableOfNewValues
+ tableOfNewValues = {}
+ for i = 1, #tableOfGUIDs do
+ table.insert(tableOfNewValues, value)
end
end
- -- reset doom on agenda
- local doomcounter = getObjectFromGUID("85c4c6")
- if doomcounter ~= nil then
- doomcounter.call("updateVal", 0)
- end
+ for i, guid in ipairs(tableOfGUIDs) do
+ local TOKEN = getObjectFromGUID(guid)
+ if TOKEN ~= nil then
+ TOKEN.call("updateVal", tableOfNewValues[i])
+ else
+ printToAll(info .. ": No. " .. i .. " could not be found.", "Yellow")
+ end
+ end
+end
+
+-- set investigator skill trackers to "1, 1, 1, 1"
+function resetSkillTrackers()
for i, guid in ipairs(TRACKER_GUIDS) do
local obj = getObjectFromGUID(guid)
+
if obj ~= nil then
obj.call("updateStats", { 1, 1, 1, 1 })
else
- printToAll("Stat tracker number " .. i .. " could not be found and was skipped.", "Yellow")
+ printToAll("Skill tracker number " .. i .. " could not be found.", "Yellow")
end
end
end
+-- reset doom on agenda
+function resetDoomCounter()
+ local doomcounter = getObjectFromGUID("85c4c6")
+
+ if doomcounter ~= nil then
+ doomcounter.call("updateVal")
+ else
+ printToAll("Doom counter could not be found.", "Yellow")
+ end
+end
+
-- read values for trauma from campaign log if enabled
function getTrauma()
- -- load default values
- RESET_VALUES = {}
- for k, v in pairs(DEFAULT_VALUES) do
- RESET_VALUES[k] = v
- end
+ RESET_VALUES = {
+ 0; 0; 0; 0;
+ 0; 0; 0; 0
+ }
-- stop here if trauma import is disabled
- if not importTrauma then
+ if not options["importTrauma"] then
printToAll("Default values for health and sanity loaded.", "Yellow")
return
end
@@ -259,42 +262,51 @@ function getTrauma()
end
end
--- get rid of bless/curse tokens via bless / curse manager
+-- get rid of bless/curse tokens via bless/curse manager
function removeBlessCurse()
local BlessCurseManager = getObjectFromGUID("5933fb")
+
if BlessCurseManager ~= nil then
BlessCurseManager.call("doRemove", "White")
+ else
+ printToAll("Bless / Curse manager could not be found and thus bless/curse tokens were skipped.", "Yellow")
end
end
-- remove drawn lines
function removeLines()
- Global.setVectorLines({})
+ if options["removeDrawnLines"] then
+ printToAll("Removing vector lines...", "White")
+ Global.setVectorLines({})
+ end
end
-- discard all hand objects
function discardHands()
+ if not options["tidyPlayermats"] then return end
for i = 1, 4 do
local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[i])
- local hand = Player[COLORS[i]].getHandObjects()
if trashcan == nil then return end
- for j = #hand, 1, -1 do trashcan.putObject(hand[j]) end
+ local hand = Player[COLORS[i]].getHandObjects()
+ for j = #hand, 1, -1 do
+ trashcan.putObject(hand[j])
+ end
end
end
--- clean up for big playmat
-function tidyPlaymatCoroutine()
+-- clean up for play area
+function tidyPlayareaCoroutine()
local trashcan = getObjectFromGUID(TRASHCAN_GUIDS[5])
local PLAYMATZONE = getObjectFromGUID("a2f932")
if PLAYMATZONE == nil then
- printToAll("Scripting zone for big playmat could not be found!", "Red")
+ printToAll("Scripting zone for main play area could not be found!", "Red")
elseif trashcan == nil then
- printToAll("Trashcan for big playmat could not be found!", "Red")
+ printToAll("Trashcan for main play area could not be found!", "Red")
else
for _, obj in ipairs(PLAYMATZONE.getObjects()) do
-- ignore these elements
- if indexOf(IGNORE_GUIDS, obj.getGUID()) == nil and obj.hasTag(IGNORE_TAG) == false then
+ if not tableContains(IGNORE_GUIDS, obj.getGUID()) and obj.hasTag(IGNORE_TAG) == false then
coroutine.yield(0)
trashcan.putObject(obj)
end
@@ -311,8 +323,8 @@ end
-- clean up for the four playermats and the agenda/act playmat
function tidyPlayerMatCoroutine()
for i = 1, 5 do
- -- skip playermat (1-4) if option disabled
- if tidyPlayermats or i == 5 then
+ -- only continue for playermat (1-4) if option enabled
+ if options["tidyPlayermats"] or i == 5 then
-- delay for animation purpose
for k = 1, 30 do coroutine.yield(0) end
@@ -328,7 +340,7 @@ function tidyPlayerMatCoroutine()
local desc_low = string.lower(obj.getDescription())
-- ignore these elements
- if indexOf(IGNORE_GUIDS, obj.getGUID()) == nil and obj.hasTag(IGNORE_TAG) == false and
+ if not tableContains(IGNORE_GUIDS, obj.getGUID()) and obj.hasTag(IGNORE_TAG) == false and
desc_low ~= "chaos bag" and desc_low ~= "action token" then
coroutine.yield(0)
trashcan.putObject(obj)
@@ -375,11 +387,12 @@ function findObjects(num)
})
end
--- helper to search array
-function indexOf(array, value)
- for i, v in ipairs(array) do
+-- search a table for a value, return true if found (else returns false)
+function tableContains(table, value)
+ for _, v in ipairs(table) do
if v == value then
- return i
+ return true
end
end
+ return false
end
diff --git a/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.xml b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.xml
new file mode 100644
index 00000000..bbc4ff08
--- /dev/null
+++ b/objects/Fan-MadeAccessories.aa8b38/CleanUpHelper.26cf4b.xml
@@ -0,0 +1,70 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Clean up Helper - Options
+
+
+
+
+
+
+ Import trauma
+
+
+
+
+
+ Controls whether trauma values should be imported from the campaign log (if possible).
Enter players in the campaign log in this order:
White, Orange, Green, Red.
+
+
+
+
+
+
+ Tidy playermats
+
+
+
+
+
+ Controls whether the playermats should get tidied (removal of all cards and tokens).
+
+
+
+
+
+
+ Remove drawn lines
+
+
+
+
+
+ Controls whether all drawn lines should be removed.
+
+
+
+
\ No newline at end of file