ah_sce_unpacked/unpacked/Bag All Player Cards 15bb07/CardCustom Summoned Servitor Upgrade Sheet 5397a6.ttslua

325 lines
9.5 KiB
Plaintext
Raw Normal View History

2023-04-22 16:56:01 -04:00
-- Bundled by luabundle {"version":"1.6.0"}
local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)
local loadingPlaceholder = {[{}] = true}
local register
local modules = {}
local require
local loaded = {}
register = function(name, body)
if not modules[name] then
modules[name] = body
end
end
require = function(name)
local loadedModule = loaded[name]
if loadedModule then
if loadedModule == loadingPlaceholder then
return nil
end
else
if not modules[name] then
if not superRequire then
local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
error('Tried to require ' .. identifier .. ', but no such module has been registered')
else
return superRequire(name)
end
end
loaded[name] = loadingPlaceholder
loadedModule = modules[name](require, loaded, register, modules)
loaded[name] = loadedModule
end
return loadedModule
end
return require, loaded, register, modules
end)(nil)
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("playercards/customizable/SummonedServitorUpgradeSheet")
end)
__bundle_register("playercards/customizable/SummonedServitorUpgradeSheet", function(require, _LOADED, __bundle_register, __bundle_modules)
2022-10-19 19:07:47 -04:00
-- Customizable Cards: Summoned Servitor
-- by Chr1Z
information = {
version = "1.7",
last_updated = "12.10.2022"
}
-- Color information for buttons
boxSize = 35
-- static values
x_1 = -0.935
x_offset = 0.068
y_visible = 0.25
y_invisible = -0.5
-- z-values (lines on the sheet)
posZ = {
-0.92,
-0.625,
-0.33,
0.055,
0.26,
0.56,
0.765,
1.06
}
-- box setup (amount of boxes per line and amount of marked boxes in that line)
existingBoxes = { 1, 1, 1, 1, 1, 2, 3, 5 }
inputBoxes = {}
2023-04-22 16:56:01 -04:00
-- Locations of the slot selectors
local SLOT_ICON_POSITIONS = {
arcane = { x = 0.160, z = 0.65},
ally = { x = -0.073, z = 0.65}
}
-- These match with ArkhamDB's way of storing the data in the dropdown menu
local slotIndices = {arcane = "1", ally = "0", none = ""}
local selectedSlot = slotIndices.none
2022-10-19 19:07:47 -04:00
-- override 'marked boxes' for debugging ('all' or 'none')
markDEBUG = ""
-- save state when going into bags / decks
function onDestroy() self.script_state = onSave() end
2023-04-22 16:56:01 -04:00
function onSave() return JSON.encode({ markedBoxes, {selectedSlot} }) end
2022-10-19 19:07:47 -04:00
-- Startup procedure
function onLoad(saved_data)
if saved_data ~= "" and markDEBUG == "" then
local loaded_data = JSON.decode(saved_data)
markedBoxes = loaded_data[1]
2023-04-22 16:56:01 -04:00
selectedSlot = loaded_data[2][1]
2022-10-19 19:07:47 -04:00
else
markedBoxes = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
2023-04-22 16:56:01 -04:00
selectedSlot = ""
2022-10-19 19:07:47 -04:00
end
makeData()
createButtonsAndBoxes()
2023-04-22 16:56:01 -04:00
updateSlotDisplay()
2022-10-19 19:07:47 -04:00
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()
2023-04-22 16:56:01 -04:00
updateSlotDisplay()
2022-10-19 19:07:47 -04:00
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
2023-04-22 16:56:01 -04:00
makeSlotSelectionButtons()
end
-- Creates the invisible buttons overlaying the slot words
function makeSlotSelectionButtons()
local buttonPositions = { x = -1 * SLOT_ICON_POSITIONS.arcane.x, y = 0.2, z = SLOT_ICON_POSITIONS.arcane.z }
local buttonData = {
click_function = "click_arcane",
function_owner = self,
position = buttonPositions,
height = 130,
width = 130,
scale = { 1, 1, 1 },
color = { 0, 0, 0, 0 },
}
self.createButton(buttonData)
buttonData.click_function = "click_ally"
buttonPositions.x = -1 * SLOT_ICON_POSITIONS.ally.x
buttonData.position = buttonPositions
self.createButton(buttonData)
end
function click_arcane()
if selectedSlot == slotIndices.arcane then
selectedSlot = slotIndices.none
else
selectedSlot = slotIndices.arcane
end
updateSlotDisplay()
end
function click_ally()
if selectedSlot == slotIndices.ally then
selectedSlot = slotIndices.none
else
selectedSlot = slotIndices.ally
end
updateSlotDisplay()
end
-- Refresh the vector circles indicating a slot is selected.
function updateSlotDisplay()
local box = {}
local center = {}
center = SLOT_ICON_POSITIONS["arcane"]
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),
}
center = SLOT_ICON_POSITIONS["ally"]
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),
}
local arcaneVecColor = {0.5, 0.5, 0.5, 0.75}
local allyVecColor = {0.5, 0.5, 0.5, 0.75}
if selectedSlot == slotIndices.arcane then
arcaneVecColor = {0.597, 0.195, 0.796}
elseif selectedSlot == slotIndices.ally then
allyVecColor = {0.597, 0.195, 0.796}
end
self.setVectorLines({
{
points = arcaneVecList,
color = arcaneVecColor,
thickness = 0.02,
},
{
points = allyVecList,
color = allyVecColor,
thickness = 0.02,
},
})
end
end)
return __bundle_require("__root")