-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinit.lua
86 lines (68 loc) · 1.92 KB
/
init.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
local MP = minetest.get_modpath("modgen")
local storage = minetest.get_mod_storage()
local VERSION = 4
-- mod namespace
modgen = {
pos1 = {},
pos2 = {},
MOD_PATH = MP,
CHUNK_LENGTH = 80,
-- current version
version = VERSION,
-- autosave feature
autosave = storage:get_int("autosave") == 1,
-- mod storage
storage = storage,
-- export path for the generated mod
export_path = minetest.get_worldpath() .. "/modgen_mod_export",
-- manifest of already existing import-mod if available
manifest = {
-- stats
size = 0,
chunks = 0,
-- exported name to nodeid mapping
node_mapping = {},
-- next nodeid
next_id = 0,
-- current export/import version
version = VERSION
},
-- enables saving mapblocks in-place
enable_inplace_save = false
}
-- create export directories
minetest.mkdir(modgen.export_path)
minetest.mkdir(modgen.export_path .. "/map")
-- secure/insecure environment
local global_env = _G
local ie = minetest.request_insecure_environment and minetest.request_insecure_environment()
if ie then
print("[modgen] using insecure environment")
-- register insecure environment
global_env = ie
-- enable in-place saving
modgen.enable_inplace_save = true
end
-- pass on global env (secure/insecure)
loadfile(MP.."/functions.lua")(global_env)
loadfile(MP.."/manifest.lua")(global_env)
dofile(MP.."/hud.lua")
dofile(MP.."/debug.lua")
dofile(MP.."/encode.lua")
dofile(MP.."/chunk.lua")
dofile(MP.."/markers.lua")
dofile(MP.."/register.lua")
dofile(MP.."/serialize.lua")
dofile(MP.."/iterator_next.lua")
dofile(MP.."/export.lua")
dofile(MP.."/autosave.lua")
dofile(MP.."/commands/stats.lua")
dofile(MP.."/commands/export.lua")
dofile(MP.."/commands/export_here.lua")
dofile(MP.."/commands/autosave.lua")
dofile(MP.."/commands/pos.lua")
-- try to read existing manifest in worldpath
modgen.read_manifest(modgen.export_path .. "/manifest.json")
if minetest.get_modpath("mtt") then
dofile(MP.."/iterator_next.spec.lua")
end