optimization

This commit is contained in:
Chr1Z93 2023-10-01 11:28:31 +02:00
parent 282a411ec2
commit 8c3e87867b
6 changed files with 11 additions and 22 deletions

View File

@ -131,11 +131,11 @@
"EdgeoftheEarth.895eaa",
"TheDream-Eaters.a16a1a",
"ReturntoTheCircleUndone.757324",
"Playermat4Red.0840d5",
"Playermat3Green.383d8b",
"OtherDoominPlay.652ff3",
"Playermat1White.8b081b",
"Playermat2Orange.bd0ff4",
"Playermat3Green.383d8b",
"Playermat4Red.0840d5",
"Neutral.2691e1",
"Neutral.748245",
"Neutral.271b17",

View File

@ -20,7 +20,7 @@ function onLoad()
color = { 0, 0, 0, 0 }
})
trash = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" })
TRASH = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "Trash" })
ZONE = Global.call("getObjectFromMemo", { matColor = "Mythos", type = "PlayAreaZone" })
loopID = Wait.time(countDoom, 2, -1)
end

View File

@ -169,7 +169,7 @@ function getObjectFromMemo(searchParam)
if matColor == nil or type == nil then return nil end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo then
if memo and memo:sub(1, 1) == "{" then
local decoded = JSON.decode(memo) or {}
if decoded.matColor == matColor and decoded.type == type then
return obj
@ -184,10 +184,9 @@ end
---@return objList Table Table of type-object pairs
function getObjectsForMatColor(matColor)
local objList = {}
if matColor == nil then return objList end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo then
if memo and memo:sub(1, 1) == "{" then
local decoded = JSON.decode(memo) or {}
if decoded.matColor == matColor then
objList[decoded.type] = obj
@ -202,10 +201,9 @@ end
---@return objList Table Table of matColor-object pairs
function getObjectsForType(type)
local objList = {}
if type == nil then return objList end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo then
if memo and memo:sub(1, 1) == "{" then
local decoded = JSON.decode(memo) or {}
if decoded.type == type then
objList[decoded.matColor] = obj

View File

@ -52,8 +52,7 @@ function findValidItemsInSphere()
direction = { 0, 1, 0 },
type = 2,
max_distance = 0,
size = { 2, 2, 2 },
--debug=true
size = { 2, 2, 2 }
})
retval = {}

View File

@ -903,14 +903,11 @@ end
-- reports the clue count
---@param useClickableCounters Boolean Controls which type of counter is getting checked
function getClueCount(useClickableCounters)
local count = 0
if useClickableCounters then
count = tonumber(ownedObjects.ClickableClueCounter.getVar("val"))
return ownedObjects.ClickableClueCounter.getVar("val")
else
count = tonumber(ownedObjects.ClueCounter.getVar("exposedValue"))
return ownedObjects.ClueCounter.getVar("exposedValue")
end
return count
end
-- Sets this playermat's snap points to limit snapping to matching card types or not. If matchTypes

View File

@ -136,7 +136,7 @@ do
PlaymatApi.getClueCount = function(useClickableCounters, matColor)
local count = 0
for _, mat in pairs(internal.getMatForColor(matColor)) do
count = count + tonumber(mat.call("getClueCount", useClickableCounters))
count = count + mat.call("getClueCount", useClickableCounters)
end
return count
end
@ -198,12 +198,7 @@ do
---@return array Table Single-element if only single playmat is requested
internal.getMatForColor = function(matColor)
if matColor == "All" then
return {
White = Global.call("getObjectFromMemo", {matColor = "White", type = "Playermat"}),
Orange = Global.call("getObjectFromMemo", {matColor = "Orange", type = "Playermat"}),
Green = Global.call("getObjectFromMemo", {matColor = "Green", type = "Playermat"}),
Red = Global.call("getObjectFromMemo", {matColor = "Red", type = "Playermat"})
}
return Global.call("getObjectsForType", "Playermat")
else
return {matColor = Global.call("getObjectFromMemo", {matColor = matColor, type = "Playermat"}) }
end