-- Playmat Image Swapper -- updated by: Chr1Z -- original by: - -- description: changes the big playmats image information = { version = "1.1", last_updated = "10.10.2022" } defaultURL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/" -- parameters for open/close button for reusing BUTTON_PARAMETERS = {} BUTTON_PARAMETERS.function_owner = self BUTTON_PARAMETERS.click_function = "click_toggleControl" BUTTON_PARAMETERS.height = 1500 BUTTON_PARAMETERS.width = 1500 BUTTON_PARAMETERS.color = { 1, 1, 1, 0 } function onload() controlActive = false createOpenCloseButton() self.addContextMenuItem("More Information", function() printToAll("------------------------------", "White") printToAll("Playmat Image Swapper v" .. information["version"] .. " by Chr1Z", "Orange") printToAll("last updated: " .. information["last_updated"], "White") printToAll("Original made by unknown", "White") end) 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) if isRightClick then updateSurface(defaultURL) else updateSurface(self.getInputs()[1].value) end end -- input function for the input box function none() end -- main function (can be called by other objects) function updateSurface(newURL) local obj_surface = getObjectFromGUID("721ba2") local customInfo = obj_surface.getCustomObject() if newURL ~= "" and newURL ~= nil and newURL ~= defaultURL then customInfo.image = newURL broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 }) else customInfo.image = defaultURL broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 }) end obj_surface.setCustomObject(customInfo) obj_surface = obj_surface.reload() end -- creates the main button function createOpenCloseButton() if controlActive then BUTTON_PARAMETERS.tooltip = "Close Playmat Panel" else BUTTON_PARAMETERS.tooltip = "Open Playmat Panel" end self.createButton(BUTTON_PARAMETERS) end