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",
"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,
"GMNotes": "",
"GUID": "b7b45b",
@ -34,7 +34,7 @@
"LayoutGroupSortIndex": 0,
"Locked": true,
"LuaScript": "require(\"core/PlayAreaSelector\")",
"LuaScriptState": "{\"cd\":{\"move\":false,\"scale\":false},\"tid\":[]}",
"LuaScriptState": "",
"MeasureMovement": false,
"Name": "Custom_Token",
"Nickname": "Playmat Image Swapper",
@ -42,9 +42,9 @@
"Sticky": true,
"Tooltip": true,
"Transform": {
"posX": -10.358,
"posY": 1.675,
"posZ": 17.063,
"posX": -10.36,
"posY": 1.5,
"posZ": 17.06,
"rotX": 0,
"rotY": 270,
"rotZ": 0,

View File

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