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