-
Notifications
You must be signed in to change notification settings - Fork 1
/
object.lua
41 lines (35 loc) · 1.37 KB
/
object.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
-- SPDX-License-Identifier: AGPL-3.0-only
-- Copyright © 2023 Corp Por LTD
Object = {}
--- Gets or sets an object immovability
-- @param object GameObj
-- @param newImmovable boolean (optional)
-- @return if newImmovable is not provided, will return true if object is immovable, false otherwise
function Object.Immovable(object, newImmovable)
if ( newImmovable ~= nil ) then
object:SetSharedObjectPropert("Immovable", newImmovable)
else
return object:GetSharedObjectProperty("Immovable")
end
end
--- Set an object to decay after a specific timespan (or default decay timespan)
-- @param object GameObj
-- @param timespan TimeSpan (optional) will default to server setting default decay time
function Object.Decay(object, timespan)
if ( not object or not object:IsValid() ) then
LuaDebugCallStack("[Object.Decay] Invalid object provided.")
return
end
timespan = timespan or ServerSettings.Interaction.DefaultDecayTime
object:ScheduleDecay(timespan)
end
--- Get an object's template (preferred as the template id is cached in lua memory)
-- @param object - gameObject
local _templateIdCache = {}
function Object.Template(object)
if ( object == nil ) then return nil end
if ( _templateIdCache[object] == nil ) then
_templateIdCache[object] = object:GetCreationTemplateId()
end
return _templateIdCache[object]
end