-
Notifications
You must be signed in to change notification settings - Fork 6
/
init.lua
88 lines (71 loc) · 2.3 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
87
88
-- simple_protection initialization
if not minetest.get_translator then
error("[simple_protection] Your Minetest version is no longer supported."
.. " (version < 5.0.0)")
end
simple_protection = {}
local world_path = minetest.get_worldpath()
local sp = simple_protection
s_protect = sp -- Backwards compat
sp.mod_path = minetest.get_modpath("simple_protection")
sp.conf = world_path.."/s_protect.conf"
-- Raw backend paths
sp.file = world_path.."/s_protect.data"
sp.sharefile = world_path.."/s_protect_share.data"
-- Translation functions
sp.S = minetest.get_translator("simple_protection")
sp.FS = function(...)
return minetest.formspec_escape(sp.S(...))
end
sp.translator = sp.S -- TODO: Remove
-- Unify checks of what game we are under
if minetest.get_modpath("default") then
sp.game_mode = "MTG" -- Minetest Game
elseif minetest.get_modpath("mcl_core") then
sp.game_mode = "MCL" -- VoxeLibre / Mineclonia and any other similar fork
else
sp.game_mode = "???"
end
minetest.register_privilege("simple_protection",
sp.S("Allows to modify and delete protected areas"))
-- Load helper functions and configuration
dofile(sp.mod_path.."/misc_functions.lua")
sp.load_config()
-- Unify crafting items
sp.resource = {
copper = "default:copper_ingot",
steel = "default:steel_ingot",
stonebrick = "default:stonebrick",
chest = {
-- Used in: chest.lua
regular = "default:chest",
locked = "default:chest_locked"
},
}
if sp.game_mode == "MCL" then
if minetest.get_modpath("mcl_copper") then
sp.resource.copper = "mcl_copper:copper_ingot"
else
-- No copper, fallback to gold
sp.resource.copper = "mcl_core:gold_ingot"
end
sp.resource.steel = "mcl_core:iron_ingot"
sp.resource.stonebrick = "mcl_core:stonebrick"
sp.resource.chest.regular = "mcl_chests:chest"
-- There is no locked chest, fallback to trapped chest
sp.resource.chest.locked = "mcl_chests:trapped_chest"
end
-- Load database functions
dofile(sp.mod_path.."/command_mgr.lua")
if sp.backend == "storage" then
dofile(sp.mod_path.."/database_storage.lua")
else
dofile(sp.mod_path.."/database_raw.lua")
end
-- Spread the load a bit
minetest.after(0.5, sp.load_db)
-- General things to make this mod friendlier
dofile(sp.mod_path.."/protection.lua")
dofile(sp.mod_path.."/hud.lua")
dofile(sp.mod_path.."/radar.lua")
dofile(sp.mod_path.."/chest.lua")