Merge pull request #159 from argonui/image-swapper

Playarea image swapper: Update position, remove personal information
This commit is contained in:
Chr1Z 2023-01-06 10:13:53 +01:00 committed by GitHub
commit 89e71a93f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 39 deletions

View File

@ -22,7 +22,7 @@
"ImageURL": "https://i.imgur.com/gs1mtXJ.png", "ImageURL": "https://i.imgur.com/gs1mtXJ.png",
"WidthScale": 0 "WidthScale": 0
}, },
"Description": "Allows changing of the playmat image. Provide URL to the image or leave empty for default image.\n\nSee context menu for additional information.", "Description": "Allows changing of the playmat image. Provide URL to the image or leave empty for default image.",
"DragSelectable": true, "DragSelectable": true,
"GMNotes": "", "GMNotes": "",
"GUID": "b7b45b", "GUID": "b7b45b",
@ -34,7 +34,7 @@
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScript": "require(\"core/PlayAreaSelector\")", "LuaScript": "require(\"core/PlayAreaSelector\")",
"LuaScriptState": "{\"cd\":{\"move\":false,\"scale\":false},\"tid\":[]}", "LuaScriptState": "",
"MeasureMovement": false, "MeasureMovement": false,
"Name": "Custom_Token", "Name": "Custom_Token",
"Nickname": "Playmat Image Swapper", "Nickname": "Playmat Image Swapper",
@ -42,9 +42,9 @@
"Sticky": true, "Sticky": true,
"Tooltip": true, "Tooltip": true,
"Transform": { "Transform": {
"posX": -10.358, "posX": -10.36,
"posY": 1.675, "posY": 1.5,
"posZ": 17.063, "posZ": 17.06,
"rotX": 0, "rotX": 0,
"rotY": 270, "rotY": 270,
"rotZ": 0, "rotZ": 0,

View File

@ -1,32 +1,16 @@
-- Playmat Image Swapper local controlActive = false
-- updated by: Chr1Z local DEFAULT_URL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/"
-- original by: -
-- description: changes the big playmats image
information = {
version = "1.2",
last_updated = "12.11.2022"
}
defaultURL = "http://cloud-3.steamusercontent.com/ugc/998015670465071049/FFAE162920D67CF38045EFBD3B85AD0F916147B2/"
-- parameters for open/close button for reusing -- parameters for open/close button for reusing
local BUTTON_PARAMETERS = {} local buttonParameters = {}
BUTTON_PARAMETERS.function_owner = self buttonParameters.function_owner = self
BUTTON_PARAMETERS.click_function = "click_toggleControl" buttonParameters.click_function = "click_toggleControl"
BUTTON_PARAMETERS.height = 1500 buttonParameters.height = 1500
BUTTON_PARAMETERS.width = 1500 buttonParameters.width = 1500
BUTTON_PARAMETERS.color = { 1, 1, 1, 0 } buttonParameters.color = { 1, 1, 1, 0 }
function onLoad() function onLoad()
controlActive = false
createOpenCloseButton() 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 end
-- click function for main button -- click function for main button
@ -78,11 +62,7 @@ end
-- click function for apply button -- click function for apply button
function click_applySurface(_, _, isRightClick) function click_applySurface(_, _, isRightClick)
if isRightClick then updateSurface(isRightClick and "" or self.getInputs()[1].value)
updateSurface()
else
updateSurface(self.getInputs()[1].value)
end
end end
-- input function for the input box -- input function for the input box
@ -93,17 +73,17 @@ function updateSurface(newURL)
local playArea = getObjectFromGUID("721ba2") local playArea = getObjectFromGUID("721ba2")
local customInfo = playArea.getCustomObject() local customInfo = playArea.getCustomObject()
if newURL ~= "" and newURL ~= nil and newURL ~= defaultURL then if newURL ~= "" and newURL ~= nil and newURL ~= DEFAULT_URL then
customInfo.image = newURL customInfo.image = newURL
broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 }) broadcastToAll("New Playmat Image Applied", { 0.2, 0.9, 0.2 })
else else
customInfo.image = defaultURL customInfo.image = DEFAULT_URL
broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 }) broadcastToAll("Default Playmat Image Applied", { 0.2, 0.9, 0.2 })
end end
playArea.setCustomObject(customInfo) playArea.setCustomObject(customInfo)
-- get custom data helper and call it after reloading -- get custom data helper and call the playarea with it after reloading
local guid = playArea.getVar("customDataHelper") local guid = playArea.getVar("customDataHelper")
playArea = playArea.reload() playArea = playArea.reload()
@ -114,6 +94,6 @@ end
-- creates the main button -- creates the main button
function createOpenCloseButton() function createOpenCloseButton()
BUTTON_PARAMETERS.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel" buttonParameters.tooltip = (controlActive and "Close" or "Open") .. " Playmat Panel"
self.createButton(BUTTON_PARAMETERS) self.createButton(buttonParameters)
end end