using require for customizables

This commit is contained in:
Chr1Z93 2023-05-11 11:56:39 +02:00
parent 28a22df8be
commit 43fce75b7d
18 changed files with 502 additions and 2508 deletions

View File

@ -103,9 +103,12 @@ function loadCards(slots, investigatorId, bondedList, customizations, playerColo
-- If cards are spread too close together TTS groups them weirdly, selecting multiples -- If cards are spread too close together TTS groups them weirdly, selecting multiples
-- when hovering over a single card. This distance is the minimum to avoid that -- when hovering over a single card. This distance is the minimum to avoid that
local spreadDistance = 1.15 local spreadDistance = 1.15
if (zone == "SetAside4") then if (zone == "SetAside4" and #zoneCards < 6) then
-- SetAside4 is reserved for customization cards, and we want them spread on the table -- SetAside4 is reserved for customization cards, and we want them spread on the table
-- so their checkboxes are visible -- so their checkboxes are visible
-- TO-DO: take into account that spreading will make multiple rows
-- (unclear if this is affected by the user's local setting)
-- -> To avoid weird positioning, there will only be a spread if less than 6 upgradesheets are spawned
if (playerColor == "White") then if (playerColor == "White") then
deckPos.z = deckPos.z + (#zoneCards - 1) * spreadDistance deckPos.z = deckPos.z + (#zoneCards - 1) * spreadDistance
elseif (playerColor == "Green") then elseif (playerColor == "Green") then

View File

@ -1,10 +1,4 @@
-- Customizable Cards: Alchemical Distillation -- Customizable Cards: Alchemical Distillation
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 40 boxSize = 40
@ -12,8 +6,6 @@ boxSize = 40
-- static values -- static values
x_1 = -0.933 x_1 = -0.933
x_offset = 0.075 x_offset = 0.075
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,154 +20,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 2, 4, 5 } existingBoxes = { 1, 1, 1, 1, 2, 4, 5 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Custom Modifications -- Customizable Cards: Custom Modifications
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 38 boxSize = 38
@ -11,8 +6,6 @@ boxSize = 38
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.0735 x_offset = 0.0735
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -26,154 +19,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 2, 2, 3, 3, 4 } existingBoxes = { 1, 2, 2, 3, 3, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Damning Testimony -- Customizable Cards: Damning Testimony
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 40 boxSize = 40
@ -11,8 +6,6 @@ boxSize = 40
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.075 x_offset = 0.075
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -26,154 +19,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 2, 2, 3, 3, 4 } existingBoxes = { 1, 2, 2, 3, 3, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Empirical Hypothesis -- Customizable Cards: Empirical Hypothesis
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 37 boxSize = 37
@ -11,8 +6,6 @@ boxSize = 37
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.069 x_offset = 0.069
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,154 +21,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 2, 2, 3, 4 } existingBoxes = { 1, 1, 1, 1, 2, 2, 3, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Friends in Low Places -- Customizable Cards: Friends in Low Places
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons and input boxes -- Color information for buttons and input boxes
boxSize = 36 boxSize = 36
@ -12,8 +7,6 @@ inputFontsize = 50
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.0685 x_offset = 0.0685
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,156 +21,8 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } existingBoxes = { 1, 2, 2, 2, 2, 3, 3 }
inputBoxes = { 1, 1 } inputBoxes = { 1, 1 }
inputWidth = { 640, 290 } inputWidth = { 640, 290 }
inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } } inputPos = { { 0.275, 0.25, -0.91 }, { 0.6295, 0.25, -0.44 } }
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Grizzled -- Customizable Cards: Grizzled
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons and input boxes -- Color information for buttons and input boxes
boxSize = 40 boxSize = 40
@ -12,8 +7,6 @@ inputFontsize = 50
-- static values -- static values
x_1 = -0.933 x_1 = -0.933
x_offset = 0.075 x_offset = 0.075
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -26,156 +19,8 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 2, 3, 4, 5 } existingBoxes = { 1, 2, 3, 4, 5 }
inputBoxes = { 1, 1, 1 } inputBoxes = { 1, 1, 1 }
inputWidth = { 600, 875, 875 } inputWidth = { 600, 875, 875 }
inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } } inputPos = { { 0.3, 0.25, -0.91 }, { 0.005, 0.25, -0.58 }, { 0.005, 0.25, -0.32 } }
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Honed Instinct -- Customizable Cards: Honed Instinct
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 38 boxSize = 38
@ -11,8 +6,6 @@ boxSize = 38
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.069 x_offset = 0.069
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,154 +21,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Hunter's Armor -- Customizable Cards: Hunter's Armor
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 40 boxSize = 40
@ -11,8 +6,6 @@ boxSize = 40
-- static values -- static values
x_1 = -0.933 x_1 = -0.933
x_offset = 0.075 x_offset = 0.075
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -27,154 +20,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 2, 2, 2, 2, 3, 3 } existingBoxes = { 1, 2, 2, 2, 2, 3, 3 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Hyperphysical Shotcaster -- Customizable Cards: Hyperphysical Shotcaster
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 38 boxSize = 38
@ -11,8 +6,6 @@ boxSize = 38
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.069 x_offset = 0.069
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -27,154 +20,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 2, 2, 2, 2, 2, 4, 4 } existingBoxes = { 2, 2, 2, 2, 2, 4, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,45 +1,40 @@
-- Customizable Cards: Living Ink -- Customizable Cards: Living Ink
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Size information for buttons -- Size information for buttons
boxSize = 40 boxSize = 40
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.075 x_offset = 0.075
y_visible = 0.25 y_visible = 0.25
y_invisible = -0.5 y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
-0.69, -0.69,
-0.355, -0.355,
0.0855, 0.0855,
0.425, 0.425,
0.555, 0.555,
0.685, 0.685,
1.02 1.02
} }
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 2, 2, 3, 3, 3 } existingBoxes = { 1, 1, 2, 2, 3, 3, 3 }
-- override 'marked boxes' for debugging ('all' or 'none') -- override 'marked boxes' for debugging ('all' or 'none')
markDEBUG = "" markDEBUG = ""
-- Locations of the skill selectors -- Locations of the skill selectors
local SKILL_ICON_POSITIONS = { local SKILL_ICON_POSITIONS = {
willpower = { x = 0.085, z = -0.88}, willpower = { x = 0.085, z = -0.88 },
intellect = { x = -0.183, z = -0.88}, intellect = { x = -0.183, z = -0.88 },
combat = { x = -0.473, z = -0.88}, combat = { x = -0.473, z = -0.88 },
agility = { x = -0.74, z = -0.88}, agility = { x = -0.74, z = -0.88 },
} }
local selectedSkills = { local selectedSkills = {
willpower = false, willpower = false,
intellect = false, intellect = false,
combat = false, combat = false,
@ -50,7 +45,7 @@ local selectedSkills = {
function onDestroy() self.script_state = onSave() end function onDestroy() self.script_state = onSave() end
function onSave() function onSave()
local skillArray = { } local skillArray = {}
for skill, isSelected in pairs(selectedSkills) do for skill, isSelected in pairs(selectedSkills) do
if (isSelected) then if (isSelected) then
table.insert(skillArray, skill) table.insert(skillArray, skill)
@ -61,35 +56,35 @@ end
-- Startup procedure -- Startup procedure
function onLoad(saved_data) function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1] markedBoxes = loaded_data[1]
log(loaded_data[2]) log(loaded_data[2])
for _, skill in ipairs(loaded_data[2]) do for _, skill in ipairs(loaded_data[2]) do
if (skill ~= "") then if (skill ~= "") then
log("Skill from load "..skill) log("Skill from load " .. skill)
selectedSkills[skill] = true selectedSkills[skill] = true
end end
end
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
local selectedSkills = {
willpower = false,
intellect = false,
combat = false,
agility = false
}
end end
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
local selectedSkills = {
willpower = false,
intellect = false,
combat = false,
agility = false
}
end
makeData() makeData()
createButtonsAndBoxes() createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end) self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() updateScale(1) end) self.addContextMenuItem("Scale: normal", function() updateScale(1) end)
self.addContextMenuItem("Scale: double", function() updateScale(2) end) self.addContextMenuItem("Scale: double", function() updateScale(2) end)
self.addContextMenuItem("Scale: triple", function() updateScale(3) end) self.addContextMenuItem("Scale: triple", function() updateScale(3) end)
updateSkillDisplay() updateSkillDisplay()
end end
function updateScale(scale) function updateScale(scale)
@ -98,61 +93,61 @@ function updateScale(scale)
end end
function updateState(markedBoxesNew) function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData() makeData()
createButtonsAndBoxes() createButtonsAndBoxes()
updateSkillDisplay() updateSkillDisplay()
end end
-- create Data -- create Data
function makeData() function makeData()
Data = {} Data = {}
Data.checkbox = {} Data.checkbox = {}
Data.textbox = {} Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes -- repeat this for each entry (= line) in existingBoxes
local totalCount = 0 local totalCount = 0
for i = 1, #existingBoxes do for i = 1, #existingBoxes do
-- repeat this for each checkbox per line -- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do for j = 1, existingBoxes[i] do
totalCount = totalCount + 1 totalCount = totalCount + 1
Data.checkbox[totalCount] = {} Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {} Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i] Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true Data.checkbox[totalCount].state = true
else else
Data.checkbox[totalCount].pos.y = y_invisible Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false Data.checkbox[totalCount].state = false
end end
end
end end
end
end end
-- checks or unchecks the given box -- checks or unchecks the given box
function click_checkbox(tableIndex) function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1 markedBoxes[row] = markedBoxes[row] - 1
else else
Data.checkbox[tableIndex].pos.y = y_visible Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1 markedBoxes[row] = markedBoxes[row] + 1
end end
self.editButton({ self.editButton({
index = tableIndex - 1, index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos position = Data.checkbox[tableIndex].pos
}) })
end end
function click_willpower() function click_willpower()
@ -176,40 +171,40 @@ function click_agility()
end end
function createButtonsAndBoxes() function createButtonsAndBoxes()
self.clearButtons() self.clearButtons()
for i, box_data in ipairs(Data.checkbox) do for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end local func = function() click_checkbox(i) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function = funcName, click_function = funcName,
function_owner = self, function_owner = self,
position = box_data.pos, position = box_data.pos,
height = boxSize, height = boxSize,
width = boxSize, width = boxSize,
font_size = box_data.size, font_size = box_data.size,
scale = { 1, 1, 1 }, scale = { 1, 1, 1 },
color = { 0, 0, 0 }, color = { 0, 0, 0 },
font_color = { 0, 0, 0 } font_color = { 0, 0, 0 }
}) })
end end
makeSkillSelectionButtons() makeSkillSelectionButtons()
end end
-- Creates the invisible buttons overlaying the skill icons -- Creates the invisible buttons overlaying the skill icons
function makeSkillSelectionButtons() function makeSkillSelectionButtons()
local buttonPositions = { x = -1 * SKILL_ICON_POSITIONS.willpower.x, y = 0.2, z = SKILL_ICON_POSITIONS.willpower.z } local buttonPositions = { x = -1 * SKILL_ICON_POSITIONS.willpower.x, y = 0.2, z = SKILL_ICON_POSITIONS.willpower.z }
local buttonData = { local buttonData = {
click_function = "click_willpower", click_function = "click_willpower",
function_owner = self, function_owner = self,
position = buttonPositions, position = buttonPositions,
height = 130, height = 130,
width = 130, width = 130,
scale = { 1, 1, 1 }, scale = { 1, 1, 1 },
color = { 0, 0, 0, 0 }, color = { 0, 0, 0, 0 },
} }
self.createButton(buttonData) self.createButton(buttonData)
buttonData.click_function = "click_intellect" buttonData.click_function = "click_intellect"
@ -229,7 +224,7 @@ end
-- Refresh the vector circles indicating a skill is selected. Since we can only have one table of -- Refresh the vector circles indicating a skill is selected. Since we can only have one table of
-- vectors set, have to refresh all 4 at once -- vectors set, have to refresh all 4 at once
function updateSkillDisplay() function updateSkillDisplay()
local circles = { } local circles = {}
for skill, isSelected in pairs(selectedSkills) do for skill, isSelected in pairs(selectedSkills) do
if isSelected then if isSelected then
local circle = getCircleVector(SKILL_ICON_POSITIONS[skill]) local circle = getCircleVector(SKILL_ICON_POSITIONS[skill])
@ -258,8 +253,8 @@ function getCircleVector(center)
end end
return { return {
points = vecList, points = vecList,
color = {0.597, 0.195, 0.796}, color = { 0.597, 0.195, 0.796 },
thickness = 0.02, thickness = 0.02,
} }
end end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Makeshift Trap -- Customizable Cards: Makeshift Trap
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 39 boxSize = 39
@ -11,8 +6,6 @@ boxSize = 39
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.0735 x_offset = 0.0735
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -27,154 +20,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } existingBoxes = { 1, 1, 2, 2, 2, 3, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Pocket Multi Tool -- Customizable Cards: Pocket Multi Tool
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 40 boxSize = 40
@ -11,8 +6,6 @@ boxSize = 40
-- static values -- static values
x_1 = -0.933 x_1 = -0.933
x_offset = 0.075 x_offset = 0.075
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -27,154 +20,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } existingBoxes = { 1, 1, 2, 2, 2, 3, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Power Word -- Customizable Cards: Power Word
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 38 boxSize = 38
@ -11,8 +6,6 @@ boxSize = 38
-- static values -- static values
x_1 = -0.933 x_1 = -0.933
x_offset = 0.069 x_offset = 0.069
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,154 +21,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 2, 3, 3, 3 } existingBoxes = { 1, 1, 1, 1, 2, 3, 3, 3 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: Runic Axe -- Customizable Cards: Runic Axe
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 38 boxSize = 38
@ -11,8 +6,6 @@ boxSize = 38
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.0705 x_offset = 0.0705
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,154 +21,6 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 1, 3, 3, 4 } existingBoxes = { 1, 1, 1, 1, 1, 3, 3, 4 }
inputBoxes = {} inputBoxes = {}
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -1,276 +1,270 @@
-- Customizable Cards: Summoned Servitor -- Customizable Cards: Summoned Servitor
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons -- Color information for buttons
boxSize = 35 boxSize = 35
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.068 x_offset = 0.068
y_visible = 0.25 y_visible = 0.25
y_invisible = -0.5 y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
-0.92, -0.92,
-0.625, -0.625,
-0.33, -0.33,
0.055, 0.055,
0.26, 0.26,
0.56, 0.56,
0.765, 0.765,
1.06 1.06
} }
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 } existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 }
inputBoxes = {}
inputBoxes = {}
-- Locations of the slot selectors -- Locations of the slot selectors
local SLOT_ICON_POSITIONS = { local SLOT_ICON_POSITIONS = {
arcane = { x = 0.160, z = 0.65}, arcane = { x = 0.160, z = 0.65 },
ally = { x = -0.073, z = 0.65} ally = { x = -0.073, z = 0.65 }
} }
-- These match with ArkhamDB's way of storing the data in the dropdown menu -- These match with ArkhamDB's way of storing the data in the dropdown menu
local slotIndices = {arcane = "1", ally = "0", none = ""} local slotIndices = { arcane = "1", ally = "0", none = "" }
local selectedSlot = slotIndices.none local selectedSlot = slotIndices.none
-- override 'marked boxes' for debugging ('all' or 'none') -- override 'marked boxes' for debugging ('all' or 'none')
markDEBUG = "" markDEBUG = ""
-- save state when going into bags / decks -- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, {selectedSlot} }) end function onSave() return JSON.encode({ markedBoxes, { selectedSlot } }) end
-- Startup procedure -- Startup procedure
function onLoad(saved_data) function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data) local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1] markedBoxes = loaded_data[1]
selectedSlot = loaded_data[2][1] selectedSlot = loaded_data[2][1]
else else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
selectedSlot = "" selectedSlot = ""
end end
makeData() makeData()
createButtonsAndBoxes() createButtonsAndBoxes()
updateSlotDisplay() updateSlotDisplay()
self.addContextMenuItem("Reset Inputs", function() updateState() end) self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end) self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end) self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end) self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end end
function updateState(markedBoxesNew) function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData() makeData()
createButtonsAndBoxes() createButtonsAndBoxes()
updateSlotDisplay() updateSlotDisplay()
end end
-- create Data -- create Data
function makeData() function makeData()
Data = {} Data = {}
Data.checkbox = {} Data.checkbox = {}
Data.textbox = {} Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes -- repeat this for each entry (= line) in existingBoxes
local totalCount = 0 local totalCount = 0
for i = 1, #existingBoxes do for i = 1, #existingBoxes do
-- repeat this for each checkbox per line -- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do for j = 1, existingBoxes[i] do
totalCount = totalCount + 1 totalCount = totalCount + 1
Data.checkbox[totalCount] = {} Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {} Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i] Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true Data.checkbox[totalCount].state = true
else else
Data.checkbox[totalCount].pos.y = y_invisible Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false Data.checkbox[totalCount].state = false
end end
end
end end
end
-- repeat this for each entry (= line) in inputBoxes -- repeat this for each entry (= line) in inputBoxes
local totalCount = 0 local totalCount = 0
for i = 1, #inputBoxes do for i = 1, #inputBoxes do
-- repeat this for each textbox per line -- repeat this for each textbox per line
for j = 1, inputBoxes[i] do for j = 1, inputBoxes[i] do
totalCount = totalCount + 1 totalCount = totalCount + 1
Data.textbox[totalCount] = {} Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount] Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount] Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount] Data.textbox[totalCount].value = inputValues[totalCount]
end
end end
end
end end
-- checks or unchecks the given box -- checks or unchecks the given box
function click_checkbox(tableIndex) function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1 markedBoxes[row] = markedBoxes[row] - 1
else else
Data.checkbox[tableIndex].pos.y = y_visible Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1 markedBoxes[row] = markedBoxes[row] + 1
end end
self.editButton({ self.editButton({
index = tableIndex - 1, index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos position = Data.checkbox[tableIndex].pos
}) })
end end
-- updates saved value for given text box -- updates saved value for given text box
function click_textbox(i, value, selected) function click_textbox(i, value, selected)
if selected == false then if selected == false then
inputValues[i] = value inputValues[i] = value
end end
end end
function createButtonsAndBoxes() function createButtonsAndBoxes()
self.clearButtons() self.clearButtons()
self.clearInputs() self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end local func = function() click_checkbox(i) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createButton({ self.createButton({
click_function = funcName, click_function = funcName,
function_owner = self, function_owner = self,
position = box_data.pos, position = box_data.pos,
height = boxSize, height = boxSize,
width = boxSize, width = boxSize,
font_size = box_data.size, font_size = box_data.size,
scale = { 1, 1, 1 }, scale = { 1, 1, 1 },
color = { 0, 0, 0 }, color = { 0, 0, 0 },
font_color = { 0, 0, 0 } font_color = { 0, 0, 0 }
}) })
end end
for i, box_data in ipairs(Data.textbox) do for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func) self.setVar(funcName, func)
self.createInput({ self.createInput({
input_function = funcName, input_function = funcName,
function_owner = self, function_owner = self,
label = "Click to type", label = "Click to type",
alignment = 2, alignment = 2,
position = box_data.pos, position = box_data.pos,
scale = buttonScale, scale = buttonScale,
width = box_data.width, width = box_data.width,
height = (inputFontsize * 1) + 24, height = (inputFontsize * 1) + 24,
font_size = inputFontsize, font_size = inputFontsize,
color = "White", color = "White",
font_color = buttonFontColor, font_color = buttonFontColor,
value = box_data.value value = box_data.value
}) })
end end
makeSlotSelectionButtons() makeSlotSelectionButtons()
end end
-- Creates the invisible buttons overlaying the slot words -- Creates the invisible buttons overlaying the slot words
function makeSlotSelectionButtons() function makeSlotSelectionButtons()
local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z } local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z }
local buttonData = { local buttonData = {
click_function = "click_arcane", click_function = "click_arcane",
function_owner = self, function_owner = self,
position = buttonPositions, position = buttonPositions,
height = 130, height = 130,
width = 130, width = 130,
scale = { 1, 1, 1 }, scale = { 1, 1, 1 },
color = { 0, 0, 0, 0 }, color = { 0, 0, 0, 0 },
} }
self.createButton(buttonData) self.createButton(buttonData)
buttonData.click_function = "click_ally" buttonData.click_function = "click_ally"
buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x
buttonData.position = buttonPositions buttonData.position = buttonPositions
self.createButton(buttonData) self.createButton(buttonData)
end end
function click_arcane() function click_arcane()
if selectedSlot == slotIndices.arcane then if selectedSlot == slotIndices.arcane then
selectedSlot = slotIndices.none selectedSlot = slotIndices.none
else else
selectedSlot = slotIndices.arcane selectedSlot = slotIndices.arcane
end end
updateSlotDisplay() updateSlotDisplay()
end end
function click_ally() function click_ally()
if selectedSlot == slotIndices.ally then if selectedSlot == slotIndices.ally then
selectedSlot = slotIndices.none selectedSlot = slotIndices.none
else else
selectedSlot = slotIndices.ally selectedSlot = slotIndices.ally
end end
updateSlotDisplay() updateSlotDisplay()
end end
-- Refresh the vector circles indicating a slot is selected. -- Refresh the vector circles indicating a slot is selected.
function updateSlotDisplay() function updateSlotDisplay()
local box = {} local box = {}
local center = {} local center = {}
center = SLOT_ICON_POSITIONS["arcane"] center = SLOT_ICON_POSITIONS["arcane"]
local arcaneVecList = { local arcaneVecList = {
Vector(center.x + 0.12, 0.3, center.z + 0.05), Vector(center.x + 0.12, 0.3, center.z + 0.05),
Vector(center.x - 0.12, 0.3, center.z + 0.05), Vector(center.x - 0.12, 0.3, center.z + 0.05),
Vector(center.x - 0.12, 0.3, center.z - 0.05), Vector(center.x - 0.12, 0.3, center.z - 0.05),
Vector(center.x + 0.12, 0.3, center.z - 0.05), Vector(center.x + 0.12, 0.3, center.z - 0.05),
Vector(center.x + 0.12, 0.3, center.z + 0.05), Vector(center.x + 0.12, 0.3, center.z + 0.05),
} }
center = SLOT_ICON_POSITIONS["ally"] center = SLOT_ICON_POSITIONS["ally"]
local allyVecList = { local allyVecList = {
Vector(center.x + 0.07, 0.3, center.z + 0.05), Vector(center.x + 0.07, 0.3, center.z + 0.05),
Vector(center.x - 0.07, 0.3, center.z + 0.05), Vector(center.x - 0.07, 0.3, center.z + 0.05),
Vector(center.x - 0.07, 0.3, center.z - 0.05), Vector(center.x - 0.07, 0.3, center.z - 0.05),
Vector(center.x + 0.07, 0.3, center.z - 0.05), Vector(center.x + 0.07, 0.3, center.z - 0.05),
Vector(center.x + 0.07, 0.3, center.z + 0.05), Vector(center.x + 0.07, 0.3, center.z + 0.05),
} }
local arcaneVecColor = {0.5, 0.5, 0.5, 0.75} local arcaneVecColor = { 0.5, 0.5, 0.5, 0.75 }
local allyVecColor = {0.5, 0.5, 0.5, 0.75} local allyVecColor = { 0.5, 0.5, 0.5, 0.75 }
if selectedSlot == slotIndices.arcane then if selectedSlot == slotIndices.arcane then
arcaneVecColor = {0.597, 0.195, 0.796} arcaneVecColor = { 0.597, 0.195, 0.796 }
elseif selectedSlot == slotIndices.ally then elseif selectedSlot == slotIndices.ally then
allyVecColor = {0.597, 0.195, 0.796} allyVecColor = { 0.597, 0.195, 0.796 }
end end
self.setVectorLines({ self.setVectorLines({
{ {
points = arcaneVecList, points = arcaneVecList,
color = arcaneVecColor, color = arcaneVecColor,
thickness = 0.02, thickness = 0.02,
}, },
{ {
points = allyVecList, points = allyVecList,
color = allyVecColor, color = allyVecColor,
thickness = 0.02, thickness = 0.02,
}, },
}) })
end end

