ah_sce_unpacked/unpacked/Custom_Model_Bag Fan-Made Accessories aa8b38/Custom_Tile PlayermatHider a758b2.ttslua
2024-01-06 21:32:29 -05:00

120 lines
3.5 KiB
Plaintext

-- Bundled by luabundle {"version":"1.6.0"}
local __bundle_require, __bundle_loaded, __bundle_register, __bundle_modules = (function(superRequire)
local loadingPlaceholder = {[{}] = true}
local register
local modules = {}
local require
local loaded = {}
register = function(name, body)
if not modules[name] then
modules[name] = body
end
end
require = function(name)
local loadedModule = loaded[name]
if loadedModule then
if loadedModule == loadingPlaceholder then
return nil
end
else
if not modules[name] then
if not superRequire then
local identifier = type(name) == 'string' and '\"' .. name .. '\"' or tostring(name)
error('Tried to require ' .. identifier .. ', but no such module has been registered')
else
return superRequire(name)
end
end
loaded[name] = loadingPlaceholder
loadedModule = modules[name](require, loaded, register, modules)
loaded[name] = loadedModule
end
return loadedModule
end
return require, loaded, register, modules
end)(nil)
__bundle_register("__root", function(require, _LOADED, __bundle_register, __bundle_modules)
require("accessories/PlayermatHider")
end)
__bundle_register("accessories/PlayermatHider", function(require, _LOADED, __bundle_register, __bundle_modules)
local guidReferenceApi = require("core/GUIDReferenceApi")
local objects
function onClick_hideShow(player, matColor)
objects = guidReferenceApi.getObjectsByOwner(matColor)
local actionTokens = searchMat(objects.Playermat.positionToWorld({-1.1, 0.05, -0.27}), {4, 1, 1}, isActionToken)
local pos = objects.Playermat.getPosition()
local mod = (pos.y > 0) and -2 or 2
-- move all objects
for _, obj in pairs(objects) do
obj.setPosition(obj.getPosition() + Vector(0, mod, 0))
end
-- move action tokens
for _, obj in ipairs(actionTokens) do
obj.setLock(pos.y > 0)
obj.setPosition(obj.getPosition() + Vector(0, mod, 0))
end
end
function isActionToken(x) return x.getDescription() == 'Action Token' end
function searchMat(origin, size, filter)
local searchResult = Physics.cast({
origin = origin,
direction = { 0, 1, 0 },
orientation = objects.Playermat.getRotation(),
type = 3,
size = size,
max_distance = 0
})
local objList = {}
for _, v in ipairs(searchResult) do
if not filter or (filter and filter(v.hit_object)) then
table.insert(objList, v.hit_object)
end
end
return objList
end
end)
__bundle_register("core/GUIDReferenceApi", function(require, _LOADED, __bundle_register, __bundle_modules)
do
local GUIDReferenceApi = {}
local function getGuidHandler()
return getObjectFromGUID("123456")
end
-- returns all matching objects as a table with references
---@param owner String Parent object for this search
---@param type String Type of object to search for
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
end
-- returns all matching objects as a table with references
---@param type String Type of object to search for
GUIDReferenceApi.getObjectsByType = function(type)
return getGuidHandler().call("getObjectsByType", type)
end
-- returns all matching objects as a table with references
---@param owner String Parent object for this search
GUIDReferenceApi.getObjectsByOwner = function(owner)
return getGuidHandler().call("getObjectsByOwner", owner)
end
return GUIDReferenceApi
end
end)
return __bundle_require("__root")