mirror of
https://gitlab.com/hoggit/developers/hoggit.git
synced 2026-08-17 20:56:12 +00:00
Added stuff from TNN2 Hoggit Core to lib
This commit is contained in:
@@ -1 +1,5 @@
|
|||||||
|
HOGGIT = {}
|
||||||
|
dofile(lfs.writedir()..[[Scripts\HOGGIT\lib\error_handling.lua]])
|
||||||
|
dofile(lfs.writedir()..[[Scripts\HOGGIT\lib\logging.lua]])
|
||||||
|
dofile(lfs.writedir()..[[Scripts\HOGGIT\lib\utils.lua]])
|
||||||
dofile(lfs.writedir()..[[Scripts\HOGGIT\lib\spawner.lua]])
|
dofile(lfs.writedir()..[[Scripts\HOGGIT\lib\spawner.lua]])
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
HandleError = function(err)
|
||||||
|
log("Error in pcall: " .. err)
|
||||||
|
log(debug.traceback())
|
||||||
|
return err
|
||||||
|
end
|
||||||
|
|
||||||
|
try = function(func, catch)
|
||||||
|
return function()
|
||||||
|
local r, e = xpcall(func, HandleError)
|
||||||
|
if not r then
|
||||||
|
return catch(e)
|
||||||
|
end
|
||||||
|
return r
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
logFile = io.open(lfs.writedir()..[[Logs\HOGGIT.log]], "w")
|
||||||
|
|
||||||
|
function log(str)
|
||||||
|
if str == nil then str = 'nil' end
|
||||||
|
if logFile then
|
||||||
|
logFile:write("HOGGIT --- " .. str .."\r\n")
|
||||||
|
logFile:flush()
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -4,8 +4,6 @@ spawner.lua
|
|||||||
Automatically create a table of all units in the game and create a spawner for them.
|
Automatically create a table of all units in the game and create a spawner for them.
|
||||||
]]
|
]]
|
||||||
|
|
||||||
HOGGIT = {}
|
|
||||||
|
|
||||||
HOGGIT.Spawner = function(grpName)
|
HOGGIT.Spawner = function(grpName)
|
||||||
local CallBack = {}
|
local CallBack = {}
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
HOGGIT.filterTable = function(t, filter)
|
||||||
|
local out = {}
|
||||||
|
for k,v in pairs(t) do
|
||||||
|
if filter(v) then out[k] = v end
|
||||||
|
end
|
||||||
|
return out
|
||||||
|
end
|
||||||
|
|
||||||
|
HOGGIT.listContains = function(list, elem)
|
||||||
|
for _, value in ipairs(list) do
|
||||||
|
if value == elem then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return false
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user