SCED/objects/Fan-MadeAccessories.aa8b38/DisplacementTool.0f1374.ttslua
2022-11-30 12:11:07 +01:00

71 lines
1.9 KiB
Plaintext

local zone = getObjectFromGUID("a2f932")
local excluded = {
["b7b45b"] = true,
["f182ee"] = true,
["721ba2"] = true
}
local OFFSETS = {
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 }
}
local UI_offset = 1.15
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
broadcastToColor("Scripting zone couldn't be found.", color, "Red")
return
end
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