diff --git a/maps/includes/base.lua b/maps/includes/base.lua index 5d96d75..b33f1ad 100644 --- a/maps/includes/base.lua +++ b/maps/includes/base.lua @@ -7,6 +7,7 @@ -- Do not change this file. ----------------------------------------------------------------------------- +require "util.utils" Class = require "util.class" Collection = require "util.collection" diff --git a/maps/includes/util/utils.lua b/maps/includes/util/utils.lua new file mode 100644 index 0000000..d279d6c --- /dev/null +++ b/maps/includes/util/utils.lua @@ -0,0 +1,28 @@ + +function table.clear(tbl) + for k in pairs(tbl) do + tbl[k] = nil + end +end + +function table.contains(tbl, element) + if tbl == nil then return false end + for _, value in pairs(tbl) do + if value == element then + return true + end + end + return false +end + +function table.contains_any(tbl, elements) + if tbl == nil or elements == nil then return false end + for _, value in pairs(tbl) do + for _, element in pairs(elements) do + if value == element then + return true + end + end + end + return false +end \ No newline at end of file