techage_modpack_ru_upd/signs_bot/extender.lua

140 lines
3.8 KiB
Lua
Raw Permalink Normal View History

2020-05-31 23:31:18 +03:00
--[[
Signs Bot
=========
2021-05-14 19:50:16 +03:00
Copyright (C) 2019-2021 Joachim Stolberg
2020-05-31 23:31:18 +03:00
GPL v3
See LICENSE.txt for more information
2022-09-24 12:01:30 +03:00
2020-05-31 23:31:18 +03:00
Sensor Extender
(passive node, the Sensor detects the extender)
]]--
-- for lazy programmers
2021-05-14 19:50:16 +03:00
local P2S = function(pos) if pos then return minetest.pos_to_string(pos) end end
2020-05-31 23:31:18 +03:00
local M = minetest.get_meta
2021-05-14 19:50:16 +03:00
-- Load support for I18n.
local S = signs_bot.S
2020-05-31 23:31:18 +03:00
local function update_infotext(pos, dest_pos, cmnd)
2021-05-14 19:50:16 +03:00
M(pos):set_string("infotext", S("Sensor Extender: Connected with").." "..P2S(dest_pos).." / "..cmnd)
2022-09-24 12:01:30 +03:00
end
2020-05-31 23:31:18 +03:00
minetest.register_node("signs_bot:sensor_extender", {
2021-05-14 19:50:16 +03:00
description = S("Sensor Extender"),
2020-05-31 23:31:18 +03:00
inventory_image = "signs_bot_extender_inv.png",
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {
{-6/32, -1/2, -6/32, 6/32, -5/16, 6/32},
},
connect_front = {{-1/16, -1/2, -12/16, 1/16, -6/16, 1/16}},
connect_left = {{-12/16, -1/2, -1/16, 1/16, -6/16, 1/16}},
connect_back = {{-1/16, -1/2, -1/16, 1/16, -6/16, 12/16}},
connect_right = {{-1/16, -1/2, -1/16, 12/16, -6/16, 1/16}},
},
connects_to = {"group:sign_bot_sensor"},
tiles = {
-- up, down, right, left, back, front
"signs_bot_extender.png",
"signs_bot_extender.png",
"signs_bot_extender_side.png",
"signs_bot_extender_side.png",
"signs_bot_extender_side.png",
"signs_bot_extender_side.png",
},
2022-09-24 12:01:30 +03:00
2020-05-31 23:31:18 +03:00
after_place_node = function(pos, placer)
local meta = M(pos)
2021-05-14 19:50:16 +03:00
meta:set_string("infotext", S("Sensor Extender: Not connected"))
2020-05-31 23:31:18 +03:00
end,
2022-09-24 12:01:30 +03:00
2020-05-31 23:31:18 +03:00
update_infotext = update_infotext,
on_rotate = screwdriver.disallow,
paramtype = "light",
2021-05-14 19:50:16 +03:00
use_texture_alpha = signs_bot.CLIP,
2020-05-31 23:31:18 +03:00
sunlight_propagates = true,
paramtype2 = "facedir",
is_ground_content = false,
groups = {sign_bot_sensor = 1, cracky = 1},
sounds = default.node_sound_metal_defaults(),
})
minetest.register_node("signs_bot:sensor_extender_on", {
2021-05-14 19:50:16 +03:00
description = S("Sensor Extender"),
2020-05-31 23:31:18 +03:00
drawtype = "nodebox",
node_box = {
type = "connected",
fixed = {
{-6/32, -1/2, -6/32, 6/32, -5/16, 6/32},
},
connect_front = {{-1/16, -1/2, -12/16, 1/16, -6/16, 1/16}},
connect_left = {{-12/16, -1/2, -1/16, 1/16, -6/16, 1/16}},
connect_back = {{-1/16, -1/2, -1/16, 1/16, -6/16, 12/16}},
connect_right = {{-1/16, -1/2, -1/16, 12/16, -6/16, 1/16}},
},
connects_to = {"group:sign_bot_sensor"},
tiles = {
-- up, down, right, left, back, front
"signs_bot_extender_on.png",
"signs_bot_extender.png",
"signs_bot_extender_side.png",
"signs_bot_extender_side.png",
"signs_bot_extender_side.png",
"signs_bot_extender_side.png",
},
2022-09-24 12:01:30 +03:00
2020-05-31 23:31:18 +03:00
-- Called from the Sensor beside
after_place_node = function(pos)
minetest.get_node_timer(pos):start(1)
signs_bot.send_signal(pos)
signs_bot.lib.activate_extender_nodes(pos)
end,
2022-09-24 12:01:30 +03:00
2020-05-31 23:31:18 +03:00
on_timer = function(pos)
2021-02-07 16:37:07 +03:00
local node = tubelib2.get_node_lvm(pos)
2020-05-31 23:31:18 +03:00
node.name = "signs_bot:sensor_extender"
minetest.swap_node(pos, node)
return false
end,
2022-09-24 12:01:30 +03:00
2020-05-31 23:31:18 +03:00
update_infotext = update_infotext,
on_rotate = screwdriver.disallow,
paramtype = "light",
2021-05-14 19:50:16 +03:00
use_texture_alpha = signs_bot.CLIP,
2020-05-31 23:31:18 +03:00
sunlight_propagates = true,
paramtype2 = "facedir",
is_ground_content = false,
diggable = false,
groups = {sign_bot_sensor = 1, not_in_creative_inventory = 1},
sounds = default.node_sound_metal_defaults(),
})
minetest.register_craft({
output = "signs_bot:sensor_extender",
recipe = {
{"group:wood", "dye:yellow"},
{"default:mese_crystal_fragment", "default:steel_ingot"}
}
})
if minetest.get_modpath("doc") then
doc.add_entry("signs_bot", "sensor_extender", {
2021-05-14 19:50:16 +03:00
name = S("Sensor Extender"),
2020-05-31 23:31:18 +03:00
data = {
item = "signs_bot:sensor_extender",
text = table.concat({
2021-05-14 19:50:16 +03:00
S("With the Sensor Extender, sensor signals can be sent to more than one actuator."),
2022-09-24 12:01:30 +03:00
S("Place one or more extender nearby the sensor and connect each extender"),
S("with one further actuator by means of the Connection Tool."),
}, "\n")
2020-05-31 23:31:18 +03:00
},
})
end