visual update

This commit is contained in:
Chr1Z93 2022-11-30 12:11:07 +01:00
parent 7c3af7de31
commit b829edd340
3 changed files with 74 additions and 62 deletions

View File

@ -10,14 +10,19 @@
"g": 1,
"r": 1
},
"CustomUIAssets": [
{
"Name": "down-arrow",
"Type": 0,
"URL": "http://cloud-3.steamusercontent.com/ugc/1849291925327196037/A32E84E24065356A759D8676A90FF698A05FE691/"
}
],
"Description": "a2f932",
"CustomImage": {
"CustomToken": {
"MergeDistancePixels": 15,
"Stackable": false,
"StandUp": false,
"Thickness": 0.2
},
"ImageScalar": 1,
"ImageSecondaryURL": "",
"ImageURL": "http://cloud-3.steamusercontent.com/ugc/1915746489209870095/5F6A6F2946DBEB81667C15B112F9E35943E61A97/",
"WidthScale": 0
},
"Description": "Moves all objects on the playmat in the chosen direction.",
"DragSelectable": true,
"GMNotes": "",
"GUID": "0f1374",
@ -31,22 +36,25 @@
"LuaScriptState": "",
"LuaScript_path": "Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.ttslua",
"MeasureMovement": false,
"Name": "Checker_white",
"Name": "Custom_Token",
"Nickname": "Displacement Tool",
"Snap": true,
"Sticky": true,
"Tags": [
"displacement_excluded"
],
"Tooltip": true,
"Transform": {
"posX": 29.557,
"posY": 4.094,
"posZ": -21.437,
"posX": 31.478,
"posY": 4.204,
"posZ": -20.335,
"rotX": 0,
"rotY": 270,
"rotZ": 0,
"scaleX": 1,
"scaleX": 1.5,
"scaleY": 1,
"scaleZ": 1
"scaleZ": 1.5
},
"Value": 0,
"XmlUI_path": "Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.xml"
"XmlUI": ""
}

View File

@ -1,12 +1,4 @@
---
--- Generated by Luanalysis
--- Created by Whimsical.
--- DateTime: 2022-01-21 1:39 p.m.
---
function onload()
self:getRotation(Vector(0, 270, 0))
end
local zone = getObjectFromGUID("a2f932")
local excluded = {
["b7b45b"] = true,
@ -14,49 +6,65 @@ local excluded = {
["721ba2"] = true
}
---@type table<string, table<string, any>>
local OFFSETS = {
left = {
axis = "z",
offset = 7.67
},
right = {
axis = "z",
offset = -7.67
},
up = {
axis = "x",
offset = 6.54
},
down = {
axis = "x",
offset = -6.54
}
left = { x = 0.00, y = 0, z = 7.67 },
right = { x = 0.00, y = 0, z = -7.67 },
up = { x = 6.54, y = 0, z = 0.00 },
down = { x = -6.54, y = 0, z = 0.00 }
}
---@param player Player
---@param direction string
function shift(player, direction)
if self:getDescription()=="" then
player:broadcast("The description of the displacement tool must contain (only) the GUID for a scripting zone that contains the play field.", Color.RED)
return
end
local UI_offset = 1.15
local zone = getObjectFromGUID(self:getDescription())
local offset = OFFSETS[direction]
local buttonParamaters = {}
buttonParamaters.function_owner = self
buttonParamaters.label = ""
buttonParamaters.height = 500
buttonParamaters.width = 500
buttonParamaters.color = { 0, 0, 0, 0 }
function onLoad()
-- index 0: left
buttonParamaters.click_function = "shift_left"
buttonParamaters.tooltip = "Move left"
buttonParamaters.position = { -UI_offset, 0, 0 }
self.createButton(buttonParamaters)
-- index 1: right
buttonParamaters.click_function = "shift_right"
buttonParamaters.tooltip = "Move right"
buttonParamaters.position = { UI_offset, 0, 0 }
self.createButton(buttonParamaters)
-- index 2: up
buttonParamaters.click_function = "shift_up"
buttonParamaters.tooltip = "Move up"
buttonParamaters.position = { 0, 0, -UI_offset }
self.createButton(buttonParamaters)
-- index 3: down
buttonParamaters.click_function = "shift_down"
buttonParamaters.tooltip = "Move down"
buttonParamaters.position = { 0, 0, UI_offset }
self.createButton(buttonParamaters)
end
function shift_left(color) shift(color, "left") end
function shift_right(color) shift(color, "right") end
function shift_up(color) shift(color, "up") end
function shift_down(color) shift(color, "down") end
function shift(color, direction)
if not zone then
player:broadcast("The description of the displacement tool either contains text that is not a GUID or contains a GUID for a scripting zone that does not exist.", Color.RED)
broadcastToColor("Scripting zone couldn't be found.", color, "Red")
return
end
local adjustment = Vector(0, 0, 0)
adjustment[offset.axis] = offset.offset
---@param object TTSObject
for _, object in ipairs(zone:getObjects()) do
if not (excluded[object:getGUID():lower()] or object:hasTag("displacement_excluded")) then
object:translate(adjustment)
for _, object in ipairs(zone.getObjects()) do
if not (excluded[object.getGUID()] or object.hasTag("displacement_excluded")) then
object.translate(OFFSETS[direction])
end
end
end

View File

@ -1,4 +0,0 @@
<Button onClick="shift(up)" icon="down-arrow" width="100" height="100" color="#FFFFFF" position="0 -150 -10" />
<Button onClick="shift(down)" icon="down-arrow" width="100" height="100" color="#FFFFFF" position="0 150 -10" rotation="0 0 180"/>
<Button onClick="shift(left)" icon="down-arrow" width="100" height="100" color="#FFFFFF" position="150 0 -10" rotation="0 0 90" />
<Button onClick="shift(right)" icon="down-arrow" width="100" height="100" color="#FFFFFF" position="-150 0 -10" rotation="0 0 270" />