Initial commit

master
HimbeerserverDE 2020-09-18 16:50:52 +02:00
parent f38d407336
commit b5ce84a5d3
7 changed files with 147 additions and 0 deletions

144
init.lua Normal file
View File

@ -0,0 +1,144 @@
local m_rules = {
{x = 0, y = 0, z = -1},
{x = 1, y = 0, z = 0},
{x = -1, y = 0, z = 0},
{x = 0, y = 0, z = 1},
{x = 1, y = 1, z = 0},
{x = 1, y = -1, z = 0},
{x = -1, y = 1, z = 0},
{x = -1, y = -1, z = 0},
{x = 0, y = 1, z = 1},
{x = 0, y = -1, z = 1},
{x = 0, y = 1, z = -1},
{x = 0, y = -1, z = -1},
{x = 0, y = -1, z = 0},
{x = 0, y = 0, z = -2},
{x = 2, y = 0, z = 0},
{x = -2, y = 0, z = 0},
{x = 0, y = 0, z = 2},
{x = 2, y = 2, z = 0},
{x = 2, y = -2, z = 0},
{x = -2, y = 2, z = 0},
{x = -2, y = -2, z = 0},
{x = 0, y = 2, z = 2},
{x = 0, y = -2, z = 2},
{x = 0, y = 2, z = -2},
{x = 0, y = -2, z = -2},
{x = 0, y = -2, z = 0},
}
minetest.register_node("alarms:fire", {
description = "Fire alarm",
groups = {snappy = 1},
tiles = {"red.png", "red.png", "red.png", "red.png", "red.png", "gray.png"},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.5, 0.2, 0.2, -0.4},
},
},
mesecons = {
effector = {
rules = m_rules,
action_on = function(pos, node)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 20)) do
if not obj:is_player() then return end
local sound = minetest.sound_play("alarm_fire", {
to_player = obj:get_player_name(),
max_hear_distance = 20,
gain = 10.0,
})
end
minetest.get_meta(pos):set_int("sound", sound)
end,
action_off = function(pos, node)
if not minetest.get_meta(pos):get_int("sound") then return end
minetest.sound_stop(minetest.get_meta(pos):get_int("sound"))
end,
},
},
on_destruct = function(pos)
if not minetest.get_meta(pos):get_int("sound") then return end
minetest.sound_stop(minetest.get_meta(pos):get_int("sound"))
end,
})
minetest.register_node("alarms:nuclear", {
description = "Nuclear alarm",
groups = {choppy = 1},
tiles = {"gray.png"},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.8, 0.2, 0.2, 0.8},
},
},
mesecons = {
effector = {
rules = m_rules,
action_on = function(pos, node)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 20)) do
if not obj:is_player() then return end
local sound = minetest.sound_play("alarm_nuclear", {
to_player = obj:get_player_name(),
max_hear_distance = 20,
gain = 10.0,
})
end
minetest.get_meta(pos):set_int("sound", sound)
end,
action_off = function(pos, node)
if not minetest.get_meta(pos):get_int("sound") then return end
minetest.sound_stop(minetest.get_meta(pos):get_int("sound"))
end,
},
},
on_destruct = function(pos)
if not minetest.get_meta(pos):get_int("sound") then return end
minetest.sound_stop(minetest.get_meta(pos):get_int("sound"))
end,
})
minetest.register_node("alarms:intruder", {
description = "Intruder alarm",
groups = {snappy = 1},
tiles = {"gray.png", "gray.png", "gray.png", "gray.png", "gray.png", "red.png"},
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
node_box = {
type = "fixed",
fixed = {
{-0.2, -0.2, -0.5, 0.2, 0.2, -0.4},
},
},
mesecons = {
effector = {
rules = m_rules,
action_on = function(pos, node)
for _, obj in ipairs(minetest.get_objects_inside_radius(pos, 20)) do
if not obj:is_player() then return end
local sound = minetest.sound_play("alarm_intruder", {
to_player = obj:get_player_name(),
max_hear_distance = 20,
gain = 10.0,
})
end
minetest.get_meta(pos):set_int("sound", sound)
end,
action_off = function(pos, node)
if not minetest.get_meta(pos):get_int("sound") then return end
minetest.sound_stop(minetest.get_meta(pos):get_int("sound"))
end,
},
},
on_destruct = function(pos)
if not minetest.get_meta(pos):get_int("sound") then return end
minetest.sound_stop(minetest.get_meta(pos):get_int("sound"))
end,
})

3
mod.conf Normal file
View File

@ -0,0 +1,3 @@
name = alarms
description = "Adds alarm nodes for minetest"
depends = mesecons

BIN
sounds/alarm_fire.ogg Normal file

Binary file not shown.

BIN
sounds/alarm_intruder.ogg Normal file

Binary file not shown.

BIN
sounds/alarm_nuclear.ogg Normal file

Binary file not shown.

BIN
textures/gray.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B

BIN
textures/red.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 B