ah_sce_unpacked/unpacked/Custom_Tile Neutral 42ec66.ttslua

369 lines
8.9 KiB
Plaintext
Raw Normal View History

2024-07-27 21:47:52 -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("core/UniversalActionAbilityToken")
end)
__bundle_register("core/UniversalActionAbilityToken", function(require, _LOADED, __bundle_register, __bundle_modules)
local class, symbol
local listOfClasses = {
"Guardian",
"Mystic",
"Neutral",
"Rogue",
"Seeker",
"Survivor"
}
local listOfClassDisplayNames = {
"Blue (Guardian)",
"Purple (Mystic)",
"Grey (Neutral)",
"Green (Rogue)",
"Orange (Seeker)",
"Red (Survivor)"
}
local listOfSymbols = {
"Activate",
"Engage",
"Evade",
"Explore",
"Fight",
"FreeTrigger",
"Investigate",
"Move",
"None",
"Parley",
"PlayItem",
"Reaction",
"Resource",
"Scan",
"Spell",
"Tome",
"Guardian",
"Mystic",
"Neutral",
"Rogue",
"Seeker",
"Survivor"
}
local colorsForClasses = {
Guardian = Color.new(19 / 255, 84 / 255, 165 / 255),
Mystic = Color.new(82 / 255, 18 / 255, 97 / 255),
Neutral = Color.new(108 / 255, 110 / 255, 112 / 255),
Rogue = Color.new(17 / 255, 72 / 255, 54 / 255),
Seeker = Color.new(215 / 255, 115 / 255, 35 / 255),
Survivor = Color.new(190 / 255, 30 / 255, 45 / 255)
}
function onSave()
return JSON.encode({ class = class, symbol = symbol })
end
function onLoad(savedData)
local loadedData = JSON.decode(savedData) or {}
class = loadedData.class or "Neutral"
symbol = loadedData.symbol or "Neutral"
updateDisplay()
addContextMenu()
-- get random seed from Global so all are different
math.randomseed(Global.call("getRandomSeed"))
end
function updateDisplay()
local xml = {
-- background on the front
{
tag = "Image",
attributes = {
image = "Bundle/" .. class .. "Background",
height = "200",
width = "200",
position = "0 0 -10.1",
rotation = "0 0 180"
}
},
-- ring on the front
{
tag = "Image",
attributes = {
image = "Bundle/Ring",
height = "200",
width = "200",
position = "0 0 -10.2",
rotation = "0 0 180"
}
},
-- symbol on the front
{
tag = "Image",
attributes = {
image = "Bundle/" .. symbol,
height = "200",
width = "200",
position = "0 0 -10.3",
rotation = "0 0 180"
}
},
-- background on the back
{
tag = "Image",
attributes = {
image = "Bundle/NeutralBackground",
height = "000",
width = "200",
position = "0 0 0.1",
rotation = "0 180 180"
}
},
-- ring on the back
{
tag = "Image",
attributes = {
image = "Bundle/Ring",
color = "#000000",
height = "200",
width = "200",
position = "0 0 0.2",
rotation = "0 180 180"
}
},
-- symbol on the back
{
tag = "Image",
attributes = {
image = "Bundle/" .. symbol,
color = "#000000",
height = "200",
width = "200",
position = "0 0 0.3",
rotation = "0 180 180"
}
}
}
-- handling for double symbols
if string.contains(symbol, "/") then
local symbols = {}
for str in string.gmatch(symbol, "([^/]+)") do
table.insert(symbols, str)
end
-- update front image
xml[3].attributes.image = "Bundle/" .. symbols[1]
xml[3].attributes.height = xml[3].attributes.height * 0.55
xml[3].attributes.width = xml[3].attributes.width * 0.55
xml[3].attributes.position = "35 0 -10.3"
-- add 2nd image element to front
local frontSymbolXml = deepcopy(xml[3])
frontSymbolXml.attributes.image = "Bundle/" .. symbols[2]
frontSymbolXml.attributes.position = "-35 0 -10.3"
table.insert(xml, frontSymbolXml)
-- update back image
xml[6].attributes.image = "Bundle/" .. symbols[1]
xml[6].attributes.height = xml[6].attributes.height * 0.55
xml[6].attributes.width = xml[6].attributes.width * 0.55
xml[6].attributes.position = "35 0 0.3"
-- add 2nd image element to back
local backSymbolXml = deepcopy(xml[6])
backSymbolXml.attributes.image = "Bundle/" .. symbols[2]
backSymbolXml.attributes.position = "-35 0 0.3"
table.insert(xml, backSymbolXml)
end
self.UI.setXmlTable(xml)
-- set color tint
self.setColorTint(colorsForClasses[class])
-- update name (only show symbol name if it isn't the class name)
if isClassName(symbol) then
self.setName(class)
else
self.setName(class .. " " .. symbol)
end
-- update scale
if symbol == "FreeTrigger" or symbol == "Reaction" then
self.setScale({ 0.35, 1, 0.35 })
else
self.setScale({ 0.45, 1, 0.45 })
end
end
function getSymbolList()
local symbolList = {}
for str in string.gmatch(symbol, "([^/]+)") do
table.insert(symbolList, str)
end
return symbolList
end
function addContextMenu()
self.addContextMenuItem("Change color", function(playerColor)
Player[playerColor].clearSelectedObjects()
local currentClassDisplayName = listOfClassDisplayNames[getIndexOfValue(listOfClasses, class)]
Player[playerColor].showOptionsDialog("Choose color", listOfClassDisplayNames, currentClassDisplayName,
function(_, selectedIndex)
updateClass(listOfClasses[selectedIndex])
end)
end)
self.addContextMenuItem("Change 1st symbol", function(playerColor)
Player[playerColor].clearSelectedObjects()
local symbolList = getSymbolList()
Player[playerColor].showOptionsDialog("Choose symbol", listOfSymbols, symbolList[1], function(newSymbol)
if newSymbol == "None" then
if symbolList[2] then
updateSymbol(symbolList[2])
else
printToColor("Need to have at least one symbol.", playerColor)
end
else
if symbolList[2] then
updateSymbol(newSymbol .. "/" .. symbolList[2])
else
updateSymbol(newSymbol)
end
end
end)
end)
self.addContextMenuItem("Change 2nd symbol", function(playerColor)
Player[playerColor].clearSelectedObjects()
local symbolList = getSymbolList()
Player[playerColor].showOptionsDialog("Choose 2nd symbol", listOfSymbols, symbolList[2] or symbolList[1],
function(newSymbol)
if newSymbol == "None" then
updateSymbol(symbolList[1])
else
updateSymbol(symbolList[1] .. "/" .. newSymbol)
end
end)
end)
end
function updateClass(newClass)
-- also update the symbol if it matches the class
if class == symbol then
symbol = newClass or "Neutral"
end
class = newClass or "Neutral"
updateDisplay()
end
function updateSymbol(newSymbol)
symbol = newSymbol or class
if symbol == "Universal" then
symbol = class
end
updateDisplay()
end
function updateClassAndSymbol(params)
class = params.class or "Neutral"
symbol = params.symbol or class
if symbol == "Universal" then
symbol = class
end
updateDisplay()
end
function isClassName(str)
for _, className in ipairs(listOfClasses) do
if className == str then
return true
end
end
return false
end
function onRandomize()
local newSymbol = listOfSymbols[math.random(1, #listOfSymbols)]
while newSymbol == "None" do
newSymbol = listOfSymbols[math.random(1, #listOfSymbols)]
end
-- if the new symbol is a class symbol, don't get a random class
if isClassName(newSymbol) then
updateClassAndSymbol({ class = newSymbol, symbol = newSymbol })
else
updateClassAndSymbol({ class = listOfClasses[math.random(1, #listOfClasses)], symbol = newSymbol })
end
end
function getIndexOfValue(t, value)
for i, v in ipairs(t) do
if v == value then
return i
end
end
return nil
end
function deepcopy(orig)
local copy
if type(orig) == 'table' then
copy = {}
for orig_key, orig_value in next, orig, nil do
copy[deepcopy(orig_key)] = deepcopy(orig_value)
end
setmetatable(copy, deepcopy(getmetatable(orig)))
else -- number, string, boolean, etc
copy = orig
end
return copy
end
end)
return __bundle_require("__root")