Files
simple-makes-complex/mods/SYSTEM/HelperLib/src/Lib/getObjectByGUID.lua

17 lines
596 B
Lua

---Returns an active object by unique identifier (GUID).
---* For players, this is a player name.
---* For Lua entities, this is a uniquely generated string, guaranteed not to collide with player names.
---
---**Note**: If an object with such an identifier does not exist or is inactive, the value `nil` will be returned.
---@param guid string only use printable ASCII characters. Example: `@bGh3p2AbRE29Mb4biqX6OA`.
---@return ObjectRef|Player|Entity|nil
function Smc.getObjectByGUID(guid)
local obj = core.objects_by_guid[guid]
if obj == nil then
return
else
return obj
end
end