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
151
152
153
154
155
156
157
158
159
160
|
digistuff.button_turnoff = function (pos)
local node = minetest.get_node(pos)
if node.name=="digistuff:button_on" then --has not been dug
minetest.swap_node(pos, {name = "digistuff:button_off", param2=node.param2})
if minetest.get_modpath("mesecons") then minetest.sound_play("mesecons_button_pop", {pos=pos}) end
end
end
minetest.register_node("digistuff:button", {
drawtype = "nodebox",
tiles = {
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_off.png"
},
paramtype = "light",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
}
},
digiline =
{
receptor = {}
},
groups = {dig_immediate=2},
description = "Digilines Button",
on_construct = function(pos)
local meta = minetest.get_meta(pos)
meta:set_string("formspec","size[8,4;]field[1,1;6,2;channel;Channel;${channel}]field[1,2;6,2;msg;Message;${msg}]button_exit[2.25,3;3,1;submit;Save]")
end,
on_receive_fields = function(pos, formname, fields, sender)
local meta = minetest.get_meta(pos)
if fields.channel and fields.msg and fields.channel ~= "" and fields.msg ~= "" then
meta:set_string("channel",fields.channel)
meta:set_string("msg",fields.msg)
meta:set_string("formspec","")
minetest.swap_node(pos, {name = "digistuff:button_off", param2=minetest.get_node(pos).param2})
else
minetest.chat_send_player(sender:get_player_name(),"Channel and message must both be set!")
end
end,
sounds = default and default.node_sound_stone_defaults(),
})
minetest.register_node("digistuff:button_off", {
drawtype = "nodebox",
tiles = {
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_off.png"
},
paramtype = "light",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 }, -- the thin plate behind the button
{ -4/16, -2/16, 4/16, 4/16, 2/16, 6/16 } -- the button itself
}
},
digiline =
{
receptor = {}
},
groups = {dig_immediate=2, not_in_creative_inventory=1},
drop = "digistuff:button",
description = "Digilines Button (off state - you hacker you!)",
on_rightclick = function (pos, node, clicker)
local meta = minetest.get_meta(pos)
digiline:receptor_send(pos, digiline.rules.default, meta:get_string("channel"), meta:get_string("msg"))
minetest.swap_node(pos, {name = "digistuff:button_on", param2=node.param2})
if minetest.get_modpath("mesecons") then minetest.sound_play("mesecons_button_push", {pos=pos}) end
minetest.after(0.5, digistuff.button_turnoff, pos)
end,
sounds = default and default.node_sound_stone_defaults(),
})
minetest.register_node("digistuff:button_on", {
drawtype = "nodebox",
tiles = {
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_sides.png",
"digistuff_digibutton_on.png"
},
paramtype = "light",
paramtype2 = "facedir",
legacy_wallmounted = true,
walkable = false,
light_source = 7,
sunlight_propagates = true,
selection_box = {
type = "fixed",
fixed = { -6/16, -6/16, 5/16, 6/16, 6/16, 8/16 }
},
node_box = {
type = "fixed",
fixed = {
{ -6/16, -6/16, 6/16, 6/16, 6/16, 8/16 },
{ -4/16, -2/16, 11/32, 4/16, 2/16, 6/16 }
}
},
digiline =
{
receptor = {}
},
groups = {dig_immediate=2, not_in_creative_inventory=1},
drop = 'digistuff:button',
on_rightclick = function (pos, node, clicker)
local meta = minetest.get_meta(pos)
digiline:receptor_send(pos, digiline.rules.default, meta:get_string("channel"), meta:get_string("msg"))
if minetest.get_modpath("mesecons") then minetest.sound_play("mesecons_button_push", {pos=pos}) end
end,
description = "Digilines Button (on state - you hacker you!)",
sounds = default and default.node_sound_stone_defaults(),
})
minetest.register_craft({
output = "digistuff:digimese",
recipe = {
{"digilines:wire_std_00000000","digilines:wire_std_00000000","digilines:wire_std_00000000"},
{"digilines:wire_std_00000000","default:mese","digilines:wire_std_00000000"},
{"digilines:wire_std_00000000","digilines:wire_std_00000000","digilines:wire_std_00000000"}
}
})
minetest.register_craft({
output = "digistuff:button",
recipe = {
{"mesecons_button:button_off"},
{"mesecons_luacontroller:luacontroller0000"},
{"digilines:wire_std_00000000"}
}
})
|