ah_sce_unpacked/unpacked/Custom_Token Playmat Image Swapper b7b45b.ttslua

237 lines
7.9 KiB
Plaintext
Raw Normal View History

2022-12-13 14:02:30 -05: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)
2024-01-06 21:32:07 -05:00
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("core/PlayAreaSelector")
end)
2022-12-13 14:02:30 -05:00
__bundle_register("core/PlayAreaSelector", function(require, _LOADED, __bundle_register, __bundle_modules)
2024-01-06 21:32:07 -05:00
local playAreaApi = require("core/PlayAreaApi")
2023-01-29 19:31:52 -05:00
local controlActive = false
2022-10-19 19:07:47 -04:00
-- parameters for open/close button for reusing
2023-01-29 19:31:52 -05:00
local buttonParameters = {}
buttonParameters.function_owner = self
buttonParameters.click_function = "click_toggleControl"
buttonParameters.height = 1500
buttonParameters.width = 1500
buttonParameters.color = { 1, 1, 1, 0 }
2022-10-19 19:07:47 -04:00
2022-12-13 14:02:30 -05:00
function onLoad()
2022-10-19 19:07:47 -04:00
createOpenCloseButton()
end
-- click function for main button
function click_toggleControl()
self.clearButtons()
self.clearInputs()
controlActive = not controlActive
createOpenCloseButton()
if not controlActive then return end
-- creates the label, input box and apply button
self.createButton({
function_owner = self,
label = "Playmat Image Swapper",
tooltip = "",
click_function = "none",
position = { 0, 0.15, 2.2 },
height = 0,
width = 0,
font_size = 300,
font_color = { 1, 1, 1 }
})
self.createInput({
function_owner = self,
label = "URL",
tooltip = "Enter URL for playmat image",
input_function = "none",
alignment = 3,
position = { 0, 0.15, 3 },
height = 323,
width = 4000,
font_size = 300
})
self.createButton({
function_owner = self,
label = "Apply Image\nTo Playmat",
tooltip = "Left-Click: Apply URL\nRight-Click: Reset to default image",
click_function = "click_applySurface",
position = { 0, 0.15, 4.1 },
height = 460,
width = 1400,
font_size = 200
})
end
-- click function for apply button
function click_applySurface(_, _, isRightClick)
2024-01-06 21:32:07 -05:00
playAreaApi.updateSurface(isRightClick and "" or self.getInputs()[1].value)
2022-10-19 19:07:47 -04:00
end
function updateSurface(newURL)
2024-01-06 21:32:07 -05:00
playAreaApi.updateSurface(newURL)
2022-10-19 19:07:47 -04:00
end
2024-01-06 21:32:07 -05:00
-- input function for the input box
function none() end
2022-10-19 19:07:47 -04:00
-- creates the main button
function createOpenCloseButton()
2023-01-29 19:31:52 -05:00
buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel"
self.createButton(buttonParameters)
2022-10-19 19:07:47 -04:00
end
2022-12-13 14:02:30 -05:00
end)
2024-01-06 21:32:07 -05:00
__bundle_register("core/PlayAreaApi", function(require, _LOADED, __bundle_register, __bundle_modules)
do
local PlayAreaApi = { }
local PLAY_AREA_GUID = "721ba2"
local INVESTIGATOR_COUNTER_GUID = "f182ee"
-- Returns the current value of the investigator counter from the playmat
---@return Integer. Number of investigators currently set on the counter
PlayAreaApi.getInvestigatorCount = function()
return getObjectFromGUID(INVESTIGATOR_COUNTER_GUID).getVar("val")
end
-- Updates the current value of the investigator counter from the playmat
---@param count Number of investigators to set on the counter
PlayAreaApi.setInvestigatorCount = function(count)
return getObjectFromGUID(INVESTIGATOR_COUNTER_GUID).call("updateVal", count)
end
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
-- fixed objects will be ignored, as will anything the player has tagged with
-- 'displacement_excluded'
---@param playerColor Color of the player requesting the shift. Used solely to send an error
--- message in the unlikely case that the scripting zone has been deleted
PlayAreaApi.shiftContentsUp = function(playerColor)
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsUp", playerColor)
end
PlayAreaApi.shiftContentsDown = function(playerColor)
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsDown", playerColor)
end
PlayAreaApi.shiftContentsLeft = function(playerColor)
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsLeft", playerColor)
end
PlayAreaApi.shiftContentsRight = function(playerColor)
return getObjectFromGUID(PLAY_AREA_GUID).call("shiftContentsRight", playerColor)
end
-- Reset the play area's tracking of which cards have had tokens spawned.
PlayAreaApi.resetSpawnedCards = function()
return getObjectFromGUID(PLAY_AREA_GUID).call("resetSpawnedCards")
end
-- Event to be called when the current scenario has changed.
---@param scenarioName Name of the new scenario
PlayAreaApi.onScenarioChanged = function(scenarioName)
getObjectFromGUID(PLAY_AREA_GUID).call("onScenarioChanged", scenarioName)
end
-- Sets this playmat's snap points to limit snapping to locations or not.
-- If matchTypes is false, snap points will be reset to snap all cards.
---@param matchTypes Boolean Whether snap points should only snap for the matching card types.
PlayAreaApi.setLimitSnapsByType = function(matchCardTypes)
getObjectFromGUID(PLAY_AREA_GUID).call("setLimitSnapsByType", matchCardTypes)
end
-- Receiver for the Global tryObjectEnterContainer event. Used to clear vector lines from dragged
-- cards before they're destroyed by entering the container
PlayAreaApi.tryObjectEnterContainer = function(container, object)
getObjectFromGUID(PLAY_AREA_GUID).call("tryObjectEnterContainer",
{ container = container, object = object })
end
-- counts the VP on locations in the play area
PlayAreaApi.countVP = function()
return getObjectFromGUID(PLAY_AREA_GUID).call("countVP")
end
-- highlights all locations in the play area without metadata
---@param state Boolean True if highlighting should be enabled
PlayAreaApi.highlightMissingData = function(state)
return getObjectFromGUID(PLAY_AREA_GUID).call("highlightMissingData", state)
end
-- highlights all locations in the play area with VP
---@param state Boolean True if highlighting should be enabled
PlayAreaApi.highlightCountedVP = function(state)
return getObjectFromGUID(PLAY_AREA_GUID).call("highlightCountedVP", state)
end
-- Checks if an object is in the play area (returns true or false)
PlayAreaApi.isInPlayArea = function(object)
return getObjectFromGUID(PLAY_AREA_GUID).call("isInPlayArea", object)
end
PlayAreaApi.getSurface = function()
return getObjectFromGUID(PLAY_AREA_GUID).getCustomObject().image
end
PlayAreaApi.updateSurface = function(url)
return getObjectFromGUID(PLAY_AREA_GUID).call("updateSurface", url)
end
-- Called by Custom Data Helpers to push their location data into the Data Helper. This adds the
-- data to the local token manager instance.
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
PlayAreaApi.updateLocations = function(args)
getObjectFromGUID(PLAY_AREA_GUID).call("updateLocations", args)
end
PlayAreaApi.getCustomDataHelper = function()
return getObjectFromGUID(PLAY_AREA_GUID).getVar("customDataHelper")
end
return PlayAreaApi
end
2023-04-22 16:56:01 -04:00
end)
2022-12-13 14:02:30 -05:00
return __bundle_require("__root")