-
Notifications
You must be signed in to change notification settings - Fork 0
/
nodes.lua
150 lines (124 loc) · 4.6 KB
/
nodes.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
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
145
146
147
148
149
150
minetest.register_node("tardis:tardis", {
decription = "Testing And Relative Dimensions In (3D) Space",
tiles = { "tardis_exterior.png" },
use_texture_alpha = true,
drawtype = "mesh",
mesh = "tardis_exterior.obj",
paramtype = "light",
selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5}},
collision_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5}},
-- Setup Meta, clone meta if not placed by a player
on_place = function(itemstack, placer, pointed_thing)
local pos = pointed_thing.above
local name = placer:get_player_name()
tardis.swap_node(pos, {name = "tardis:tardis"})
if (name) then
tardis:spawn_interior (pos, name)
else
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if (tardis.get_interior(owner)) then
tardis.set_exerior(pos, owner)
else tardis.set_exterior(pos, name)
end
end
local meta = minetest.get_meta(pos)
meta:set_string ("owner", name)
itemstack:take_item()
return itemstack
end,
-- Teleport Player
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local meta = minetest.get_meta(pos)
local name = meta:get_string("owner")
local teleport = tardis.get_interior(name)
teleport.z = teleport.z + 1
player.setpos(player, teleport)
end,
})
-- Initialize materialization, fail if nav is not set, then swap node to off pos
minetest.register_node("tardis:demat_lever_on", {
tiles = {"tardis_demat.png"},
drawtype = "mesh",
mesh = "tardis_demat_on.obj",
paramtype = "light",
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if (tardis.remat(owner)) then
minetest.sound_play ("tardis_remat", {
pos = pos ,
max_hear_distance = 100 ,
gain = 10 ,
})
minetest.swap_node(pos, {name = "tardis:demat_lever_off"})
else
minetest.chat_send_player(name, "Failed to remat")
end
end
})
-- Initialize dematerialization, then set lever to on pos
minetest.register_node ("tardis:demat_lever_off", {
tiles = {"tardis_demat.png"},
drawtype = "mesh",
mesh = "tardis_demat_off.obj",
paramtype = "light",
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if (tardis.demat(owner)) then
minetest.sound_play ("tardis_demat", {
pos = pos ,
max_hear_distance = 10 ,
gain = 10 ,
})
minetest.swap_node (pos, {name = "tardis:demat_lever_on"})
else
minetest.chat_send_player(name, "Failed to demat")
end
end
})
minetest.register_node("tardis:navigator", {
tiles = {"tardis_navigator.png"},
drawtype = "signlike",
paramtype = "light",
paramtype2 = "wallmounted",
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
tardis.show_nav_formspec(name, owner)
end
})
-- Teleports player to exterior is in_vortex is set to false
minetest.register_node("tardis:interior_doors", {
tiles = {"tardis_doors.png"},
use_texture_alpha = true,
drawtype = "mesh",
mesh = "tardis_interior_doors.obj",
paramtype = "light",
selection_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5}},
collision_box = {type = "fixed", fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5}},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local name = player:get_player_name()
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if (tardis.get_vortex(owner)) then
minetest.chat_send_player (name, "The TARDIS is in the Vortex - the doors have been locked automatically.")
else
local teleport = tardis.get_exterior(owner)
teleport["z"] = teleport["z"] - 1
player:setpos(teleport)
end
end,
on_timer = function(pos)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
if (tardis.get_vortex(owner)) then -- If we're in a vortex, we must have been activated from the remat function.
tardis.set_vortex(false, owner) -- exit it.
tardis.swap_node((tardis.get_exterior(owner)), {name = "tardis:tardis"})
end
end
})