2022-07-29 21:12:54 +01:00
|
|
|
-----
|
|
|
|
--- Misc Util functions
|
|
|
|
-- @luautil Util
|
2022-04-02 17:52:39 +01:00
|
|
|
local Util = {}
|
|
|
|
|
2022-07-29 21:12:54 +01:00
|
|
|
--- Adds all built-in functions and types to the global environment.
|
|
|
|
-- Put simply, this means that you do not have to write out the full name of a function.
|
|
|
|
-- e.g. Instead of writing
|
|
|
|
-- local door = TEN.Objects.GetMoveableByName("door_type4_14")
|
|
|
|
-- You can write
|
|
|
|
-- local door = GetMoveableByName("door_type4_14")
|
2022-04-02 17:52:39 +01:00
|
|
|
Util.ShortenTENCalls = function()
|
|
|
|
local ShortenInner
|
2022-07-29 21:12:54 +01:00
|
|
|
|
2022-04-02 17:52:39 +01:00
|
|
|
ShortenInner = function(tab)
|
|
|
|
for k, v in pairs(tab) do
|
|
|
|
if _G[k] then
|
|
|
|
print("WARNING! Key " .. k .. " already exists in global environment!")
|
|
|
|
else
|
|
|
|
_G[k] = v
|
|
|
|
if "table" == type(v) then
|
|
|
|
if nil == v.__type then
|
|
|
|
ShortenInner(v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
ShortenInner(TEN)
|
|
|
|
end
|
|
|
|
|
|
|
|
return Util
|