initial commit

This commit is contained in:
Chr1Z93 2023-04-20 09:09:45 +02:00
parent ecfd765806
commit 18e0ba8275
3 changed files with 88 additions and 201 deletions

View File

@ -18,11 +18,11 @@
"Type": 2
},
"ImageScalar": 1,
"ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/933819604050849524/797528309EFBAC7485283048AAB9DA68B8A31891/",
"ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/933819604050849085/9E22AFD7B0157140FC177DBCCBCB1D61D6A0329F/",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/933819604050849085/9E22AFD7B0157140FC177DBCCBCB1D61D6A0329F/",
"WidthScale": 0
},
"Description": "",
"Description": "Use contextmenu option to enable broadcasting phase changes.\nLeft-click: Next phase\nRight-click: Previous phase",
"DragSelectable": true,
"GMNotes": "",
"GUID": "d0c8fa",
@ -33,169 +33,7 @@
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScriptState": "",
"LuaScript_path": "PhaseTracker.d0c8fa.ttslua",
"MeasureMovement": false,
"Name": "Custom_Tile",
"Nickname": "Phase Tracker",
"Snap": true,
"States": {
"2": {
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 0.0009864086,
"g": 0.1132373,
"r": 0.0414623022
},
"CustomImage": {
"CustomTile": {
"Stackable": false,
"Stretch": true,
"Thickness": 0.2,
"Type": 2
},
"ImageScalar": 1,
"ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/933819604050886219/5987AB68E0D2609CC3831F1311E9070D7189FBA8/",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/933819604050885611/845B5AA915F30492B5F34864698B9C3627FA5763/",
"WidthScale": 0
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "807ed5",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "function onLoad()\n -- Add a button to the object\n local params = {}\n params.click_function = 'toPhaseThree'\n params.function_owner = self\n params.tooltip = ''\n params.width = 600\n params.height = 600\n self.createButton(params)\nend\n\nfunction toPhaseThree()\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n tracker.setState(3)\n end\nend",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Tile",
"Nickname": "Phase Tracker",
"Snap": true,
"Sticky": true,
"Tags": [
"LinkedPhaseTracker"
],
"Tooltip": true,
"Transform": {
"posX": -11.3,
"posY": 1.52,
"posZ": -16,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 1.5,
"scaleY": 1,
"scaleZ": 1.5
},
"Value": 0,
"XmlUI": ""
},
"3": {
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 0,
"g": 0,
"r": 0.235188574
},
"CustomImage": {
"CustomTile": {
"Stackable": false,
"Stretch": true,
"Thickness": 0.2,
"Type": 2
},
"ImageScalar": 1,
"ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/982233321870235526/32D11CE67CBFB6E1197E540F9CA08F871A500C85/",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/982233321870235122/492996D07ABF6DDA4B605A3013C4892839DCF1F3/",
"WidthScale": 0
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "b4983b",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "function onLoad()\n -- Add a button to the object\n local params = {}\n params.click_function = 'toPhaseFour'\n params.function_owner = self\n params.tooltip = ''\n params.width = 600\n params.height = 600\n self.createButton(params)\nend\n\nfunction toPhaseFour()\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n tracker.setState(4)\n end\nend",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Tile",
"Nickname": "Phase Tracker",
"Snap": true,
"Sticky": true,
"Tags": [
"LinkedPhaseTracker"
],
"Tooltip": true,
"Transform": {
"posX": -11.3,
"posY": 1.52,
"posZ": -16,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 1.5,
"scaleY": 1,
"scaleZ": 1.5
},
"Value": 0,
"XmlUI": ""
},
"4": {
"AltLookAngle": {
"x": 0,
"y": 0,
"z": 0
},
"Autoraise": true,
"ColorDiffuse": {
"b": 0,
"g": 0.3496273,
"r": 0.5313587
},
"CustomImage": {
"CustomTile": {
"Stackable": false,
"Stretch": true,
"Thickness": 0.2,
"Type": 2
},
"ImageScalar": 1,
"ImageSecondaryURL": "http://cloud-3.steamusercontent.com/ugc/982233321870237827/81374325F650673C37C89E4E2A1DC25F1C97FED8/",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/982233321870237261/C287CAED2423970F33E72D6C7415CBEC6794C533/",
"WidthScale": 0
},
"Description": "",
"DragSelectable": true,
"GMNotes": "",
"GUID": "d8a337",
"Grid": true,
"GridProjection": false,
"Hands": false,
"HideWhenFaceDown": false,
"IgnoreFoW": false,
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "function onLoad()\n -- Add a button to the object\n local params = {}\n params.click_function = 'toPhaseOne'\n params.function_owner = self\n params.tooltip = ''\n params.width = 600\n params.height = 600\n self.createButton(params)\nend\n\nfunction toPhaseOne()\n for _, tracker in ipairs(getObjectsWithTag(\"LinkedPhaseTracker\")) do\n tracker.setState(1)\n end\nend",
"LuaScript": "require(\"accessories/PhaseTracker\")",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Tile",
@ -220,23 +58,3 @@
"Value": 0,
"XmlUI": ""
}
},
"Sticky": true,
"Tags": [
"LinkedPhaseTracker"
],
"Tooltip": true,
"Transform": {
"posX": -11.3,
"posY": 1.52,
"posZ": -16,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 1.5,
"scaleY": 1,
"scaleZ": 1.5
},
"Value": 0,
"XmlUI": ""
}

