72 lines
1.7 KiB
Plaintext
72 lines
1.7 KiB
Plaintext
---
|
|
--- Generated by EmmyLua(https://github.com/EmmyLua)
|
|
--- Created by Whimsical.
|
|
--- DateTime: 2021-02-02 9:41 a.m.
|
|
---
|
|
|
|
local zone = nil
|
|
|
|
-- Forward Declaration
|
|
---@param is_enabled boolean
|
|
local setMenu = function(is_enabled) end
|
|
|
|
local function enable()
|
|
if self.held_by_color~=nil then return end
|
|
local position = self:getPosition()
|
|
local rotation = self:getRotation()
|
|
local scale = self:getScale()
|
|
|
|
zone = spawnObject {
|
|
type = "ScriptingTrigger",
|
|
position = Vector(position.x, position.y+25+(bit32.rshift(scale.y, 1))+0.41, position.z),
|
|
rotation = rotation,
|
|
scale = Vector(scale.x*2, 50, scale.z*2),
|
|
sound = true,
|
|
snap_to_grid = true
|
|
}
|
|
|
|
setMenu(false)
|
|
end
|
|
|
|
local function disable()
|
|
if zone~=nil then zone:destruct() end
|
|
setMenu(true)
|
|
end
|
|
|
|
---@param is_enabled boolean
|
|
setMenu = function(is_enabled)
|
|
self:clearContextMenu()
|
|
if is_enabled then
|
|
self:addContextMenuItem("Enable", enable, false)
|
|
else
|
|
self:addContextMenuItem("Disable", disable, false)
|
|
end
|
|
end
|
|
|
|
function onLoad(save_state)
|
|
if save_state=="" then return end
|
|
local data = JSON.decode(save_state)
|
|
zone = getObjectFromGUID(data.zone)
|
|
setMenu(zone==nil)
|
|
end
|
|
|
|
function onSave()
|
|
return JSON.encode {
|
|
zone = zone and zone:getGUID() or nil
|
|
}
|
|
end
|
|
|
|
---@param entering TTSObject
|
|
---@param object TTSObject
|
|
function onObjectEnterScriptingZone(entering , object)
|
|
if zone~=entering then return end
|
|
if object==self then return end
|
|
if object.type=="Deck" or object.type=="Card" then return end
|
|
|
|
object:destruct()
|
|
end
|
|
|
|
---@param color string
|
|
function onPickUp(color)
|
|
disable()
|
|
end |