resolving comments
This commit is contained in:
parent
19b69a3cee
commit
efbf9e885f
@ -33,8 +33,8 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "require(\"core/GenericCounter\")",
|
||||
"LuaScriptState": "0",
|
||||
"LuaScript_path": "TokenSource.124381/ResourceCounter.498ec0.ttslua",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Custom_Token",
|
||||
"Nickname": "Resource Counter",
|
||||
|
@ -1,43 +0,0 @@
|
||||
value = 0
|
||||
|
||||
function onSave() return JSON.encode(value) end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData ~= "" then
|
||||
value = JSON.decode(savedData)
|
||||
end
|
||||
|
||||
self.createButton({
|
||||
label = tostring(value),
|
||||
click_function = "addOrSubtract",
|
||||
function_owner = self,
|
||||
position = { 0, 0.06, 0.1 },
|
||||
height = 600,
|
||||
width = 1000,
|
||||
scale = { 1.5, 1.5, 1.5 },
|
||||
font_size = 600,
|
||||
font_color = { 1, 1, 1, 100 },
|
||||
color = { 0, 0, 0, 0 }
|
||||
})
|
||||
self.addContextMenuItem("Value from description", function(color) setToDescription(color) end)
|
||||
end
|
||||
|
||||
function setToDescription(color)
|
||||
local newValue = tonumber(self.getDescription())
|
||||
if type(newValue) == "number" and newValue <= 99 and newValue >= 0 then
|
||||
updateVal(newValue)
|
||||
else
|
||||
printToColor("Description does not contain a valid one or two digit number!", color, "Red")
|
||||
end
|
||||
end
|
||||
|
||||
function addOrSubtract(_, _, isRightClick)
|
||||
local mod = isRightClick and -1 or 1
|
||||
newValue = math.min(math.max(value + mod, 0), 99)
|
||||
updateVal(newValue)
|
||||
end
|
||||
|
||||
function updateVal(newValue)
|
||||
value = newValue
|
||||
self.editButton({ index = 0, label = tostring(newValue) })
|
||||
end
|
@ -4,15 +4,15 @@ val = 0
|
||||
|
||||
function onSave() return JSON.encode(val) end
|
||||
|
||||
function onLoad(saved_data)
|
||||
if saved_data ~= nil then
|
||||
val = JSON.decode(saved_data)
|
||||
function onLoad(savedData)
|
||||
if savedData ~= nil then
|
||||
val = JSON.decode(savedData)
|
||||
end
|
||||
|
||||
local name = self.getName()
|
||||
local position = {}
|
||||
|
||||
if name == "Damage" or name == "Resources" then
|
||||
if name == "Damage" or name == "Resources" or name == "Resource Counter" then
|
||||
position = { 0, 0.06, 0.1 }
|
||||
elseif name == "Horror" then
|
||||
position = { -0.025, 0.06, -0.025 }
|
||||
@ -32,19 +32,29 @@ function onLoad(saved_data)
|
||||
font_color = { 1, 1, 1, 100 },
|
||||
color = { 0, 0, 0, 0 }
|
||||
})
|
||||
|
||||
if name == "Resource Counter" then
|
||||
self.addContextMenuItem("Set to description", function(color) setToDescription(color) end)
|
||||
end
|
||||
end
|
||||
|
||||
function setToDescription(color)
|
||||
local newVal = tonumber(self.getDescription())
|
||||
if type(newVal) == "number" and newVal <= 99 and newVal >= 0 then
|
||||
updateVal(newVal)
|
||||
else
|
||||
printToColor("Description does not contain a valid number!", color, "Orange")
|
||||
end
|
||||
end
|
||||
|
||||
function updateVal(newVal)
|
||||
if tonumber(newVal) then
|
||||
val = newVal
|
||||
self.editButton({
|
||||
index = 0,
|
||||
label = tostring(val)
|
||||
})
|
||||
self.editButton({ index = 0, label = tostring(val) })
|
||||
end
|
||||
end
|
||||
|
||||
function addOrSubtract(_, _, alt_click)
|
||||
val = math.min(math.max(val + (alt_click and -1 or 1), MIN_VALUE), MAX_VALUE)
|
||||
function addOrSubtract(_, _, isRightClick)
|
||||
val = math.min(math.max(val + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)
|
||||
self.editButton({ index = 0, label = tostring(val) })
|
||||
end
|
||||
|
@ -409,15 +409,17 @@ function replenishTokens(card, count, replenish)
|
||||
|
||||
-- get current amount of resource tokens on the card
|
||||
local search = searchArea(cardPos, { 2.5, 0.5, 3.5 })
|
||||
local clickableResourceCounter = nil
|
||||
local foundTokens = 0
|
||||
|
||||
for _, obj in ipairs(search) do
|
||||
local obj = obj.hit_object
|
||||
if obj.getCustomObject().image == "http://cloud-3.steamusercontent.com/ugc/1758068501357192910/11DDDC7EF621320962FDCF3AE3211D5EDC3D1573/" then
|
||||
foundTokens = foundTokens + math.abs(obj.getQuantity())
|
||||
obj.destruct()
|
||||
elseif obj.getName() == "Resource Counter" then
|
||||
foundTokens = obj.getVar("value")
|
||||
obj.destruct()
|
||||
foundTokens = obj.getVar("val")
|
||||
clickableResourceCounter = obj
|
||||
break
|
||||
end
|
||||
end
|
||||
@ -438,8 +440,13 @@ function replenishTokens(card, count, replenish)
|
||||
|
||||
local newCount = foundTokens + replenish
|
||||
if newCount > count then newCount = count end
|
||||
|
||||
if clickableResourceCounter then
|
||||
clickableResourceCounter.call("updateVal", newCount)
|
||||
else
|
||||
tokenManager.spawnTokenGroup(card, "resource", newCount)
|
||||
end
|
||||
end
|
||||
|
||||
function syncCustomizableMetadata(card)
|
||||
local cardMetadata = JSON.decode(card.getGMNotes()) or { }
|
||||
|
Loading…
Reference in New Issue
Block a user