Add LV led and lamp
@ -1 +1,3 @@
|
||||
name = technic
|
||||
description = technic
|
||||
min_minetest_version = 5.0
|
||||
|
@ -22,3 +22,6 @@ dofile(path.."/extractor.lua")
|
||||
dofile(path.."/compressor.lua")
|
||||
|
||||
dofile(path.."/music_player.lua")
|
||||
-- NEW LV LAMPS
|
||||
dofile(path.."/led.lua")
|
||||
dofile(path.."/lamp.lua")
|
||||
|
171
technic/machines/LV/lamp.lua
Normal file
@ -0,0 +1,171 @@
|
||||
|
||||
-- LV Lamp
|
||||
-- Illuminates a 7x7x3(H) volume below itself with light bright as the sun.
|
||||
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local desc = S("@1 Lamp", S("LV"))
|
||||
local active_desc = S("@1 Active", desc)
|
||||
local unpowered_desc = S("@1 Unpowered", desc)
|
||||
local off_desc = S("@1 Off", desc)
|
||||
local demand = 50
|
||||
|
||||
|
||||
-- Invisible light source node used for illumination
|
||||
minetest.register_node("technic:dummy_light_source", {
|
||||
description = S("Dummy light source node"),
|
||||
inventory_image = "technic_dummy_light_source.png",
|
||||
wield_image = "technic_dummy_light_source.png",
|
||||
paramtype = "light",
|
||||
drawtype = "airlike",
|
||||
light_source = 14,
|
||||
sunlight_propagates = true,
|
||||
walkable = false,
|
||||
buildable_to = true,
|
||||
diggable = false,
|
||||
pointable = false,
|
||||
--drop = "", -- Intentionally allowed to drop itself
|
||||
groups = {not_in_creative_inventory = 1}
|
||||
})
|
||||
|
||||
|
||||
local function illuminate(pos, active)
|
||||
local pos1 = {x = pos.x - 3, y = pos.y - 1, z = pos.z - 3}
|
||||
local pos2 = {x = pos.x + 3, y = pos.y - 3, z = pos.z + 3}
|
||||
|
||||
local find_node = active and "air" or "technic:dummy_light_source"
|
||||
local set_node = {name = (active and "technic:dummy_light_source" or "air")}
|
||||
|
||||
for _,p in pairs(minetest.find_nodes_in_area(pos1, pos2, find_node)) do
|
||||
minetest.set_node(p, set_node)
|
||||
end
|
||||
end
|
||||
|
||||
local function lamp_run(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
if meta:get_int("LV_EU_demand") == 0 then
|
||||
return -- Lamp is turned off
|
||||
end
|
||||
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
|
||||
if node.name == "technic:lv_lamp_active" then
|
||||
if eu_input < demand then
|
||||
technic.swap_node(pos, "technic:lv_lamp")
|
||||
meta:set_string("infotext", unpowered_desc)
|
||||
illuminate(pos, false)
|
||||
else
|
||||
illuminate(pos, true)
|
||||
end
|
||||
elseif node.name == "technic:lv_lamp" then
|
||||
if eu_input >= demand then
|
||||
technic.swap_node(pos, "technic:lv_lamp_active")
|
||||
meta:set_string("infotext", active_desc)
|
||||
illuminate(pos, true)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function lamp_toggle(pos, node, player)
|
||||
if not player or minetest.is_protected(pos, player:get_player_name()) then
|
||||
return
|
||||
end
|
||||
local meta = minetest.get_meta(pos)
|
||||
if meta:get_int("LV_EU_demand") == 0 then
|
||||
meta:set_string("infotext", active_desc)
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
else
|
||||
illuminate(pos, false)
|
||||
technic.swap_node(pos, "technic:lv_lamp")
|
||||
meta:set_string("infotext", off_desc)
|
||||
meta:set_int("LV_EU_demand", 0)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:lv_lamp", {
|
||||
description = desc,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5}
|
||||
},
|
||||
tiles = {
|
||||
"technic_lv_lamp_top.png",
|
||||
"technic_lv_lamp_bottom.png",
|
||||
"technic_lv_lamp_side.png",
|
||||
"technic_lv_lamp_side.png",
|
||||
"technic_lv_lamp_side.png",
|
||||
"technic_lv_lamp_side.png"
|
||||
},
|
||||
groups = {cracky = 2, technic_machine = 1, technic_lv = 1},
|
||||
connect_sides = {"front", "back", "left", "right", "top"},
|
||||
can_dig = technic.machine_can_dig,
|
||||
technic_run = lamp_run,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", desc)
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
end,
|
||||
on_destruct = illuminate,
|
||||
on_rightclick = lamp_toggle
|
||||
})
|
||||
|
||||
minetest.register_node("technic:lv_lamp_active", {
|
||||
description = active_desc,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, -0.2, -0.5}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, -0.2, -0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, -0.2, -0.5}
|
||||
},
|
||||
tiles = {
|
||||
"technic_lv_lamp_top.png",
|
||||
"technic_lv_lamp_bottom.png",
|
||||
"technic_lv_lamp_side.png",
|
||||
"technic_lv_lamp_side.png",
|
||||
"technic_lv_lamp_side.png",
|
||||
"technic_lv_lamp_side.png"
|
||||
},
|
||||
paramtype = "light",
|
||||
light_source = 14,
|
||||
drop = "technic:lv_lamp",
|
||||
groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1},
|
||||
connect_sides = {"front", "back", "left", "right", "top"},
|
||||
can_dig = technic.machine_can_dig,
|
||||
technic_run = lamp_run,
|
||||
technic_on_disable = function(pos)
|
||||
illuminate(pos, false)
|
||||
technic.swap_node(pos, "technic:lv_lamp")
|
||||
end,
|
||||
on_destruct = illuminate,
|
||||
on_rightclick = lamp_toggle,
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:lv_lamp", technic.receiver)
|
||||
technic.register_machine("LV", "technic:lv_lamp_active", technic.receiver)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "technic:lv_lamp",
|
||||
recipe = {
|
||||
{"default:glass", "default:glass", "default:glass"},
|
||||
{"technic:lv_led", "technic:lv_led", "technic:lv_led"},
|
||||
{"mesecons_materials:glue", "technic:lv_cable", "mesecons_materials:glue"},
|
||||
}
|
||||
})
|
108
technic/machines/LV/led.lua
Normal file
@ -0,0 +1,108 @@
|
||||
-- LED
|
||||
-- Intended primarily as a core component for LED lamps.
|
||||
|
||||
local S = technic.getter
|
||||
|
||||
local desc = S("@1 LED", S("LV"))
|
||||
local active_desc = S("@1 Active", desc)
|
||||
local unpowered_desc = S("@1 Unpowered", desc)
|
||||
local demand = 5
|
||||
|
||||
|
||||
local function led_run(pos, node)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local eu_input = meta:get_int("LV_EU_input")
|
||||
|
||||
if eu_input < demand and node.name == "technic:lv_led_active" then
|
||||
technic.swap_node(pos, "technic:lv_led")
|
||||
meta:set_string("infotext", unpowered_desc)
|
||||
elseif eu_input >= demand and node.name == "technic:lv_led" then
|
||||
technic.swap_node(pos, "technic:lv_led_active")
|
||||
meta:set_string("infotext", active_desc)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_node("technic:lv_led", {
|
||||
description = desc,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
||||
},
|
||||
tiles = {
|
||||
"technic_lv_led_top.png",
|
||||
"technic_lv_led.png",
|
||||
"technic_lv_led_side.png",
|
||||
"technic_lv_led_side2.png",
|
||||
"technic_lv_led_side2.png",
|
||||
"technic_lv_led_side2.png",
|
||||
},
|
||||
inventory_image = "technic_lv_led_inv.png",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky = 2, technic_machine = 1, technic_lv = 1},
|
||||
connect_sides = {"front", "back", "left", "right", "top", "bottom"},
|
||||
can_dig = technic.machine_can_dig,
|
||||
technic_run = led_run,
|
||||
on_construct = function(pos)
|
||||
local meta = minetest.get_meta(pos)
|
||||
meta:set_string("infotext", desc)
|
||||
meta:set_int("LV_EU_demand", demand)
|
||||
end,
|
||||
})
|
||||
|
||||
minetest.register_node("technic:lv_led_active", {
|
||||
description = active_desc,
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
||||
},
|
||||
collision_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
||||
},
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
||||
},
|
||||
tiles = {
|
||||
"technic_lv_led_top.png",
|
||||
"technic_lv_led.png",
|
||||
"technic_lv_led_side.png",
|
||||
"technic_lv_led_side2.png",
|
||||
"technic_lv_led_side2.png",
|
||||
"technic_lv_led_side2.png",
|
||||
},
|
||||
inventory_image = "technic_lv_led_inv.png",
|
||||
paramtype = "light",
|
||||
light_source = 9,
|
||||
drop = "technic:lv_led",
|
||||
sunlight_propagates = true,
|
||||
groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1},
|
||||
connect_sides = {"front", "back", "left", "right", "top", "bottom"},
|
||||
can_dig = technic.machine_can_dig,
|
||||
technic_run = led_run,
|
||||
technic_on_disable = function(pos)
|
||||
technic.swap_node(pos, "technic:lv_led")
|
||||
end,
|
||||
})
|
||||
|
||||
technic.register_machine("LV", "technic:lv_led", technic.receiver)
|
||||
technic.register_machine("LV", "technic:lv_led_active", technic.receiver)
|
||||
|
||||
minetest.register_craft({
|
||||
output = "technic:lv_led 2",
|
||||
recipe = {
|
||||
{"", "homedecor:plastic_sheeting", ""},
|
||||
{"homedecor:plastic_sheeting", "technic:doped_silicon_wafer", "homedecor:plastic_sheeting"},
|
||||
{"", "technic:fine_silver_wire", ""},
|
||||
}
|
||||
})
|
BIN
technic/textures/technic_lv_lamp_bottom.png
Normal file
After Width: | Height: | Size: 995 B |
BIN
technic/textures/technic_lv_lamp_side.png
Normal file
After Width: | Height: | Size: 1014 B |
BIN
technic/textures/technic_lv_lamp_top.png
Normal file
After Width: | Height: | Size: 466 B |
BIN
technic/textures/technic_lv_led.png
Normal file
After Width: | Height: | Size: 738 B |
BIN
technic/textures/technic_lv_led_inv.png
Normal file
After Width: | Height: | Size: 429 B |
BIN
technic/textures/technic_lv_led_side.png
Normal file
After Width: | Height: | Size: 245 B |
BIN
technic/textures/technic_lv_led_side2.png
Normal file
After Width: | Height: | Size: 253 B |
BIN
technic/textures/technic_lv_led_top.png
Normal file
After Width: | Height: | Size: 466 B |