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
161
162
163
|
local sounds = {}
minetest.register_node("handdryer:a",{
description = "Hand Dryer",
groups = {cracky=3},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
node_box = {
type = "fixed",
fixed = {
{-0.3, -0.25, 0.204, 0.3, 0.25, 0.5}, --Body
{-0.202, -0.094, 0.1, -0.077, 0.1085, 0.204}, --Outlet
{0.125, -0.045, 0.15, 0.22, 0.045, 0.204}, --Button
},
},
tiles = {
"handdryer_a_xa5_sides.png",
"handdryer_a_xa5_bottom.png^[transformFY",
"handdryer_a_xa5_sides.png^[transformR270",
"handdryer_a_xa5_sides.png^[transformR90",
"handdryer_metal.png",
"handdryer_a_front.png",
},
on_rightclick = function(pos)
local hash = minetest.hash_node_position(pos)
local handle = sounds[hash]
if handle then
minetest.sound_stop(handle)
end
sounds[hash] = minetest.sound_play("handdryer_a_ra_run",{pos=pos,gain=0.75,max_hear_distance=20})
end,
})
minetest.register_node("handdryer:ra",{
description = "Recessed Hand Dryer",
groups = {cracky=3},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
node_box = {
type = "fixed",
fixed = {
{-0.3, -0.45, 0.45, 0.3, 0.25, 0.5}, --Body
{-0.202, -0.094, 0.35, -0.077, 0.1085, 0.45}, --Outlet
{0.125, -0.045, 0.4, 0.22, 0.045, 0.45}, --Button
},
},
tiles = {
"handdryer_a_xa5_sides.png",
"handdryer_a_xa5_bottom.png^[transformFY",
"handdryer_a_xa5_sides.png^[transformR270",
"handdryer_a_xa5_sides.png^[transformR90",
"handdryer_metal.png",
"handdryer_ra_front.png",
},
on_rightclick = function(pos)
local hash = minetest.hash_node_position(pos)
local handle = sounds[hash]
if handle then
minetest.sound_stop(handle)
end
sounds[hash] = minetest.sound_play("handdryer_a_ra_run",{pos=pos,gain=0.75,max_hear_distance=20})
end,
})
minetest.register_node("handdryer:xa5",{
description = "Automatic Hand Dryer",
groups = {cracky=3},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
is_ground_content = false,
node_box = {
type = "fixed",
fixed = {
{-0.3, -0.25, 0.204, 0.3, 0.25, 0.5}, --Body
{-0.202, -0.094, 0.1, -0.077, 0.1085, 0.204}, --Outlet
},
},
tiles = {
"handdryer_a_xa5_sides.png",
"handdryer_a_xa5_bottom.png^[transformFY",
"handdryer_a_xa5_sides.png^[transformR270",
"handdryer_a_xa5_sides.png^[transformR90",
"handdryer_metal.png",
"handdryer_xa5_front.png",
},
on_destruct = function(pos)
local hash = minetest.hash_node_position(pos)
local handle = sounds[hash]
local meta = minetest.get_meta(pos)
if handle then minetest.sound_stop(handle) end
if meta:get_int("running") == 1 then
meta:set_int("running",0)
minetest.sound_play("handdryer_xa5_stop",{pos=pos,gain=0.75,max_hear_distance=20})
end
end,
})
minetest.register_abm({
label = "Automatic hand dryers",
interval = 1,
chance = 1,
nodenames = {"handdryer:xa5"},
action = function(pos)
local posbelow = vector.add(pos,vector.new(0,-1,0))
local objects = minetest.get_objects_inside_radius(posbelow,1)
local player = false
for _,obj in pairs(objects) do
if obj:is_player() then player = true end
end
local hash = minetest.hash_node_position(pos)
local handle = sounds[hash]
local meta = minetest.get_meta(pos)
if player then
if meta:get_int("running") == 0 then
if handle then minetest.sound_stop(handle) end
meta:set_int("running",1)
minetest.sound_play("handdryer_xa5_start",{pos=pos,gain=0.75,max_hear_distance=20})
minetest.after(2,function()
if meta:get_int("running") ~= 1 then return end
sounds[hash] = minetest.sound_play("handdryer_xa5_run",{pos=pos,gain=0.75,max_hear_distance=20,loop=true})
end)
end
else
if handle then minetest.sound_stop(handle) end
if meta:get_int("running") == 1 then
meta:set_int("running",0)
minetest.sound_play("handdryer_xa5_stop",{pos=pos,gain=0.75,max_hear_distance=20})
end
end
end,
})
minetest.register_craft({
output = "handdryer:a",
recipe = {
{"default:steel_ingot","default:steel_ingot","mesecons_button:button_off"},
{"default:steel_ingot","homedecor:fan_blades","homedecor:motor"},
{"default:steel_ingot","homedecor:heating_element","default:steel_ingot"},
},
})
minetest.register_craft({
output = "handdryer:ra",
recipe = {
{"default:steel_ingot","default:steel_ingot","mesecons_button:button_off"},
{"homedecor:motor","homedecor:fan_blades","default:steel_ingot"},
{"default:steel_ingot","homedecor:heating_element","default:steel_ingot"},
},
})
minetest.register_craft({
output = "handdryer:xa5",
recipe = {
{"default:steel_ingot","default:steel_ingot","homedecor:ic"},
{"default:steel_ingot","homedecor:fan_blades","homedecor:motor"},
{"default:steel_ingot","homedecor:heating_element","mesecons_solarpanel:solar_panel_off"},
},
})
|