-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
147 lines (143 loc) · 3.98 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
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
--[[
## StreetsMod 2.0 ##
Submod: laneuse
Optional: true
]]
local nodebox = {
{ -7 / 16, -7 / 16, -1 / 8, 7 / 16, 7 / 16, 1 / 8 }, --Face
{ -7 / 16, 0, -1 / 4, -3 / 8, 7 / 16, -1 / 8 }, --Visor Left
{ 3 / 8, 0, -1 / 4, 7 / 16, 7 / 16, -1 / 8 }, --Visor Right
{ -7 / 16, 3 / 8, -5 / 16, 7 / 16, 7 / 16, -1 / 8 }, --Visor Top
{ -1 / 4, -1 / 4, 0.85, 1 / 4, 1 / 4, 1 / 8 }, --Mounting Bracket
}
minetest.register_node("streets:lane_use_off", {
description = "Lane Use Signal",
tiles = {
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_laneuse_off.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;Channel;${channel}]")
end,
groups = { cracky = 3 },
node_box = {
type = "fixed",
fixed = nodebox
},
selection_box = {
type = "fixed",
fixed = nodebox
},
on_receive_fields = function(pos, formname, fields, sender)
local name = sender:get_player_name()
if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, { protection_bypass = true }) then
minetest.record_protection_violation(pos, name)
return
end
if (fields.channel) then
minetest.get_meta(pos):set_string("channel", fields.channel)
end
end,
digiline = {
receptor = {},
effector = {
action = function(pos, node, channel, msg)
local setchan = minetest.get_meta(pos):get_string("channel")
if setchan ~= channel then
return
end
msg = msg:lower()
if (msg == "off") then
node.name = "streets:lane_use_off"
elseif (msg == "green") then
node.name = "streets:lane_use_green"
elseif (msg == "red") then
node.name = "streets:lane_use_red"
elseif (msg == "yellow") then
node.name = "streets:lane_use_yellow"
end
minetest.set_node(pos, node)
minetest.get_meta(pos):set_string("channel", setchan)
end
}
}
})
for _, v in pairs({ "green", "yellow", "red" }) do
minetest.register_node("streets:lane_use_" .. v, {
drop = "streets:lane_use_off",
tiles = {
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_tl_bg.png",
"streets_laneuse_" .. v .. ".png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec", "field[channel;Channel;${channel}]")
end,
groups = { cracky = 3, not_in_creative_inventory = 1 },
light_source = 11,
node_box = {
type = "fixed",
fixed = nodebox
},
selection_box = {
type = "fixed",
fixed = nodebox
},
on_receive_fields = function(pos, formname, fields, sender)
local name = sender:get_player_name()
if minetest.is_protected(pos, name) and not minetest.check_player_privs(name, { protection_bypass = true }) then
minetest.record_protection_violation(pos, name)
return
end
if (fields.channel) then
minetest.get_meta(pos):set_string("channel", fields.channel)
end
end,
digiline = {
receptor = {},
effector = {
action = function(pos, node, channel, msg)
local setchan = minetest.get_meta(pos):get_string("channel")
if setchan ~= channel then
return
end
msg = msg:lower()
if (msg == "off") then
node.name = "streets:lane_use_off"
elseif (msg == "green") then
node.name = "streets:lane_use_green"
elseif (msg == "red") then
node.name = "streets:lane_use_red"
elseif (msg == "yellow") then
node.name = "streets:lane_use_yellow"
end
minetest.set_node(pos, node)
minetest.get_meta(pos):set_string("channel", setchan)
end
}
}
})
end
minetest.register_craft({
output = "streets:lane_use_off",
recipe = {
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" },
{ "dye:red", "dye:yellow", "dye:green" },
{ "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" }
}
})