updating various of my tools
This commit is contained in:
parent
bc01f28c29
commit
7e2e998d42
@ -3,35 +3,50 @@
|
|||||||
-- original by: -
|
-- original by: -
|
||||||
-- description: displays cards in it with cost/skill icons
|
-- description: displays cards in it with cost/skill icons
|
||||||
information = {
|
information = {
|
||||||
version = "1.4",
|
version = "1.6",
|
||||||
last_updated = "10.10.2022"
|
last_updated = "09.11.2022"
|
||||||
|
}
|
||||||
|
|
||||||
|
option_text = {
|
||||||
|
"Ancestral Knowledge",
|
||||||
|
"Astronomical Atlas",
|
||||||
|
"Crystallizer of Dreams",
|
||||||
|
"Diana Stanley",
|
||||||
|
"Gloria Goldberg",
|
||||||
|
"Sefina Rousseau",
|
||||||
|
"Wooden Sledge"
|
||||||
|
}
|
||||||
|
|
||||||
|
imageList = {
|
||||||
|
-- Ancestral Knowledge
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1915746489207287888/2F9F6F211ED0F98E66C9D35D93221E4C7FB6DD3C/",
|
||||||
|
-- Astronomical Atlas
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1754695853007989004/9153BC204FC707AE564ECFAC063A11CB8C2B5D1E/",
|
||||||
|
-- Crystallizer of Dreams
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1915746489207280958/100F16441939E5E23818651D1EB5C209BF3125B9/",
|
||||||
|
-- Diana Stanley
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1754695635919071208/1AB7222850201630826BFFBA8F2BD0065E2D572F/",
|
||||||
|
-- Gloria Goldberg
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1754695635919102502/453D4426118C8A6DE2EA281184716E26CA924C84/",
|
||||||
|
-- Sefina Rousseau
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1754695635919099826/3C3CBFFAADB2ACA9957C736491F470AE906CC953/",
|
||||||
|
-- Wooden Sledge
|
||||||
|
"http://cloud-3.steamusercontent.com/ugc/1750192233783143973/D526236AAE16BDBB98D3F30E27BAFC1D3E21F4AC/"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- save state and options to restore onLoad
|
-- save state and options to restore onLoad
|
||||||
function onSave() return JSON.encode({ cardsInBag, showCost, showIcons }) end
|
function onSave() return JSON.encode({ cardsInBag, showCost, showIcons }) end
|
||||||
|
|
||||||
-- load variables and create context menu
|
-- load variables and create context menu
|
||||||
function onload(saved_data)
|
function onLoad(saved_data)
|
||||||
if saved_data ~= "" and saved_data ~= nil then
|
local loaded_data = JSON.decode(saved_data)
|
||||||
local loaded_data = JSON.decode(saved_data)
|
cardsInBag = loaded_data[1] or {}
|
||||||
cardsInBag = loaded_data[1]
|
showCost = loaded_data[2] or true
|
||||||
showCost = loaded_data[2]
|
showIcons = loaded_data[3] or true
|
||||||
showIcons = loaded_data[3]
|
|
||||||
else
|
|
||||||
cardsInBag = {}
|
|
||||||
showCost = true
|
|
||||||
showIcons = true
|
|
||||||
end
|
|
||||||
|
|
||||||
recreateButtons()
|
recreateButtons()
|
||||||
|
|
||||||
self.addContextMenuItem("More Information", function()
|
self.addContextMenuItem("Select image", selectImage)
|
||||||
printToAll("------------------------------", "White")
|
|
||||||
printToAll("Attachment Helper v" .. information["version"] .. " by Chr1Z", "Orange")
|
|
||||||
printToAll("original by: bankey", "White")
|
|
||||||
printToAll("last updated: " .. information["last_updated"], "White")
|
|
||||||
end)
|
|
||||||
|
|
||||||
self.addContextMenuItem("Toggle cost", function(color)
|
self.addContextMenuItem("Toggle cost", function(color)
|
||||||
showCost = not showCost
|
showCost = not showCost
|
||||||
printToColor("Show cost of cards: " .. tostring(showCost), color, "White")
|
printToColor("Show cost of cards: " .. tostring(showCost), color, "White")
|
||||||
@ -43,6 +58,22 @@ function onload(saved_data)
|
|||||||
printToColor("Show skill icons of cards: " .. tostring(showIcons), color, "White")
|
printToColor("Show skill icons of cards: " .. tostring(showIcons), color, "White")
|
||||||
refresh()
|
refresh()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
self.addContextMenuItem("More Information", function()
|
||||||
|
printToAll("------------------------------", "White")
|
||||||
|
printToAll("Attachment Helper v" .. information["version"] .. " by Chr1Z", "Orange")
|
||||||
|
printToAll("original by: bankey", "White")
|
||||||
|
printToAll("last updated: " .. information["last_updated"], "White")
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function selectImage(color)
|
||||||
|
Player[color].showOptionsDialog("Select image:", option_text, 1, function(_, option_index)
|
||||||
|
local customInfo = self.getCustomObject()
|
||||||
|
customInfo.diffuse = imageList[option_index]
|
||||||
|
self.setCustomObject(customInfo)
|
||||||
|
self.reload()
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- called for every card that enters
|
-- called for every card that enters
|
||||||
@ -80,10 +111,7 @@ function findCard(guid, name, GMNotes)
|
|||||||
local metadata = {}
|
local metadata = {}
|
||||||
|
|
||||||
if name == nil or name == "" then name = "unnamed" end
|
if name == nil or name == "" then name = "unnamed" end
|
||||||
|
if showCost or showIcons then metadata = JSON.decode(GMNotes) end
|
||||||
if showCost or showIcons then
|
|
||||||
metadata = JSON.decode(GMNotes)
|
|
||||||
end
|
|
||||||
|
|
||||||
if showCost then
|
if showCost then
|
||||||
if GMNotes ~= "" then cost = metadata.cost end
|
if GMNotes ~= "" then cost = metadata.cost end
|
||||||
@ -96,11 +124,11 @@ function findCard(guid, name, GMNotes)
|
|||||||
icons[1] = metadata.wildIcons
|
icons[1] = metadata.wildIcons
|
||||||
icons[2] = metadata.willpowerIcons
|
icons[2] = metadata.willpowerIcons
|
||||||
icons[3] = metadata.intellectIcons
|
icons[3] = metadata.intellectIcons
|
||||||
icons[4] = metadata.fightIcons
|
icons[4] = metadata.combatIcons
|
||||||
icons[5] = metadata.agilityIcons
|
icons[5] = metadata.agilityIcons
|
||||||
end
|
end
|
||||||
|
|
||||||
local IconTypes = { "Wild", "Willpower", "Intellect", "Fight", "Agility" }
|
local IconTypes = { "Wild", "Willpower", "Intellect", "Combat", "Agility" }
|
||||||
local found = false
|
local found = false
|
||||||
for i = 1, 5 do
|
for i = 1, 5 do
|
||||||
if icons[i] ~= nil and icons[i] ~= "" then
|
if icons[i] ~= nil and icons[i] ~= "" then
|
||||||
@ -113,7 +141,6 @@ function findCard(guid, name, GMNotes)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
table.insert(cardsInBag, { name = name, id = guid })
|
table.insert(cardsInBag, { name = name, id = guid })
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -124,9 +151,7 @@ function recreateButtons()
|
|||||||
|
|
||||||
for _, card in ipairs(cardsInBag) do
|
for _, card in ipairs(cardsInBag) do
|
||||||
if _G['removeCard' .. card.id] == nil then
|
if _G['removeCard' .. card.id] == nil then
|
||||||
_G['removeCard' .. card.id] = function()
|
_G['removeCard' .. card.id] = function() removeCard(card.id) end
|
||||||
removeCard(card.id)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self.createButton({
|
self.createButton({
|
||||||
@ -138,22 +163,21 @@ function recreateButtons()
|
|||||||
width = 1200,
|
width = 1200,
|
||||||
font_size = string.len(card.name) > 20 and 75 or 100
|
font_size = string.len(card.name) > 20 and 75 or 100
|
||||||
})
|
})
|
||||||
|
|
||||||
verticalPosition = verticalPosition - 0.5
|
verticalPosition = verticalPosition - 0.5
|
||||||
end
|
end
|
||||||
|
|
||||||
local countLabel = '\nAttachment\nHelper\nv' .. information["version"]
|
local countLabel = '\nAttachment\nHelper\n' .. information["version"]
|
||||||
if #cardsInBag ~= 0 then countLabel = #cardsInBag end
|
if #cardsInBag ~= 0 then countLabel = #cardsInBag end
|
||||||
|
|
||||||
self.createButton({
|
self.createButton({
|
||||||
label = countLabel,
|
label = countLabel,
|
||||||
click_function = 'none',
|
click_function = "none",
|
||||||
function_owner = self,
|
function_owner = self,
|
||||||
position = { 0, 0, -1.35 },
|
position = { 0, 0, -1.35 },
|
||||||
height = 0,
|
height = 0,
|
||||||
width = 0,
|
width = 0,
|
||||||
font_size = 225,
|
font_size = 225,
|
||||||
font_color = { 1, 1, 1 }
|
font_color = { 1, 1, 1, 1 }
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
-- Chaos Bag Manager
|
-- Chaos Bag Manager
|
||||||
-- made by: Chr1Z
|
-- made by: Chr1Z
|
||||||
-- based on: Bless/Curse Manager
|
|
||||||
-- description: for easier managing of the chaos bag (adding / removing tokens)
|
-- description: for easier managing of the chaos bag (adding / removing tokens)
|
||||||
information = {
|
information = {
|
||||||
version = "1.3",
|
version = "1.4",
|
||||||
last_updated = "10.10.2022"
|
last_updated = "12.11.2022"
|
||||||
}
|
}
|
||||||
|
|
||||||
local TOKEN_URL = {
|
local TOKEN_URL = {
|
||||||
@ -45,48 +44,45 @@ local BUTTON_TOOLTIP = {
|
|||||||
"Elder Sign", "Skull", "Cultist", "Tablet", "Elder Thing", "Auto-fail"
|
"Elder Sign", "Skull", "Cultist", "Tablet", "Elder Thing", "Auto-fail"
|
||||||
}
|
}
|
||||||
|
|
||||||
y0 = 0
|
local tokenarranger = getObjectFromGUID("022907")
|
||||||
z1 = -0.778
|
local z = { -0.778, 0, 0.75 }
|
||||||
z2 = 0
|
|
||||||
z3 = 0.75
|
|
||||||
|
|
||||||
local BUTTON_POSITION = {
|
local BUTTON_POSITION = {
|
||||||
-- first row
|
-- first row
|
||||||
{ -1.90, y0, z1 },
|
{ -1.90, 0, z[1] },
|
||||||
{ -1.14, y0, z1 },
|
{ -1.14, 0, z[1] },
|
||||||
{ -0.38, y0, z1 },
|
{ -0.38, 0, z[1] },
|
||||||
{ 0.38, y0, z1 },
|
{ 0.38, 0, z[1] },
|
||||||
{ 1.14, y0, z1 },
|
{ 1.14, 0, z[1] },
|
||||||
{ 1.90, y0, z1 },
|
{ 1.90, 0, z[1] },
|
||||||
-- second row
|
-- second row
|
||||||
{ -1.90, y0, z2 },
|
{ -1.90, 0, z[2] },
|
||||||
{ -1.14, y0, z2 },
|
{ -1.14, 0, z[2] },
|
||||||
{ -0.38, y0, z2 },
|
{ -0.38, 0, z[2] },
|
||||||
{ 0.38, y0, z2 },
|
{ 0.38, 0, z[2] },
|
||||||
{ 1.90, y0, z2 },
|
{ 1.90, 0, z[2] },
|
||||||
-- third row
|
-- third row
|
||||||
{ -1.90, y0, z3 },
|
{ -1.90, 0, z[3] },
|
||||||
{ -1.14, y0, z3 },
|
{ -1.14, 0, z[3] },
|
||||||
{ -0.38, y0, z3 },
|
{ -0.38, 0, z[3] },
|
||||||
{ 0.38, y0, z3 },
|
{ 0.38, 0, z[3] },
|
||||||
{ 1.14, y0, z3 },
|
{ 1.14, 0, z[3] },
|
||||||
{ 1.90, y0, z3 },
|
{ 1.90, 0, z[3] },
|
||||||
}
|
}
|
||||||
|
|
||||||
-- common button parameters
|
-- common button parameters
|
||||||
local BUTTON_PARAMETERS = {}
|
local buttonParameters = {}
|
||||||
BUTTON_PARAMETERS.function_owner = self
|
buttonParameters.function_owner = self
|
||||||
BUTTON_PARAMETERS.color = { 0, 0, 0, 0 }
|
buttonParameters.color = { 0, 0, 0, 0 }
|
||||||
BUTTON_PARAMETERS.width = 300
|
buttonParameters.width = 300
|
||||||
BUTTON_PARAMETERS.height = 300
|
buttonParameters.height = 300
|
||||||
|
|
||||||
function onload()
|
function onLoad()
|
||||||
-- create buttons for tokens
|
-- create buttons for tokens
|
||||||
for i = 1, #BUTTON_POSITION do
|
for i = 1, #BUTTON_POSITION do
|
||||||
BUTTON_PARAMETERS.position = BUTTON_POSITION[i]
|
buttonParameters.position = BUTTON_POSITION[i]
|
||||||
BUTTON_PARAMETERS.click_function = attachIndex("button_click", i)
|
buttonParameters.click_function = attachIndex("button_click", i)
|
||||||
BUTTON_PARAMETERS.tooltip = BUTTON_TOOLTIP[i]
|
buttonParameters.tooltip = BUTTON_TOOLTIP[i]
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.addContextMenuItem("More Information", function()
|
self.addContextMenuItem("More Information", function()
|
||||||
@ -139,7 +135,7 @@ function button_click(obj, player_color, alt_click, index)
|
|||||||
|
|
||||||
name = BUTTON_TOOLTIP[index]
|
name = BUTTON_TOOLTIP[index]
|
||||||
tokens = {}
|
tokens = {}
|
||||||
for i, v in ipairs(chaosbag.getObjects()) do
|
for _, v in ipairs(chaosbag.getObjects()) do
|
||||||
if v.name == name then table.insert(tokens, v.guid) end
|
if v.name == name then table.insert(tokens, v.guid) end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -174,9 +170,11 @@ function button_click(obj, player_color, alt_click, index)
|
|||||||
obj.setCustomObject({
|
obj.setCustomObject({
|
||||||
type = 2,
|
type = 2,
|
||||||
image = TOKEN_URL[token],
|
image = TOKEN_URL[token],
|
||||||
thickness = 0.10
|
thickness = 0.1
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
updateTokenArranger()
|
||||||
end
|
end
|
||||||
|
|
||||||
function remove_callback(obj)
|
function remove_callback(obj)
|
||||||
@ -189,3 +187,14 @@ function spawn_callback(obj)
|
|||||||
obj.setName(name)
|
obj.setName(name)
|
||||||
printToAll("Adding " .. name .. " token (in bag: " .. #tokens + 1 .. ")", "White")
|
printToAll("Adding " .. name .. " token (in bag: " .. #tokens + 1 .. ")", "White")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
UPDATING = false
|
||||||
|
function updateTokenArranger()
|
||||||
|
if tokenarranger and not UPDATING then
|
||||||
|
UPDATING = true
|
||||||
|
Wait.time(function()
|
||||||
|
UPDATING = false
|
||||||
|
tokenarranger.call("layout")
|
||||||
|
end, 1.5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@ -5,8 +5,8 @@
|
|||||||
-- - puts everything on playmats and hands into respective trashcans
|
-- - puts everything on playmats and hands into respective trashcans
|
||||||
-- - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")
|
-- - use the IGNORE_TAG to exclude objects from tidying (default: "CleanUpHelper_Ignore")
|
||||||
information = {
|
information = {
|
||||||
version = "2.0",
|
version = "2.3",
|
||||||
last_updated = "10.10.2022"
|
last_updated = "12.11.2022"
|
||||||
}
|
}
|
||||||
|
|
||||||
-- enable this for debugging
|
-- enable this for debugging
|
||||||
@ -49,6 +49,7 @@ DEFAULT_VALUES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PLAYERMAT_GUIDS = { "8b081b"; "bd0ff4"; "383d8b"; "0840d5" }
|
PLAYERMAT_GUIDS = { "8b081b"; "bd0ff4"; "383d8b"; "0840d5" }
|
||||||
|
TRACKER_GUIDS = { "e598c2"; "b4a5f7"; "af7ed7"; "e74881" }
|
||||||
CLUE_GUIDS = { "d86b7c"; "1769ed"; "032300"; "37be78" }
|
CLUE_GUIDS = { "d86b7c"; "1769ed"; "032300"; "37be78" }
|
||||||
TRASHCAN_GUIDS = { "147e80"; "f7b6c8"; "5f896a"; "4b8594"; "70b9f6" }
|
TRASHCAN_GUIDS = { "147e80"; "f7b6c8"; "5f896a"; "4b8594"; "70b9f6" }
|
||||||
|
|
||||||
@ -56,34 +57,29 @@ PLAYMATZONE = getObjectFromGUID("a2f932")
|
|||||||
|
|
||||||
-- values for physics.cast (4 entries for player zones, 5th entry for agenda/act deck, 6th for campaign log)
|
-- values for physics.cast (4 entries for player zones, 5th entry for agenda/act deck, 6th for campaign log)
|
||||||
PHYSICS_POSITION = {
|
PHYSICS_POSITION = {
|
||||||
{ x = -54.5, y = 2, z = 21 };
|
{ -54.5, 2, 21 };
|
||||||
{ x = -54.5, y = 2, z = -21 };
|
{ -54.5, 2, -21 };
|
||||||
{ x = -25.0, y = 2, z = 26 };
|
{ -25.0, 2, 26 };
|
||||||
{ x = -25.0, y = 2, z = -26 };
|
{ -25.0, 2, -26 };
|
||||||
{ x = -02.0, y = 2, z = 10 };
|
{ -02.0, 2, 10 };
|
||||||
{ x = -00.0, y = 2, z = -27 }
|
{ -00.0, 2, -27 }
|
||||||
}
|
}
|
||||||
|
|
||||||
PHYSICS_ROTATION = {
|
PHYSICS_ROTATION = { 270, 270, 0, 180, 270, 0 }
|
||||||
{ x = 0, y = 270, z = 0 };
|
|
||||||
{ x = 0, y = 270, z = 0 };
|
|
||||||
{ x = 0, y = 000, z = 0 };
|
|
||||||
{ x = 0, y = 180, z = 0 };
|
|
||||||
{ x = 0, y = 270, z = 0 };
|
|
||||||
{ x = 0, y = 000, z = 0 }
|
|
||||||
}
|
|
||||||
|
|
||||||
PHYSICS_SCALE = {
|
PHYSICS_SCALE = {
|
||||||
{ x = 36.6, y = 1, z = 14.5 };
|
{ 36.6, 1, 14.5 };
|
||||||
{ x = 36.6, y = 1, z = 14.5 };
|
{ 36.6, 1, 14.5 };
|
||||||
{ x = 28.0, y = 1, z = 14.5 };
|
{ 28.0, 1, 14.5 };
|
||||||
{ x = 28.0, y = 1, z = 14.5 };
|
{ 28.0, 1, 14.5 };
|
||||||
{ x = 55.0, y = 1, z = 13.5 };
|
{ 55.0, 1, 13.5 };
|
||||||
{ x = 05.0, y = 1, z = 05.0 }
|
{ 05.0, 1, 05.0 }
|
||||||
}
|
}
|
||||||
|
|
||||||
local BUTTON_PARAMETERS = {}
|
local blurse = getObjectFromGUID("5933fb")
|
||||||
BUTTON_PARAMETERS.function_owner = self
|
|
||||||
|
local buttonParameters = {}
|
||||||
|
buttonParameters.function_owner = self
|
||||||
|
|
||||||
-- saving the options
|
-- saving the options
|
||||||
function onSave() return JSON.encode({ tidy_playermats, import_trauma, reset_resources }) end
|
function onSave() return JSON.encode({ tidy_playermats, import_trauma, reset_resources }) end
|
||||||
@ -109,44 +105,44 @@ function onLoad(saved_data)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- index 0: button as label
|
-- index 0: button as label
|
||||||
BUTTON_PARAMETERS.label = "Clean Up Helper v" .. information["version"]
|
buttonParameters.label = "Clean Up Helper v" .. information["version"]
|
||||||
BUTTON_PARAMETERS.click_function = "none"
|
buttonParameters.click_function = "none"
|
||||||
BUTTON_PARAMETERS.position = { x = 0, y = 0.1, z = -1.525 }
|
buttonParameters.position = { x = 0, y = 0.1, z = -1.525 }
|
||||||
BUTTON_PARAMETERS.height = 0
|
buttonParameters.height = 0
|
||||||
BUTTON_PARAMETERS.width = 0
|
buttonParameters.width = 0
|
||||||
BUTTON_PARAMETERS.font_size = 165
|
buttonParameters.font_size = 165
|
||||||
BUTTON_PARAMETERS.font_color = "Black"
|
buttonParameters.font_color = "Black"
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
-- index 1: option button for playermats
|
-- index 1: option button for playermats
|
||||||
BUTTON_PARAMETERS.label = "Tidy playermats: " .. (tidy_playermats and "✓" or "✗")
|
buttonParameters.label = "Tidy playermats: " .. (tidy_playermats and "✓" or "✗")
|
||||||
BUTTON_PARAMETERS.color = { 0, 0, 0, 0.95 }
|
buttonParameters.color = { 0, 0, 0, 0.95 }
|
||||||
BUTTON_PARAMETERS.click_function = "toggle1"
|
buttonParameters.click_function = "toggle1"
|
||||||
BUTTON_PARAMETERS.position.z = -0.8
|
buttonParameters.position.z = -0.8
|
||||||
BUTTON_PARAMETERS.height = 275
|
buttonParameters.height = 275
|
||||||
BUTTON_PARAMETERS.width = 1550
|
buttonParameters.width = 1550
|
||||||
BUTTON_PARAMETERS.font_size = 165
|
buttonParameters.font_size = 165
|
||||||
BUTTON_PARAMETERS.font_color = "White"
|
buttonParameters.font_color = "White"
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
-- index 2: option button for trauma import
|
-- index 2: option button for trauma import
|
||||||
BUTTON_PARAMETERS.label = "Import trauma: " .. (import_trauma and "✓" or "✗")
|
buttonParameters.label = "Import trauma: " .. (import_trauma and "✓" or "✗")
|
||||||
BUTTON_PARAMETERS.click_function = "toggle2"
|
buttonParameters.click_function = "toggle2"
|
||||||
BUTTON_PARAMETERS.position.z = -0.1
|
buttonParameters.position.z = -0.1
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
-- index 3: option button for resources
|
-- index 3: option button for resources
|
||||||
BUTTON_PARAMETERS.label = "Reset resources: " .. (reset_resources and "✓" or "✗")
|
buttonParameters.label = "Reset resources: " .. (reset_resources and "✓" or "✗")
|
||||||
BUTTON_PARAMETERS.click_function = "toggle3"
|
buttonParameters.click_function = "toggle3"
|
||||||
BUTTON_PARAMETERS.position.z = 0.6
|
buttonParameters.position.z = 0.6
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
-- index 4: start button
|
-- index 4: start button
|
||||||
BUTTON_PARAMETERS.label = "Start!"
|
buttonParameters.label = "Start!"
|
||||||
BUTTON_PARAMETERS.click_function = "cleanUp"
|
buttonParameters.click_function = "cleanUp"
|
||||||
BUTTON_PARAMETERS.position.z = 1.3
|
buttonParameters.position.z = 1.3
|
||||||
BUTTON_PARAMETERS.width = 775
|
buttonParameters.width = 775
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
|
|
||||||
-- create single table for ignoring
|
-- create single table for ignoring
|
||||||
for _, v in ipairs(CLUE_GUIDS) do table.insert(IGNORE_GUIDS, v) end
|
for _, v in ipairs(CLUE_GUIDS) do table.insert(IGNORE_GUIDS, v) end
|
||||||
@ -165,12 +161,12 @@ end
|
|||||||
|
|
||||||
function toggle2()
|
function toggle2()
|
||||||
import_trauma = not import_trauma
|
import_trauma = not import_trauma
|
||||||
self.editButton({ index = 2, label = "Import trauma: " .. (import_trauma and "✓" or "✗") })
|
self.editButton({ index = 2, label = "Import trauma: " .. (import_trauma and "✓" or "✗") })
|
||||||
end
|
end
|
||||||
|
|
||||||
function toggle3()
|
function toggle3()
|
||||||
reset_resources = not reset_resources
|
reset_resources = not reset_resources
|
||||||
self.editButton({ index = 3, label = "Reset resources: " .. (reset_resources and "✓" or "✗") })
|
self.editButton({ index = 3, label = "Reset resources: " .. (reset_resources and "✓" or "✗") })
|
||||||
end
|
end
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -184,6 +180,7 @@ function cleanUp()
|
|||||||
|
|
||||||
getTrauma()
|
getTrauma()
|
||||||
resetCounters()
|
resetCounters()
|
||||||
|
removeBlurse()
|
||||||
|
|
||||||
printToAll("Discarding player hands...", "White")
|
printToAll("Discarding player hands...", "White")
|
||||||
discardHands()
|
discardHands()
|
||||||
@ -211,6 +208,14 @@ function resetCounters()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
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")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- read values for trauma from campaign log if enabled
|
-- read values for trauma from campaign log if enabled
|
||||||
@ -249,6 +254,11 @@ function getTrauma()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- get rid of bless/curse tokens
|
||||||
|
function removeBlurse()
|
||||||
|
if blurse ~= nil then blurse.call("doRemove", "White") end
|
||||||
|
end
|
||||||
|
|
||||||
-- discard all hand objects
|
-- discard all hand objects
|
||||||
function discardHands()
|
function discardHands()
|
||||||
for i = 1, 4 do
|
for i = 1, 4 do
|
||||||
@ -275,7 +285,14 @@ function tidyPlaymatCoroutine()
|
|||||||
trashcan.putObject(obj)
|
trashcan.putObject(obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local PLAYMAT = getObjectFromGUID('721ba2')
|
||||||
|
if PLAYMAT then
|
||||||
|
PLAYMAT.setTable("SPAWNED_LOCATION_GUIDS", {})
|
||||||
|
end
|
||||||
|
|
||||||
printToAll("Tidying playermats and agenda mat...", "White")
|
printToAll("Tidying playermats and agenda mat...", "White")
|
||||||
startLuaCoroutine(self, "tidyPlayerMatCoroutine")
|
startLuaCoroutine(self, "tidyPlayerMatCoroutine")
|
||||||
return 1
|
return 1
|
||||||
@ -312,8 +329,22 @@ function tidyPlayerMatCoroutine()
|
|||||||
obj.flip()
|
obj.flip()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- reset "activeInvestigatorId"
|
||||||
|
if i < 5 then
|
||||||
|
local playermat = getObjectFromGUID(PLAYERMAT_GUIDS[i])
|
||||||
|
if playermat then
|
||||||
|
playermat.setVar("activeInvestigatorId", "00000")
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local datahelper = getObjectFromGUID('708279')
|
||||||
|
if datahelper then
|
||||||
|
datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {})
|
||||||
|
end
|
||||||
|
|
||||||
printToAll("Clean up completed!", "Green")
|
printToAll("Clean up completed!", "Green")
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
@ -326,11 +357,11 @@ end
|
|||||||
function findObjects(num)
|
function findObjects(num)
|
||||||
return Physics.cast({
|
return Physics.cast({
|
||||||
direction = { 0, 1, 0 },
|
direction = { 0, 1, 0 },
|
||||||
max_distance = 2,
|
max_distance = 1,
|
||||||
type = 3,
|
type = 3,
|
||||||
size = PHYSICS_SCALE[num],
|
size = PHYSICS_SCALE[num],
|
||||||
origin = PHYSICS_POSITION[num],
|
origin = PHYSICS_POSITION[num],
|
||||||
orientation = PHYSICS_ROTATION[num],
|
orientation = { 0, PHYSICS_ROTATION[num], 0 },
|
||||||
debug = SHOW_RAYS
|
debug = SHOW_RAYS
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
@ -3,37 +3,36 @@
|
|||||||
-- original by: Tikatoy
|
-- original by: Tikatoy
|
||||||
-- description: search the top X cards of your deck
|
-- description: search the top X cards of your deck
|
||||||
information = {
|
information = {
|
||||||
version = "1.3",
|
version = "1.4",
|
||||||
last_updated = "26.09.2022"
|
last_updated = "12.11.2022"
|
||||||
}
|
}
|
||||||
|
|
||||||
MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" }
|
MAT_GUIDS = { "8b081b", "bd0ff4", "383d8b", "0840d5" }
|
||||||
|
|
||||||
-- common parameters
|
-- common parameters
|
||||||
local BUTTON_PARAMETERS = {}
|
local buttonParameters = {}
|
||||||
BUTTON_PARAMETERS.function_owner = self
|
buttonParameters.function_owner = self
|
||||||
BUTTON_PARAMETERS.font_size = 125
|
buttonParameters.font_size = 125
|
||||||
BUTTON_PARAMETERS.width = 650
|
buttonParameters.width = 650
|
||||||
BUTTON_PARAMETERS.height = 225
|
buttonParameters.height = 225
|
||||||
|
|
||||||
local INPUT_PARAMETERS = {}
|
local inputParameters = {}
|
||||||
INPUT_PARAMETERS.function_owner = self
|
inputParameters.function_owner = self
|
||||||
INPUT_PARAMETERS.input_function = "updateSearchNumber"
|
inputParameters.input_function = "updateSearchNumber"
|
||||||
INPUT_PARAMETERS.tooltip = "number of cards to search"
|
inputParameters.tooltip = "number of cards to search"
|
||||||
INPUT_PARAMETERS.label = "#"
|
inputParameters.label = "#"
|
||||||
INPUT_PARAMETERS.font_size = 175
|
inputParameters.font_size = 175
|
||||||
INPUT_PARAMETERS.width = 400
|
inputParameters.width = 400
|
||||||
INPUT_PARAMETERS.height = INPUT_PARAMETERS.font_size + 23
|
inputParameters.height = inputParameters.font_size + 23
|
||||||
INPUT_PARAMETERS.position = { 0, 0.1, 0 }
|
inputParameters.position = { 0, 0.11, 0 }
|
||||||
INPUT_PARAMETERS.alignment = 3
|
inputParameters.alignment = 3
|
||||||
INPUT_PARAMETERS.validation = 2
|
inputParameters.validation = 2
|
||||||
|
|
||||||
|
function onSave() return JSON.encode(playerColor) end
|
||||||
|
|
||||||
function onLoad(save_state)
|
function onLoad(save_state)
|
||||||
if save_state ~= nil then
|
if save_state ~= nil then
|
||||||
local loaded_data = JSON.decode(save_state)
|
playerColor = JSON.decode(save_state)
|
||||||
if loaded_data.playerColor ~= nil then
|
|
||||||
playerColor = loaded_data.playerColor
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if playerColor == nil then
|
if playerColor == nil then
|
||||||
@ -50,10 +49,6 @@ function onLoad(save_state)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
function onSave()
|
|
||||||
return JSON.encode({ playerColor = playerColor })
|
|
||||||
end
|
|
||||||
|
|
||||||
-- regular view with search box and color switcher
|
-- regular view with search box and color switcher
|
||||||
function normalView()
|
function normalView()
|
||||||
self.clearButtons()
|
self.clearButtons()
|
||||||
@ -61,7 +56,7 @@ function normalView()
|
|||||||
|
|
||||||
createSearchButton()
|
createSearchButton()
|
||||||
changeColor("initialize")
|
changeColor("initialize")
|
||||||
self.createInput(INPUT_PARAMETERS)
|
self.createInput(inputParameters)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- view during a search with "done" buttons
|
-- view during a search with "done" buttons
|
||||||
@ -74,58 +69,64 @@ function searchView()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- change color (or initialize button)
|
-- change color (or initialize button)
|
||||||
function changeColor(arg)
|
function changeColor(arg, _, isRightClick)
|
||||||
if arg ~= "initialize" then
|
if arg ~= "initialize" then
|
||||||
-- update table with colors
|
-- update table with colors
|
||||||
COLORS = Player.getAvailableColors()
|
COLORS = Player.getAvailableColors()
|
||||||
table.insert(COLORS, COLORS[1])
|
|
||||||
|
|
||||||
-- get index of current color and move up one step
|
|
||||||
local pos = indexOf(COLORS, playerColor)
|
local pos = indexOf(COLORS, playerColor)
|
||||||
if pos == nil then pos = 0 end
|
|
||||||
playerColor = COLORS[pos + 1]
|
if isRightClick then
|
||||||
|
if pos == nil or pos == 1 then pos = #COLORS
|
||||||
|
else pos = pos - 1 end
|
||||||
|
else
|
||||||
|
if pos == nil or pos == #COLORS then pos = 1
|
||||||
|
else pos = pos + 1 end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- update playerColor
|
||||||
|
playerColor = COLORS[pos]
|
||||||
|
|
||||||
-- remove button and recreate it afterwards
|
-- remove button and recreate it afterwards
|
||||||
self.removeButton(1)
|
self.removeButton(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
BUTTON_PARAMETERS.click_function = "changeColor"
|
buttonParameters.click_function = "changeColor"
|
||||||
BUTTON_PARAMETERS.tooltip = "change color"
|
buttonParameters.tooltip = "change color"
|
||||||
BUTTON_PARAMETERS.position = { 0, 0.1, -0.65 }
|
buttonParameters.position = { 0, 0.11, -0.65 }
|
||||||
BUTTON_PARAMETERS.label = playerColor
|
buttonParameters.label = playerColor
|
||||||
BUTTON_PARAMETERS.color = Color.fromString(playerColor)
|
buttonParameters.color = Color.fromString(playerColor)
|
||||||
BUTTON_PARAMETERS.hover_color = BUTTON_PARAMETERS.color
|
buttonParameters.hover_color = buttonParameters.color
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create the search button
|
-- create the search button
|
||||||
function createSearchButton()
|
function createSearchButton()
|
||||||
BUTTON_PARAMETERS.click_function = "startSearch"
|
buttonParameters.click_function = "startSearch"
|
||||||
BUTTON_PARAMETERS.tooltip = "start the search"
|
buttonParameters.tooltip = "start the search"
|
||||||
BUTTON_PARAMETERS.position = { 0, 0.1, 0.65 }
|
buttonParameters.position = { 0, 0.11, 0.65 }
|
||||||
BUTTON_PARAMETERS.label = "Search"
|
buttonParameters.label = "Search"
|
||||||
BUTTON_PARAMETERS.color = Color.fromString("White")
|
buttonParameters.color = Color.fromString("White")
|
||||||
BUTTON_PARAMETERS.hover_color = nil
|
buttonParameters.hover_color = nil
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- create the done buttons (with and without shuffle)
|
-- create the done buttons (with and without shuffle)
|
||||||
function createDoneButton(arg)
|
function createDoneButton(arg)
|
||||||
if arg then
|
if arg then
|
||||||
BUTTON_PARAMETERS.click_function = "endSearch1"
|
buttonParameters.click_function = "endSearch1"
|
||||||
BUTTON_PARAMETERS.tooltip = "Done (Shuffle)"
|
buttonParameters.tooltip = "Done (Shuffle)"
|
||||||
BUTTON_PARAMETERS.position = { 0, 0.1, -0.65 }
|
buttonParameters.position = { 0, 0.11, -0.65 }
|
||||||
BUTTON_PARAMETERS.label = "Shuffle"
|
buttonParameters.label = "Shuffle"
|
||||||
else
|
else
|
||||||
BUTTON_PARAMETERS.click_function = "endSearch2"
|
buttonParameters.click_function = "endSearch2"
|
||||||
BUTTON_PARAMETERS.tooltip = "Done (No Shuffle)"
|
buttonParameters.tooltip = "Done (No Shuffle)"
|
||||||
BUTTON_PARAMETERS.position = { 0, 0.1, 0.65 }
|
buttonParameters.position = { 0, 0.11, 0.65 }
|
||||||
BUTTON_PARAMETERS.label = "No Shuffle"
|
buttonParameters.label = "No Shuffle"
|
||||||
end
|
end
|
||||||
|
|
||||||
BUTTON_PARAMETERS.color = Color.fromString("White")
|
buttonParameters.color = Color.fromString("White")
|
||||||
BUTTON_PARAMETERS.hover_color = nil
|
buttonParameters.hover_color = nil
|
||||||
self.createButton(BUTTON_PARAMETERS)
|
self.createButton(buttonParameters)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get the draw deck from the player mat
|
-- get the draw deck from the player mat
|
||||||
@ -136,12 +137,12 @@ end
|
|||||||
|
|
||||||
-- input_function to get number of cards to search
|
-- input_function to get number of cards to search
|
||||||
function updateSearchNumber(_, _, input)
|
function updateSearchNumber(_, _, input)
|
||||||
INPUT_PARAMETERS.value = tonumber(input)
|
inputParameters.value = tonumber(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- start the search (change UI, set hand aside, draw cards)
|
-- start the search (change UI, set hand aside, draw cards)
|
||||||
function startSearch(_, color)
|
function startSearch(_, color)
|
||||||
if INPUT_PARAMETERS.value == nil then
|
if inputParameters.value == nil then
|
||||||
printToColor("Enter the number of cards to search in the textbox.", color, "Orange")
|
printToColor("Enter the number of cards to search in the textbox.", color, "Orange")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -194,29 +195,22 @@ function startSearch(_, color)
|
|||||||
searchView()
|
searchView()
|
||||||
|
|
||||||
-- handling for Norman Withers
|
-- handling for Norman Withers
|
||||||
for i, object in ipairs(getObjectFromGUID(zoneID).getObjects()) do
|
for _, object in ipairs(getObjectFromGUID(zoneID).getObjects()) do
|
||||||
if self.positionToLocal(object.getPosition()).z < 0.5 and object.tag == "Card" and not object.is_face_down then
|
local pos = self.positionToLocal(object.getPosition())
|
||||||
|
if pos.z < -0.5 and object.tag == "Card" and not object.is_face_down then
|
||||||
object.flip()
|
object.flip()
|
||||||
Wait.time(function()
|
Wait.time(function() drawDeck = getDrawDeck() end, 1)
|
||||||
drawDeck = getDrawDeck()
|
|
||||||
end, 1)
|
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Wait.time(function()
|
Wait.time(function() drawDeck.deal(inputParameters.value, playerColor) end, 1)
|
||||||
drawDeck.deal(INPUT_PARAMETERS.value, playerColor)
|
|
||||||
end, 1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- place hand back into deck and optionally shuffle
|
-- place hand back into deck and optionally shuffle
|
||||||
function endSearch1()
|
function endSearch1() endSearch(true) end
|
||||||
endSearch("true")
|
|
||||||
end
|
|
||||||
|
|
||||||
function endSearch2()
|
function endSearch2() endSearch(false) end
|
||||||
endSearch("false")
|
|
||||||
end
|
|
||||||
|
|
||||||
function endSearch(shuffle)
|
function endSearch(shuffle)
|
||||||
local hand = Player[playerColor].getHandObjects()
|
local hand = Player[playerColor].getHandObjects()
|
||||||
@ -226,7 +220,7 @@ function endSearch(shuffle)
|
|||||||
hand[i].setRotation(deck_rotation)
|
hand[i].setRotation(deck_rotation)
|
||||||
end
|
end
|
||||||
|
|
||||||
if shuffle == "true" then
|
if shuffle then
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
local deck = getDrawDeck()
|
local deck = getDrawDeck()
|
||||||
if deck ~= nil then
|
if deck ~= nil then
|
||||||
@ -238,18 +232,23 @@ function endSearch(shuffle)
|
|||||||
-- draw set aside cards (from the ground!)
|
-- draw set aside cards (from the ground!)
|
||||||
local objs = Physics.cast({
|
local objs = Physics.cast({
|
||||||
origin = set_aside_pos - Vector(0, 5, 0),
|
origin = set_aside_pos - Vector(0, 5, 0),
|
||||||
direction = { x = 0, y = 1, z = 0 },
|
direction = { 0, 1, 0 },
|
||||||
type = 3,
|
type = 3,
|
||||||
size = { 2, 2, 2 }
|
size = { 2, 2, 2 },
|
||||||
|
max_distance = 0
|
||||||
})
|
})
|
||||||
|
|
||||||
for i, v in ipairs(objs) do
|
for _, v in ipairs(objs) do
|
||||||
local obj = v.hit_object
|
local obj = v.hit_object
|
||||||
if obj.tag == "Deck" then
|
if obj.tag == "Deck" then
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
obj.deal(#obj.getObjects(), playerColor)
|
obj.deal(#obj.getObjects(), playerColor)
|
||||||
end, 1)
|
end, 1)
|
||||||
break
|
break
|
||||||
|
elseif obj.tag == "Card" then
|
||||||
|
obj.setPosition(Player[playerColor].getHandTransform().position)
|
||||||
|
obj.flip()
|
||||||
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -259,8 +258,6 @@ end
|
|||||||
-- helper to search array
|
-- helper to search array
|
||||||
function indexOf(array, value)
|
function indexOf(array, value)
|
||||||
for i, v in ipairs(array) do
|
for i, v in ipairs(array) do
|
||||||
if v == value then
|
if v == value then return i end
|
||||||
return i
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user