Repository navigation
Expand file tree
/
Copy pathinit.lua
More file actions
144 lines (116 loc) · 3.78 KB
/
Copy pathinit.lua
File metadata and controls
144 lines (116 loc) · 3.78 KB
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
--[[
Teleporter networks that allow players to choose a destination out of a list
Copyright (C) 2013 Sokomine
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
--]]
-- Required to save the travelnet data properly in all cases
if not core.safe_file_write then
error("[Mod travelnet] Your Minetest version is no longer supported. (version < 0.4.17)")
end
travelnet = {
-- some players seem to be confused with entering network names at first; provide them
-- with a default name
default_network = "net1"
}
travelnet.log = function(c, msg) core.log(c, "[travelnet] " .. msg) end
travelnet.player_formspec_data = {}
travelnet.path = core.get_modpath(core.get_current_modname())
local function mod_dofile(filename)
dofile(travelnet.path .. "/"..filename..".lua")
end
-- privs
mod_dofile("privs")
-- read the configuration
mod_dofile("config")
-- saving / reading
mod_dofile("persistence")
-- common functions
mod_dofile("functions")
mod_dofile("actions/main")
-- formspec stuff
mod_dofile("formspecs")
mod_dofile("formspecs-legacy")
-- travelnet / elevator update
mod_dofile("update_formspec")
-- add button
mod_dofile("add_target")
-- chatcommand
mod_dofile("chat")
-- receive fields handler
mod_dofile("on_receive_fields")
-- meta-formspec migration lbm
if travelnet.travelnet_cleanup_lbm then
mod_dofile("migrate_formspecs_lbm")
end
-- invisible node to place inside top of travelnet box and elevator
core.register_node("travelnet:hidden_top", {
drawtype = "airlike",
paramtype = "light",
sunlight_propagates = true,
walkable = false,
pointable = false,
diggable = false,
groups = {not_in_creative_inventory = 1},
is_ground_content = false,
drop = "",
})
if core.get_modpath("mesecons_mvps") then
mesecon.register_mvps_stopper("travelnet:hidden_top")
end
if travelnet.travelnet_effect_enabled then
core.register_entity("travelnet:effect", {
hp_max = 1,
physical = false,
weight = 5,
collisionbox = { -0.4, -0.5, -0.4, 0.4, 1.5, 0.4 },
visual = "upright_sprite",
visual_size = { x=1, y=2 },
textures = { "travelnet_flash.png" }, -- number of required textures depends on visual
spritediv = { x=1, y=1 },
initial_sprite_basepos = { x=0, y=0 },
is_visible = true,
makes_footstep_sound = false,
automatic_rotate = true,
anz_rotations = 0,
on_step = function(self)
-- this is supposed to be more flickering than smooth animation
self.object:set_yaw(self.object:get_yaw()+1)
self.anz_rotations = self.anz_rotations+1
-- eventually self-destruct
if self.anz_rotations > 15 then
self.object:remove()
end
end
})
end
if travelnet.travelnet_enabled then
-- register-functions for travelnet nodes
mod_dofile("register_travelnet")
-- default travelnet registrations
mod_dofile("travelnet")
end
if travelnet.elevator_enabled then
mod_dofile("elevator") -- allows up/down transfers only
end
if travelnet.doors_enabled then
-- doors that open and close automaticly when the travelnet or elevator is used
mod_dofile("doors")
end
if travelnet.enable_abm then
-- restore travelnet data when players pass by broken networks
mod_dofile("restore_network_via_abm")
end
-- upon server start, read the savefile
travelnet.player_formspec_data = nil
if core.get_modpath("mtt") and mtt.enabled then
mod_dofile("mtt")
end