195 lines
5.3 KiB
Plaintext
195 lines
5.3 KiB
Plaintext
-- 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)
|
|
-- Additional Victory Point Card
|
|
local victoryDisplayApi = require("core/VictoryDisplayApi")
|
|
|
|
local MIN_VALUE = -10
|
|
local MAX_VALUE = 99
|
|
local vp, notes
|
|
|
|
function onSave()
|
|
return JSON.encode({ vp = vp, notes = notes })
|
|
end
|
|
|
|
function onLoad(savedData)
|
|
if savedData and savedData ~= "" then
|
|
local loadedData = JSON.decode(savedData)
|
|
vp = loadedData.vp
|
|
notes = loadedData.notes
|
|
else
|
|
vp = 1
|
|
notes = "Click to type"
|
|
end
|
|
|
|
createButtons()
|
|
createTextbox()
|
|
end
|
|
|
|
function createButtons()
|
|
self.createButton({
|
|
label = tostring(vp),
|
|
click_function = "click_function",
|
|
function_owner = self,
|
|
position = { 0, 1, -0.05 },
|
|
height = 600,
|
|
width = 1000,
|
|
font_size = 1000,
|
|
font_color = { 0, 0, 0, 100 },
|
|
color = { 0, 0, 0, 0 },
|
|
scale = { 0.25, 0.25, 0.25 }
|
|
})
|
|
end
|
|
|
|
function createTextbox()
|
|
self.createInput({
|
|
input_function = "input_function",
|
|
function_owner = self,
|
|
label = "Click to type",
|
|
value = notes,
|
|
alignment = 2,
|
|
position = { x = 0, y = 1, z = 0.825 },
|
|
width = 4250,
|
|
height = 2250,
|
|
font_size = 360,
|
|
scale = { 0.2, 0.2, 0.2 }
|
|
})
|
|
end
|
|
|
|
function updateNotes()
|
|
local md = JSON.decode(self.getGMNotes())
|
|
md.victory = vp
|
|
self.setGMNotes(JSON.encode(md))
|
|
victoryDisplayApi.update()
|
|
end
|
|
|
|
function updateSave()
|
|
self.script_state = JSON.encode({ vp = vp, notes = notes })
|
|
end
|
|
|
|
function input_function(_, _, inputValue, selected)
|
|
if selected == false then
|
|
notes = inputValue
|
|
updateSave()
|
|
end
|
|
end
|
|
|
|
function click_function(_, _, isRightClick)
|
|
vp = math.min(math.max(vp + (isRightClick and -1 or 1), MIN_VALUE), MAX_VALUE)
|
|
self.editButton({ index = 0, label = tostring(vp) })
|
|
updateSave()
|
|
updateNotes()
|
|
end
|
|
end)
|
|
__bundle_register("core/GUIDReferenceApi", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
do
|
|
local GUIDReferenceApi = {}
|
|
|
|
local function getGuidHandler()
|
|
return getObjectFromGUID("123456")
|
|
end
|
|
|
|
---@param owner string Parent object for this search
|
|
---@param type string Type of object to search for
|
|
---@return any: Object reference to the matching object
|
|
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
|
|
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
|
|
end
|
|
|
|
-- returns all matching objects as a table with references
|
|
---@param type string Type of object to search for
|
|
---@return table: List of object references to matching objects
|
|
GUIDReferenceApi.getObjectsByType = function(type)
|
|
return getGuidHandler().call("getObjectsByType", type)
|
|
end
|
|
|
|
-- returns all matching objects as a table with references
|
|
---@param owner string Parent object for this search
|
|
---@return table: List of object references to matching objects
|
|
GUIDReferenceApi.getObjectsByOwner = function(owner)
|
|
return getGuidHandler().call("getObjectsByOwner", owner)
|
|
end
|
|
|
|
-- sends new information to the reference handler to edit the main index
|
|
---@param owner string Parent of the object
|
|
---@param type string Type of the object
|
|
---@param guid string GUID of the object
|
|
GUIDReferenceApi.editIndex = function(owner, type, guid)
|
|
return getGuidHandler().call("editIndex", {
|
|
owner = owner,
|
|
type = type,
|
|
guid = guid
|
|
})
|
|
end
|
|
|
|
return GUIDReferenceApi
|
|
end
|
|
end)
|
|
__bundle_register("core/VictoryDisplayApi", function(require, _LOADED, __bundle_register, __bundle_modules)
|
|
do
|
|
local VictoryDisplayApi = {}
|
|
local guidReferenceApi = require("core/GUIDReferenceApi")
|
|
|
|
local function getVictoryDisplay()
|
|
return guidReferenceApi.getObjectByOwnerAndType("Mythos", "VictoryDisplay")
|
|
end
|
|
|
|
-- triggers an update of the victory count
|
|
---@param delay? number Delay in seconds after which the update call is executed
|
|
VictoryDisplayApi.update = function(delay)
|
|
getVictoryDisplay().call("startUpdate", delay)
|
|
end
|
|
|
|
-- moves a card to the victory display (in the first empty spot)
|
|
---@param object tts__Object Object that should be checked and potentially moved
|
|
VictoryDisplayApi.placeCard = function(object)
|
|
if object ~= nil and object.tag == "Card" then
|
|
getVictoryDisplay().call("placeCard", object)
|
|
end
|
|
end
|
|
|
|
return VictoryDisplayApi
|
|
end
|
|
end)
|
|
return __bundle_require("__root") |