-
Notifications
You must be signed in to change notification settings - Fork 9
/
lib_control.lua
38 lines (34 loc) · 950 Bytes
/
lib_control.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
local function debugDump(var, force)
if false or force then
for _, player in pairs(game.players) do
local msg
if type(var) == "string" then
msg = var
else
msg = serpent.dump(var, {name="var", comment=false, sparse=false, sortkeys=true})
end
player.print(msg)
end
end
end
local function saveVar(var, name)
var = var or global
local n = name or ""
game.write_file("module"..n..".lua", serpent.block(var, {name="global"}))
end
local function config_exists(config, name)
local configs = {}
local found = 1
for i = 1, table_size(config) do
if config[i].from == name then
configs[found] = config[i]
found = found + 1
end
end
return found > 1 and configs or false
end
local M = {}
M.debugDump = debugDump
M.saveVar = saveVar
M.config_exists = config_exists
return M