ah_sce_unpacked/unpacked/Custom_Token Playmat Image Swapper b7b45b.ttslua

151 lines
4.2 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)
__bundle_register("core/PlayAreaSelector", function(require, _LOADED, __bundle_register, __bundle_modules)
2023-01-29 19:31:52 -05:00
local controlActive = false
local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/"
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)
2023-01-29 19:31:52 -05:00
updateSurface(isRightClick and "" or self.getInputs()[1].value)
2022-10-19 19:07:47 -04:00
end
-- input function for the input box
function none() end
-- main function (can be called by other objects)
function updateSurface(newURL)
2022-12-13 14:02:30 -05:00
local playArea = getObjectFromGUID("721ba2")
local customInfo = playArea.getCustomObject()
2022-10-19 19:07:47 -04:00
2023-01-29 19:31:52 -05:00
if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then
2022-10-19 19:07:47 -04:00
customInfo.image = newURL
broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 })
else
2023-01-29 19:31:52 -05:00
customInfo.image = DEFAULT_URL
2022-10-19 19:07:47 -04:00
broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 })
end
2022-12-13 14:02:30 -05:00
playArea.setCustomObject(customInfo)
2023-01-29 19:31:52 -05:00
-- 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
2022-12-13 14:02:30 -05:00
playArea = playArea.reload()
if guid ~= nil then
Wait.time(function() playArea.call("updateLocations", { guid }) end, 1)
end
2022-10-19 19:07:47 -04:00
end
-- 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)
2023-04-22 16:56:01 -04:00
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("core/PlayAreaSelector")
end)
2022-12-13 14:02:30 -05:00
return __bundle_require("__root")