-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.lua
112 lines (92 loc) · 3.8 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
local load_start = os.clock()
mcl_beacon = {}
mcl_beacon.effects = {}
mcl_beacon.colors = {}
mcl_beacon.players = {}
mcl_beacon.sorted_effect_ids = {}
local function get_value(value, default)
if value == nil then
return default
end
return value
end
mcl_beacon.config = {
area_shielding = get_value(minetest.settings:get("mcl_beacon_area_shielding"), false),
beam_break_nodes = get_value(minetest.settings:get_bool("mcl_beacon_beam_break_nodes"), false),
beam_climbable = get_value(minetest.settings:get_bool("mcl_beacon_beam_climbable"), false),
beam_length = get_value(tonumber(minetest.settings:get("mcl_beacon_beam_length")), 200),
default_effect = get_value(minetest.settings:get("mcl_beacon_default_effect"), "none"),
effect_range_0 = get_value(tonumber(minetest.settings:get("mcl_beacon_effect_range_0")), 10),
effect_range_1 = get_value(tonumber(minetest.settings:get("mcl_beacon_effect_range_1")), 20),
effect_range_2 = get_value(tonumber(minetest.settings:get("mcl_beacon_effect_range_3")), 30),
effect_range_3 = get_value(tonumber(minetest.settings:get("mcl_beacon_effect_range_4")), 40),
effect_range_4 = get_value(tonumber(minetest.settings:get("mcl_beacon_effect_range_5")), 50),
upgrade_item = get_value(minetest.settings:get("mcl_beacon_upgrade_item"), "mcl_core:diamondblock"),
}
mcl_beacon.dir_to_vector = {
["+X"] = {x= 1,y=0,z=0},
["-X"] = {x=-1,y=0,z=0},
["+Y"] = {x=0,y= 1,z=0},
["-Y"] = {x=0,y=-1,z=0},
["+Z"] = {x=0,y=0,z= 1},
["-Z"] = {x=0,y=0,z=-1},
}
mcl_beacon.dir_to_param2 = {
["+X"] = 12,
["-X"] = 16,
["+Y"] = 0,
["-Y"] = 20,
["+Z"] = 4,
["-Z"] = 8,
}
mcl_beacon.param2_to_under = {
[ 0] = {x= 0,y=-1,z= 0}, [ 1] = {x= 0,y=-1,z= 0},
[ 2] = {x= 0,y=-1,z= 0}, [ 3] = {x= 0,y=-1,z= 0},
[ 4] = {x= 0,y= 0,z=-1}, [ 5] = {x= 0,y= 0,z=-1},
[ 6] = {x= 0,y= 0,z=-1}, [ 7] = {x= 0,y= 0,z=-1},
[ 8] = {x= 0,y= 0,z= 1}, [ 9] = {x= 0,y= 0,z= 1},
[10] = {x= 0,y= 0,z= 1}, [11] = {x= 0,y= 0,z= 1},
[12] = {x=-1,y= 0,z= 0}, [13] = {x=-1,y= 0,z= 0},
[14] = {x=-1,y= 0,z= 0}, [15] = {x=-1,y= 0,z= 0},
[16] = {x= 1,y= 0,z= 0}, [17] = {x= 1,y= 0,z= 0},
[18] = {x= 1,y= 0,z= 0}, [19] = {x= 1,y= 0,z= 0},
[20] = {x= 0,y= 1,z= 0}, [21] = {x= 0,y= 1,z= 0},
[22] = {x= 0,y= 1,z= 0}, [23] = {x= 0,y= 1,z= 0},
}
mcl_beacon.param2_to_dir = {
[ 0] = "+Y", [ 1] = "+Y", [ 2] = "+Y", [ 3] = "+Y",
[ 4] = "+Z", [ 5] = "+Z", [ 6] = "+Z", [ 7] = "+Z",
[ 8] = "-Z", [ 9] = "-Z", [10] = "-Z", [11] = "-Z",
[12] = "+X", [13] = "+X", [14] = "+X", [15] = "+X",
[16] = "-X", [17] = "-X", [18] = "-X", [19] = "-X",
[20] = "-Y", [21] = "-Y", [22] = "-Y", [23] = "-Y",
}
mcl_beacon.has_player_monoids = minetest.global_exists("player_monoids")
mcl_beacon.has_digilines = minetest.global_exists("digilines")
mcl_beacon.has_areas = minetest.global_exists("areas")
mcl_beacon.modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(mcl_beacon.modpath.."/api.lua")
dofile(mcl_beacon.modpath.."/helpers.lua")
dofile(mcl_beacon.modpath.."/functions.lua")
dofile(mcl_beacon.modpath.."/formspec.lua")
dofile(mcl_beacon.modpath.."/effects.lua")
dofile(mcl_beacon.modpath.."/digiline.lua")
dofile(mcl_beacon.modpath.."/register.lua")
dofile(mcl_beacon.modpath.."/chatcommands.lua")
dofile(mcl_beacon.modpath.."/effects/init.lua")
minetest.after(0, function()
-- check if upgrade item is registered
if not minetest.registered_items[mcl_beacon.config.upgrade_item] then
mcl_beacon.config.upgrade_item = "mcl_core:diamondblock"
end
-- check if default effect is registered
if not mcl_beacon.effects[mcl_beacon.config.default_effect] then
mcl_beacon.config.default_effect = "none"
end
-- sort effect ids
for id,_ in pairs(mcl_beacon.effects) do
table.insert(mcl_beacon.sorted_effect_ids, id)
end
table.sort(mcl_beacon.sorted_effect_ids)
end)
print(("[mcl_beacon] Loaded in %f seconds"):format(os.clock() - load_start))