added token script
This commit is contained in:
parent
e8cc95a4a7
commit
150e0e18d3
@ -89,62 +89,62 @@
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429879/3DE13BD6A88637B0D114B38A18F3F997AA553820/"
|
||||
},
|
||||
{
|
||||
"Name": "GuardianBackground",
|
||||
"Name": "GuardianClass",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020428504/D7D156CC5F34BD9DE51E71ADFCBA8BDE76358214/"
|
||||
},
|
||||
{
|
||||
"Name": "MysticBackground",
|
||||
"Name": "MysticClass",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020428733/BBF06C692394B48DFEEF8EF92D01083ABD24600D/"
|
||||
},
|
||||
{
|
||||
"Name": "NeutralBackground",
|
||||
"Name": "NeutralClass",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020428918/898E79CD6752EE225ED8563EBCFFC09FF4566EE2/"
|
||||
},
|
||||
{
|
||||
"Name": "RogueBackground",
|
||||
"Name": "RogueClass",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429368/FA66064F7B6E7E065087874AA7CA97A513F6D389/"
|
||||
},
|
||||
{
|
||||
"Name": "SeekerBackground",
|
||||
"Name": "SeekerClass",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429521/AD325698441CBAAB1A03B079B04768BC5CBDD321/"
|
||||
},
|
||||
{
|
||||
"Name": "SurvivorBackground",
|
||||
"Name": "SurvivorClass",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429727/D71F981259EE9C3077FABE361DF988E05AA96F30/"
|
||||
},
|
||||
{
|
||||
"Name": "GuardianClass",
|
||||
"Name": "Guardian",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020428585/3FF56E20DCD01D276BD57507B07FB549072F0877/"
|
||||
},
|
||||
{
|
||||
"Name": "MysticClass",
|
||||
"Name": "Mystic",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020428836/BA2851382E66D08D0DEC95D9FD4A42CF042FDA3C/"
|
||||
},
|
||||
{
|
||||
"Name": "NeutralClass",
|
||||
"Name": "Neutral",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020428998/824B0AD8AB710A86409846EA2C13DCCAF4333545/"
|
||||
},
|
||||
{
|
||||
"Name": "RogueClass",
|
||||
"Name": "Rogue",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429445/5C0508B898F8A6EB955EE0802C0827384D624885/"
|
||||
},
|
||||
{
|
||||
"Name": "SeekerClass",
|
||||
"Name": "Seeker",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429590/E6FCB23DBF28E7183C7325AFA4452D1AF9F3018D/"
|
||||
},
|
||||
{
|
||||
"Name": "SurvivorClass",
|
||||
"Name": "Survivor",
|
||||
"Type": 0,
|
||||
"URL": "http://cloud-3.steamusercontent.com/ugc/2447222612020429809/A993F31CDD4D2A3E4D4BCD796375FA262A1204D5/"
|
||||
}
|
||||
@ -160,7 +160,7 @@
|
||||
"IgnoreFoW": false,
|
||||
"LayoutGroupSortIndex": 0,
|
||||
"Locked": false,
|
||||
"LuaScript": "",
|
||||
"LuaScript": "require(\"core/UniversalActionAbilityToken\")",
|
||||
"LuaScriptState": "",
|
||||
"MeasureMovement": false,
|
||||
"Name": "Custom_Tile",
|
||||
|
165
src/core/UniversalActionAbilityToken.ttslua
Normal file
165
src/core/UniversalActionAbilityToken.ttslua
Normal file
@ -0,0 +1,165 @@
|
||||
local class, symbol
|
||||
|
||||
local listOfClasses = {
|
||||
"Guardian",
|
||||
"Mystic",
|
||||
"Neutral",
|
||||
"Rogue",
|
||||
"Seeker",
|
||||
"Survivor"
|
||||
}
|
||||
|
||||
local listOfSymbols = {
|
||||
"Activate",
|
||||
"Evade",
|
||||
"Explore",
|
||||
"Fight",
|
||||
"FreeTrigger",
|
||||
"Investigate",
|
||||
"Parley",
|
||||
"PlayItem",
|
||||
"Reaction",
|
||||
"Resource",
|
||||
"Spell",
|
||||
"Tome",
|
||||
"Guardian",
|
||||
"Mystic",
|
||||
"Neutral",
|
||||
"Rogue",
|
||||
"Seeker",
|
||||
"Survivor"
|
||||
}
|
||||
|
||||
|
||||
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()
|
||||
end
|
||||
|
||||
function updateDisplay()
|
||||
local xml = {
|
||||
-- background on the front
|
||||
{
|
||||
tag = "Image",
|
||||
attributes = {
|
||||
id = "ClassFront",
|
||||
image = class .. "Class",
|
||||
height = "200",
|
||||
width = "200",
|
||||
position = "0 0 0.1",
|
||||
rotation = "0 180 180"
|
||||
}
|
||||
},
|
||||
-- circular border on the front
|
||||
{
|
||||
tag = "Image",
|
||||
attributes = {
|
||||
image = "Border",
|
||||
height = "200",
|
||||
width = "200",
|
||||
position = "0 0 0.2",
|
||||
rotation = "0 180 180"
|
||||
}
|
||||
},
|
||||
-- symbol on the front
|
||||
{
|
||||
tag = "Image",
|
||||
attributes = {
|
||||
id = "SymbolFront",
|
||||
image = symbol,
|
||||
height = "200",
|
||||
width = "200",
|
||||
position = "0 0 0.3",
|
||||
rotation = "0 180 180"
|
||||
}
|
||||
},
|
||||
-- background on the back
|
||||
{
|
||||
tag = "Image",
|
||||
attributes = {
|
||||
id = "ClassBack",
|
||||
image = "NeutralClass",
|
||||
height = "200",
|
||||
width = "200",
|
||||
position = "0 0 -10.1",
|
||||
rotation = "0 0 180"
|
||||
}
|
||||
},
|
||||
-- circular border on the back
|
||||
{
|
||||
tag = "Image",
|
||||
attributes = {
|
||||
image = "Border",
|
||||
height = "200",
|
||||
width = "200",
|
||||
position = "0 0 -10.2",
|
||||
rotation = "0 0 180"
|
||||
}
|
||||
},
|
||||
-- symbol on the back
|
||||
{
|
||||
tag = "Image",
|
||||
attributes = {
|
||||
id = "SymbolBack",
|
||||
image = symbol,
|
||||
-- update color of symbol on the back for neutral
|
||||
color = (class == "Neutral") and "#000000" or "#FFFFFF",
|
||||
height = "200",
|
||||
width = "200",
|
||||
position = "0 0 -10.3",
|
||||
rotation = "0 0 180"
|
||||
}
|
||||
}
|
||||
}
|
||||
self.UI.setXmlTable(xml)
|
||||
|
||||
-- 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
|
||||
end
|
||||
|
||||
function addContextMenu()
|
||||
self.addContextMenuItem("Change class", function(playerColor)
|
||||
Player[playerColor].showOptionsDialog("Choose class", listOfClasses, class, updateClass)
|
||||
end)
|
||||
|
||||
self.addContextMenuItem("Change symbol", function(playerColor)
|
||||
Player[playerColor].showOptionsDialog("Choose symbol", listOfSymbols, symbol, updateSymbol)
|
||||
end)
|
||||
end
|
||||
|
||||
function updateClass(newClass)
|
||||
class = newClass
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
function updateSymbol(newSymbol)
|
||||
symbol = newSymbol
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
function updateClassAndSymbol(newClass, newSymbol)
|
||||
class = newClass
|
||||
symbol = newSymbol
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
function isClassName(str)
|
||||
for _, className in ipairs(listOfClasses) do
|
||||
if className == str then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
Loading…
Reference in New Issue
Block a user