View File

@ -1,16 +0,0 @@
function onLoad()
-- Add a button to the object
local params = {}
params.click_function = 'toPhaseTwo'
params.function_owner = self
params.tooltip = ''
params.width = 600
params.height = 600
self.createButton(params)
end
function toPhaseTwo()
for _, tracker in ipairs(getObjectsWithTag("LinkedPhaseTracker")) do
tracker.setState(2)
end
end

View File

@ -0,0 +1,85 @@
local phaseNames = {
"I. Mythos Phase",
"II. Investigation Phase",
"III. Enemy Phase",
"IV. Upkeep Phase"
}
local phaseImages = {
"http://cloud-3.steamusercontent.com/ugc/933819604050849085/9E22AFD7B0157140FC177DBCCBCB1D61D6A0329F/",
"http://cloud-3.steamusercontent.com/ugc/933819604050885611/845B5AA915F30492B5F34864698B9C3627FA5763/",
"http://cloud-3.steamusercontent.com/ugc/982233321870235122/492996D07ABF6DDA4B605A3013C4892839DCF1F3/",
"http://cloud-3.steamusercontent.com/ugc/982233321870237261/C287CAED2423970F33E72D6C7415CBEC6794C533/"
}
function onSave()
return JSON.encode({
phaseId = phaseId,
broadcastChange = broadcastChange
})
end
function onLoad(savedData)
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData)
phaseId = loadedData.phaseId
broadcastChange = loadedData.broadcastChange
else
phaseId = 1
broadcastChange = false
end
self.createButton(
{
tooltip = "change phase",
click_function = 'changeState',
function_owner = self,
width = 600,
height = 600
})
self.addContextMenuItem("toggle broadcasting", updateBroadcast)
end
function updateBroadcast()
for _, tracker in ipairs(getObjectsWithTag("LinkedPhaseTracker")) do
tracker.setVar("broadcastChange", not broadcastChange)
end
broadcastToAll("Broadcasting phase changes has been " .. (broadcastChange and "enabled." or "disabled."))
end
function changeState(_, _, isRightClick)
-- get newId for all trackers
local newId = phaseId + (isRightClick and -1 or 1)
if newId == 0 then
newId = 4
elseif newId == 5 then
newId = 1
end
-- broadcast if option is enabled
if broadcastChange then
broadcastToAll(phaseNames[newId])
end
-- manipulate data and then respawn
local data = self.getData()
data["CustomImage"]["ImageURL"] = phaseImages[newId]
data["CustomImage"]["ImageSecondaryURL"] = phaseImages[newId]
data["LuaScriptState"] = "{\"broadcastChange\":" .. tostring(broadcastChange) .. ",\"phaseId\":" .. newId .. "}"
-- update all trackers with tag
for _, tracker in ipairs(getObjectsWithTag("LinkedPhaseTracker")) do
local pos = tracker.getPosition()
local rot = tracker.getRotation()
local scale = tracker.getScale()
tracker.destruct()
spawnObjectData(
{
data = data,
position = pos,
rotation = rot,
scale = scale
}
)
end
end