ah_sce_unpacked/unpacked/Custom_Token Playmat Image Swapper b7b45b.ttslua
2023-01-29 19:31:52 -05:00

151 lines
4.2 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)
require("core/PlayAreaSelector")
end)
__bundle_register("core/PlayAreaSelector", function(require, _LOADED, __bundle_register, __bundle_modules)
local controlActive = false
local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/"
-- parameters for open/close button for reusing
local buttonParameters = {}
buttonParameters.function_owner = self
buttonParameters.click_function = "click_toggleControl"
buttonParameters.height = 1500
buttonParameters.width = 1500
buttonParameters.color = { 1, 1, 1, 0 }
function onLoad()
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)
updateSurface(isRightClick and "" or self.getInputs()[1].value)
end
-- input function for the input box
function none() end
-- main function (can be called by other objects)
function updateSurface(newURL)
local playArea = getObjectFromGUID("721ba2")
local customInfo = playArea.getCustomObject()
if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then
customInfo.image = newURL
broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 })
else
customInfo.image = DEFAULT_URL
broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 })
end
playArea.setCustomObject(customInfo)
-- get custom data helper and call the playarea with it after reloading
local customDataHelper = playArea.getVar("customDataHelper")
local guid
if customDataHelper then guid = customDataHelper.getGUID() end
playArea = playArea.reload()
if guid ~= nil then
Wait.time(function() playArea.call("updateLocations", { guid }) end, 1)
end
end
-- creates the main button
function createOpenCloseButton()
buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel"
self.createButton(buttonParameters)
end
end)
return __bundle_require("__root")