2019-01-02 12:51:57 +01:00
|
|
|
--[[
|
|
|
|
|
|
|
|
Tubelib Addons 2
|
|
|
|
================
|
|
|
|
|
2020-11-20 14:45:28 +01:00
|
|
|
Copyright (C) 2017-2020 Joachim Stolberg
|
2019-01-02 12:51:57 +01:00
|
|
|
|
2020-11-20 14:45:28 +01:00
|
|
|
AGPL v3
|
2019-01-02 12:51:57 +01:00
|
|
|
See LICENSE.txt for more information
|
|
|
|
|
|
|
|
industriallamp.lua:
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
]]--
|
|
|
|
|
2020-11-03 20:19:38 +01:00
|
|
|
-- Load support for I18n
|
|
|
|
local S = tubelib_addons2.S
|
|
|
|
|
2019-02-27 18:47:11 +01:00
|
|
|
local function switch_on(pos, node)
|
|
|
|
if string.sub(node.name, -3) ~= "_on" then
|
|
|
|
node.name = node.name.."_on"
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
end
|
2022-06-09 23:49:50 +02:00
|
|
|
end
|
2019-02-27 18:47:11 +01:00
|
|
|
|
|
|
|
local function switch_off(pos, node)
|
|
|
|
if string.sub(node.name, -3) == "_on" then
|
|
|
|
node.name = string.sub(node.name, 1, -4)
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
local pos1 = {x=pos.x-5, y=pos.y-5, z=pos.z-5}
|
|
|
|
local pos2 = {x=pos.x+5, y=pos.y+5, z=pos.z+5}
|
|
|
|
minetest.fix_light(pos1, pos2)
|
|
|
|
end
|
2022-06-09 23:49:50 +02:00
|
|
|
end
|
2019-02-27 18:47:11 +01:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
local function register_lamp(tbl)
|
|
|
|
local num, tiles, tiles_on, node_box, size = tbl.num, tbl.tiles, tbl.tiles_on, tbl.node_box, tbl.size
|
|
|
|
minetest.register_node("tubelib_addons2:industriallamp"..num, {
|
2020-11-03 20:19:38 +01:00
|
|
|
description = S("Tubelib Industrial Lamp").." "..num,
|
2019-01-02 12:51:57 +01:00
|
|
|
tiles = tiles,
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = node_box,
|
|
|
|
inventory_image = 'tubelib_addons2_industriallamp_inv'..num..'.png',
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
wall_top = {-size.x, 0.5 - size.y, -size.z, size.x, 0.5, size.z},
|
|
|
|
wall_bottom = {-size.x, -0.5, -size.z, size.x, -0.5 + size.y, size.z},
|
|
|
|
wall_side = {-0.5, -size.z, size.x, -0.5 + size.y, size.z, -size.x},
|
|
|
|
},
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local number = tubelib.add_node(pos, "tubelib_addons2:industriallamp"..num)
|
|
|
|
local meta = minetest.get_meta(pos)
|
2020-11-03 20:19:38 +01:00
|
|
|
meta:set_string("infotext", S("Tubelib Industrial Lamp").." "..num..": "..number)
|
2019-01-02 12:51:57 +01:00
|
|
|
end,
|
|
|
|
|
|
|
|
on_rightclick = function(pos, node, clicker)
|
|
|
|
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
|
|
|
node.name = "tubelib_addons2:industriallamp"..num.."_on"
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
|
|
|
after_dig_node = function(pos)
|
|
|
|
tubelib.remove_node(pos)
|
|
|
|
end,
|
|
|
|
|
|
|
|
paramtype = "light",
|
2022-06-09 23:49:50 +02:00
|
|
|
light_source = 0,
|
2019-01-02 12:51:57 +01:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
groups = {choppy=2, cracky=2, crumbly=2},
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_glass_defaults(),
|
2022-06-09 23:49:50 +02:00
|
|
|
on_blast = function() end,
|
2019-01-02 12:51:57 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_node("tubelib_addons2:industriallamp"..num.."_on", {
|
2020-11-03 20:19:38 +01:00
|
|
|
description = S("Tubelib Industrial Lamp").." "..num,
|
2019-01-02 12:51:57 +01:00
|
|
|
tiles = tiles_on,
|
|
|
|
drawtype = "nodebox",
|
|
|
|
node_box = node_box,
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
selection_box = {
|
|
|
|
type = "wallmounted",
|
|
|
|
wall_top = {-size.x, 0.5 - size.y, -size.z, size.x, 0.5, size.z},
|
|
|
|
wall_bottom = {-size.x, -0.5, -size.z, size.x, -0.5 + size.y, size.z},
|
|
|
|
wall_side = {-0.5, -size.z, size.x, -0.5 + size.y, size.z, -size.x},
|
|
|
|
},
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
after_place_node = function(pos, placer)
|
|
|
|
local number = tubelib.add_node(pos, "tubelib_addons2:industriallamp"..num)
|
|
|
|
local meta = minetest.get_meta(pos)
|
2020-11-03 20:19:38 +01:00
|
|
|
meta:set_string("infotext", S("Tubelib Industrial Lamp").." "..num..": "..number)
|
2019-01-02 12:51:57 +01:00
|
|
|
end,
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
on_rightclick = function(pos, node, clicker)
|
|
|
|
if not minetest.is_protected(pos, clicker:get_player_name()) then
|
|
|
|
node.name = "tubelib_addons2:industriallamp"..num
|
|
|
|
minetest.swap_node(pos, node)
|
|
|
|
local pos1 = {x=pos.x-5, y=pos.y-5, z=pos.z-5}
|
|
|
|
local pos2 = {x=pos.x+5, y=pos.y+5, z=pos.z+5}
|
|
|
|
minetest.fix_light(pos1, pos2)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
|
2019-01-06 15:03:22 +01:00
|
|
|
after_dig_node = function(pos)
|
|
|
|
tubelib.remove_node(pos)
|
|
|
|
end,
|
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
paramtype = "light",
|
2022-06-09 23:49:50 +02:00
|
|
|
light_source = minetest.LIGHT_MAX,
|
2019-01-02 12:51:57 +01:00
|
|
|
sunlight_propagates = true,
|
|
|
|
paramtype2 = "wallmounted",
|
|
|
|
groups = {choppy=2, cracky=2, crumbly=2, not_in_creative_inventory=1},
|
|
|
|
drop = "tubelib_addons2:industriallamp"..num,
|
|
|
|
is_ground_content = false,
|
|
|
|
sounds = default.node_sound_glass_defaults(),
|
2022-06-09 23:49:50 +02:00
|
|
|
on_blast = function() end,
|
2019-01-02 12:51:57 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
tubelib.register_node("tubelib_addons2:industriallamp"..num, {"tubelib_addons2:industriallamp"..num.."_on"}, {
|
|
|
|
on_recv_message = function(pos, topic, payload)
|
|
|
|
local node = minetest.get_node(pos)
|
|
|
|
if topic == "on" then
|
|
|
|
switch_on(pos, node)
|
|
|
|
elseif topic == "off" then
|
|
|
|
switch_off(pos, node)
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "tubelib_addons2:industriallamp1 2",
|
|
|
|
recipe = {
|
|
|
|
{"", "", ""},
|
|
|
|
{"default:glass", "tubelib:wlanchip", "dye:grey"},
|
|
|
|
{"basic_materials:plastic_strip", "default:copper_ingot", "basic_materials:plastic_strip"},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
minetest.register_craft({
|
|
|
|
output = "tubelib_addons2:industriallamp2 2",
|
|
|
|
recipe = {
|
|
|
|
{"default:glass", "default:glass", ""},
|
|
|
|
{"tubelib:wlanchip", "dye:black", ""},
|
|
|
|
{"basic_materials:steel_bar", "basic_materials:steel_bar", ""},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
register_lamp({
|
2022-06-09 23:49:50 +02:00
|
|
|
num = 1,
|
2019-01-02 12:51:57 +01:00
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
'tubelib_addons2_industriallamp1.png',
|
|
|
|
'tubelib_addons2_industriallamp1.png',
|
|
|
|
'tubelib_addons2_industriallamp1.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp1.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp1.png',
|
|
|
|
'tubelib_addons2_industriallamp1.png',
|
|
|
|
},
|
|
|
|
tiles_on = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
'tubelib_addons2_industriallamp1_on.png',
|
|
|
|
'tubelib_addons2_industriallamp1_on.png',
|
|
|
|
'tubelib_addons2_industriallamp1_on.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp1_on.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp1_on.png',
|
|
|
|
'tubelib_addons2_industriallamp1_on.png',
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-8/16, -8/16, -3/32, -6/16, -9/32, 3/32},
|
|
|
|
{ 6/16, -8/16, -3/32, 8/16, -9/32, 3/32},
|
|
|
|
{-6/16, -7/16, -1/16, 6/16, -5/16, 1/16},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
size = {x = 8/16, y = 7/32, z = 3/32}
|
|
|
|
})
|
2022-06-09 23:49:50 +02:00
|
|
|
|
2019-01-02 12:51:57 +01:00
|
|
|
register_lamp({
|
2022-06-09 23:49:50 +02:00
|
|
|
num = 2,
|
2019-01-02 12:51:57 +01:00
|
|
|
tiles = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
'tubelib_addons2_industriallamp2.png',
|
|
|
|
'tubelib_addons2_industriallamp2.png',
|
|
|
|
'tubelib_addons2_industriallamp2.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp2.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp2.png',
|
|
|
|
'tubelib_addons2_industriallamp2.png',
|
|
|
|
},
|
|
|
|
tiles_on = {
|
|
|
|
-- up, down, right, left, back, front
|
|
|
|
'tubelib_addons2_industriallamp2_on.png',
|
|
|
|
'tubelib_addons2_industriallamp2_on.png',
|
|
|
|
'tubelib_addons2_industriallamp2_on.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp2_on.png^[transformR180',
|
|
|
|
'tubelib_addons2_industriallamp2_on.png',
|
|
|
|
'tubelib_addons2_industriallamp2_on.png',
|
|
|
|
},
|
|
|
|
node_box = {
|
|
|
|
type = "fixed",
|
|
|
|
fixed = {
|
|
|
|
{-8/32, -16/32, -4/32, 8/32, -9/32, 4/32},
|
|
|
|
{-7/32, -16/32, -5/32, 7/32, -9/32, 5/32},
|
|
|
|
{-7/32, -9/32, -4/32, 7/32, -8/32, 4/32},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
size = {x = 8/32, y = 8/32, z = 5/32}
|
|
|
|
})
|