View File

@ -1,9 +1,4 @@
-- Customizable Cards: The Raven Quill -- Customizable Cards: The Raven Quill
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons and input boxes -- Color information for buttons and input boxes
boxSize = 37 boxSize = 37
@ -12,8 +7,6 @@ inputFontsize = 38
-- static values -- static values
x_1 = -0.935 x_1 = -0.935
x_offset = 0.0705 x_offset = 0.0705
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet) -- z-values (lines on the sheet)
posZ = { posZ = {
@ -28,156 +21,8 @@ posZ = {
-- box setup (amount of boxes per line and amount of marked boxes in that line) -- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 2, 2, 2, 3, 4 } existingBoxes = { 1, 1, 2, 2, 2, 3, 4 }
inputBoxes = { 1, 1 } inputBoxes = { 1, 1 }
inputWidth = { 425, 775 } inputWidth = { 425, 775 }
inputPos = { { 0.5, 0.25, -0.905 }, { 0.125, 0.25, 0 } } inputPos = { { 0.5, 0.25, -0.905 }, { 0.125, 0.25, 0 } }
-- override 'marked boxes' for debugging ('all' or 'none') require("playercards/customizable/UpgradeSheetLibrary")
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState() end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end

View File

@ -0,0 +1,173 @@
--[[ EXAMPLE CONFIGURATION
-- Color information for buttons
boxSize = 40
-- static values
x_1 = -0.933
x_offset = 0.075
-- z-values (lines on the sheet)
posZ = {
-0.892,
-0.665,
-0.430,
-0.092,
0.142,
0.376,
0.815
}
-- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 2, 4, 5 }
inputBoxes = {}]]
-- static values
y_visible = 0.25
y_invisible = -0.5
-- override 'marked boxes' for debugging ('all' or 'none')
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
function onSave() return JSON.encode({ markedBoxes, inputValues }) end
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
inputValues = loaded_data[2]
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
inputValues = { "", "", "", "", "" }
end
makeData()
createButtonsAndBoxes()
self.addContextMenuItem("Reset Inputs", function() updateState({ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }) end)
self.addContextMenuItem("Scale: normal", function() self.setScale({ 1, 1, 1 }) end)
self.addContextMenuItem("Scale: double", function() self.setScale({ 2, 1, 2 }) end)
self.addContextMenuItem("Scale: triple", function() self.setScale({ 3, 1, 3 }) end)
end
function updateState(markedBoxesNew)
if markedBoxesNew then markedBoxes = markedBoxesNew end
makeData()
createButtonsAndBoxes()
end
-- create Data
function makeData()
Data = {}
Data.checkbox = {}
Data.textbox = {}
-- repeat this for each entry (= line) in existingBoxes
local totalCount = 0
for i = 1, #existingBoxes do
-- repeat this for each checkbox per line
for j = 1, existingBoxes[i] do
totalCount = totalCount + 1
Data.checkbox[totalCount] = {}
Data.checkbox[totalCount].pos = {}
Data.checkbox[totalCount].pos.x = x_1 + j * x_offset
Data.checkbox[totalCount].pos.z = posZ[i]
Data.checkbox[totalCount].row = i
if (markDEBUG == "all") or (markedBoxes[i] >= j and markDEBUG ~= "none") then
Data.checkbox[totalCount].pos.y = y_visible
Data.checkbox[totalCount].state = true
else
Data.checkbox[totalCount].pos.y = y_invisible
Data.checkbox[totalCount].state = false
end
end
end
-- repeat this for each entry (= line) in inputBoxes
local totalCount = 0
for i = 1, #inputBoxes do
-- repeat this for each textbox per line
for j = 1, inputBoxes[i] do
totalCount = totalCount + 1
Data.textbox[totalCount] = {}
Data.textbox[totalCount].pos = inputPos[totalCount]
Data.textbox[totalCount].width = inputWidth[totalCount]
Data.textbox[totalCount].value = inputValues[totalCount]
end
end
end
-- checks or unchecks the given box
function click_checkbox(tableIndex)
local row = Data.checkbox[tableIndex].row
if Data.checkbox[tableIndex].state == true then
Data.checkbox[tableIndex].pos.y = y_invisible
Data.checkbox[tableIndex].state = false
markedBoxes[row] = markedBoxes[row] - 1
else
Data.checkbox[tableIndex].pos.y = y_visible
Data.checkbox[tableIndex].state = true
markedBoxes[row] = markedBoxes[row] + 1
end
self.editButton({
index = tableIndex - 1,
position = Data.checkbox[tableIndex].pos
})
end
-- updates saved value for given text box
function click_textbox(i, value, selected)
if selected == false then
inputValues[i] = value
end
end
function createButtonsAndBoxes()
self.clearButtons()
self.clearInputs()
for i, box_data in ipairs(Data.checkbox) do
local funcName = "checkbox" .. i
local func = function() click_checkbox(i) end
self.setVar(funcName, func)
self.createButton({
click_function = funcName,
function_owner = self,
position = box_data.pos,
height = boxSize,
width = boxSize,
font_size = box_data.size,
scale = { 1, 1, 1 },
color = { 0, 0, 0 },
font_color = { 0, 0, 0 }
})
end
for i, box_data in ipairs(Data.textbox) do
local funcName = "textbox" .. i
local func = function(_, _, val, sel) click_textbox(i, val, sel) end
self.setVar(funcName, func)
self.createInput({
input_function = funcName,
function_owner = self,
label = "Click to type",
alignment = 2,
position = box_data.pos,
scale = buttonScale,
width = box_data.width,
height = (inputFontsize * 1) + 24,
font_size = inputFontsize,
color = "White",
font_color = buttonFontColor,
value = box_data.value
})
end
end