resolving comments (part 1)
This commit is contained in:
parent
7a60c318ca
commit
43789fdaa7
@ -1,11 +1,3 @@
|
|||||||
-- Chaos Bag Manager
|
|
||||||
-- made by: Chr1Z
|
|
||||||
-- description: for easier managing of the chaos bag (adding / removing tokens)
|
|
||||||
information = {
|
|
||||||
version = "1.5",
|
|
||||||
last_updated = "24.11.2022"
|
|
||||||
}
|
|
||||||
|
|
||||||
local TOKEN_URL = {
|
local TOKEN_URL = {
|
||||||
ElderSign = "https://i.imgur.com/nEmqjmj.png",
|
ElderSign = "https://i.imgur.com/nEmqjmj.png",
|
||||||
plusOne = "https://i.imgur.com/uIx8jbY.png",
|
plusOne = "https://i.imgur.com/uIx8jbY.png",
|
||||||
@ -61,7 +53,7 @@ buttonParameters.width = 300
|
|||||||
buttonParameters.height = 300
|
buttonParameters.height = 300
|
||||||
|
|
||||||
local UPDATING = false
|
local UPDATING = false
|
||||||
local tokenarranger
|
local tokenArranger
|
||||||
|
|
||||||
local name
|
local name
|
||||||
local tokens = {}
|
local tokens = {}
|
||||||
@ -87,11 +79,10 @@ function onLoad()
|
|||||||
|
|
||||||
self.addContextMenuItem("More Information", function()
|
self.addContextMenuItem("More Information", function()
|
||||||
printToAll("------------------------------", "White")
|
printToAll("------------------------------", "White")
|
||||||
printToAll("Chaos Bag Manager v" .. information["version"] .. " by Chr1Z", "Orange")
|
printToAll("Chaos Bag Manager by Chr1Z", "Orange")
|
||||||
printToAll("last updated: " .. information["last_updated"], "White")
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
tokenarranger = getObjectFromGUID("022907")
|
tokenArranger = getObjectFromGUID("022907")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- get chaos bag from scripting zone and description
|
-- get chaos bag from scripting zone and description
|
||||||
@ -182,11 +173,11 @@ function spawnCallback(obj)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function updateTokenArranger()
|
function updateTokenArranger()
|
||||||
if tokenarranger and not UPDATING then
|
if tokenArranger and not UPDATING then
|
||||||
UPDATING = true
|
UPDATING = true
|
||||||
Wait.time(function()
|
Wait.time(function()
|
||||||
UPDATING = false
|
UPDATING = false
|
||||||
tokenarranger.call("layout")
|
tokenArranger.call("layout")
|
||||||
end, 1.5)
|
end, 1.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -93,21 +93,24 @@ function onLoad(save_state)
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
-- send object reference to bless/curse manager
|
-- send object reference to bless/curse manager
|
||||||
Wait.time(function()
|
Wait.time(function() getObjectFromGUID("5933fb").setVar("tokenArranger", self) end, 1)
|
||||||
getObjectFromGUID("5933fb").setVar("tokenArranger", self)
|
|
||||||
end, 1)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function onDestroy()
|
function onDestroy()
|
||||||
|
deleteCopiedTokens()
|
||||||
-- remove object reference from bless/curse manager
|
-- remove object reference from bless/curse manager
|
||||||
getObjectFromGUID("5933fb").setVar("tokenArranger", nil)
|
getObjectFromGUID("5933fb").setVar("tokenArranger", nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function onPickUp()
|
||||||
|
deleteCopiedTokens()
|
||||||
|
end
|
||||||
|
|
||||||
-- helper functions to carry index
|
-- helper functions to carry index
|
||||||
function attachIndex(click_function, index)
|
function attachIndex(click_function, index)
|
||||||
local fn_name = click_function .. index
|
local fn_name = click_function .. index
|
||||||
_G[fn_name] = function(obj, player_color, alt_click)
|
_G[fn_name] = function(obj, player_color, isRightClick)
|
||||||
_G[click_function](obj, player_color, alt_click, index)
|
_G[click_function](obj, player_color, isRightClick, index)
|
||||||
end
|
end
|
||||||
return fn_name
|
return fn_name
|
||||||
end
|
end
|
||||||
@ -121,21 +124,18 @@ function attachIndex2(input_function, index)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- click_function for buttons on chaos tokens
|
-- click_function for buttons on chaos tokens
|
||||||
function tokenClick(obj, player_color, alt_click, index)
|
function tokenClick(_, _, isRightClick, index)
|
||||||
if not updating then
|
if not updating then
|
||||||
updating = true
|
updating = true
|
||||||
if alt_click then
|
local change = tonumber(isRightClick and "-1" or "1")
|
||||||
TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] = TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] - 1
|
TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] = TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] + change
|
||||||
else
|
|
||||||
TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] = TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] + 1
|
|
||||||
end
|
|
||||||
self.editInput({ index = index - 1, value = TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] })
|
self.editInput({ index = index - 1, value = TOKEN_PRECEDENCE[TOKEN_NAMES[index]][1] })
|
||||||
layout()
|
layout()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- input_function for input_boxes
|
-- input_function for input_boxes
|
||||||
function tokenInput(obj, player_color, input, selected, index)
|
function tokenInput(_, _, input, selected, index)
|
||||||
if selected == false and not updating then
|
if selected == false and not updating then
|
||||||
updating = true
|
updating = true
|
||||||
local num = tonumber(input)
|
local num = tonumber(input)
|
||||||
@ -181,10 +181,14 @@ function getChaosBag()
|
|||||||
return chaosbag
|
return chaosbag
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- deletes previously placed tokens
|
||||||
|
function deleteCopiedTokens()
|
||||||
|
for _, token in ipairs(getObjectsWithTag("to_be_deleted")) do token.destruct() end
|
||||||
|
end
|
||||||
|
|
||||||
-- main function (delete old tokens, clone chaos bag content, sort it and position it)
|
-- main function (delete old tokens, clone chaos bag content, sort it and position it)
|
||||||
function layout(_, _, isRightClick)
|
function layout(_, _, isRightClick)
|
||||||
-- delete previously pulled out tokens
|
deleteCopiedTokens()
|
||||||
for _, token in ipairs(getObjectsWithTag("to_be_deleted")) do token.destruct() end
|
|
||||||
|
|
||||||
-- stop here if right-clicked
|
-- stop here if right-clicked
|
||||||
if isRightClick then return end
|
if isRightClick then return end
|
||||||
@ -205,12 +209,11 @@ function layout(_, _, isRightClick)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- wait until all tokens have finished spawning
|
-- wait until all tokens have finished spawning
|
||||||
Wait.condition(function() do_position() end,
|
Wait.condition(function() placeTokens() end, function() return #chaos_bag_objects == #getObjectsWithTag("to_be_deleted") end)
|
||||||
function() return #chaos_bag_objects == #getObjectsWithTag("to_be_deleted") end)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- position tokens sorted by value
|
-- position tokens sorted by value
|
||||||
function do_position()
|
function placeTokens()
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
-- create table with tokens
|
-- create table with tokens
|
||||||
|
@ -854,7 +854,6 @@ function applyOptionPanelChange(id, state)
|
|||||||
-- option: Show chaos bag manager
|
-- option: Show chaos bag manager
|
||||||
elseif id == "showChaosBagManager" then
|
elseif id == "showChaosBagManager" then
|
||||||
spawnOrRemoveHelper(state, "Chaos Bag Manager", {-67.8, 1.4, -49.5})
|
spawnOrRemoveHelper(state, "Chaos Bag Manager", {-67.8, 1.4, -49.5})
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ end
|
|||||||
function doReset(color)
|
function doReset(color)
|
||||||
-- delete previously pulled out tokens by the token arranger
|
-- delete previously pulled out tokens by the token arranger
|
||||||
if tokenArranger then
|
if tokenArranger then
|
||||||
for _, token in ipairs("to_be_deleted") do token.destruct() end
|
tokenArranger.call("deleteCopiedTokens")
|
||||||
end
|
end
|
||||||
|
|
||||||
playerColor = color
|
playerColor = color
|
||||||
|
Loading…
x
Reference in New Issue
Block a user