mirror of
https://github.com/minetest-mods/technic.git
synced 2024-12-22 05:42:33 +01:00
Unify and simplify LED/Lamp node definition
This commit is contained in:
parent
d623715d94
commit
4775d98fb7
@ -84,21 +84,12 @@ local function lamp_toggle(pos, node, player)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:lv_lamp", {
|
local common_fields = {
|
||||||
description = desc,
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {0.5,0.5,0.5,-0.5,-0.2,-0.5}
|
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 = {
|
tiles = {
|
||||||
"technic_lv_lamp_top.png",
|
"technic_lv_lamp_top.png",
|
||||||
"technic_lv_lamp_bottom.png",
|
"technic_lv_lamp_bottom.png",
|
||||||
@ -107,56 +98,50 @@ minetest.register_node("technic:lv_lamp", {
|
|||||||
"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"},
|
connect_sides = {"front", "back", "left", "right", "top"},
|
||||||
can_dig = technic.machine_can_dig,
|
can_dig = technic.machine_can_dig,
|
||||||
technic_run = lamp_run,
|
technic_run = lamp_run,
|
||||||
|
on_destruct = illuminate,
|
||||||
|
on_rightclick = lamp_toggle
|
||||||
|
}
|
||||||
|
|
||||||
|
local ndef
|
||||||
|
|
||||||
|
ndef = {
|
||||||
|
description = desc,
|
||||||
|
groups = {cracky = 2, technic_machine = 1, technic_lv = 1},
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", desc)
|
meta:set_string("infotext", desc)
|
||||||
meta:set_int("LV_EU_demand", demand)
|
meta:set_int("LV_EU_demand", demand)
|
||||||
end,
|
end
|
||||||
on_destruct = illuminate,
|
}
|
||||||
on_rightclick = lamp_toggle
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("technic:lv_lamp_active", {
|
for k, v in pairs(common_fields) do
|
||||||
|
ndef[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:lv_lamp", ndef)
|
||||||
|
|
||||||
|
|
||||||
|
ndef = {
|
||||||
description = active_desc,
|
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",
|
paramtype = "light",
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
drop = "technic:lv_lamp",
|
drop = "technic:lv_lamp",
|
||||||
groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1},
|
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)
|
technic_on_disable = function(pos)
|
||||||
illuminate(pos, false)
|
illuminate(pos, false)
|
||||||
technic.swap_node(pos, "technic:lv_lamp")
|
technic.swap_node(pos, "technic:lv_lamp")
|
||||||
end,
|
end,
|
||||||
on_destruct = illuminate,
|
}
|
||||||
on_rightclick = lamp_toggle,
|
|
||||||
})
|
for k, v in pairs(common_fields) do
|
||||||
|
ndef[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:lv_lamp_active", ndef)
|
||||||
|
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:lv_lamp", technic.receiver)
|
technic.register_machine("LV", "technic:lv_lamp", technic.receiver)
|
||||||
technic.register_machine("LV", "technic:lv_lamp_active", technic.receiver)
|
technic.register_machine("LV", "technic:lv_lamp_active", technic.receiver)
|
||||||
|
@ -22,21 +22,12 @@ local function led_run(pos, node)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("technic:lv_led", {
|
local common_fields = {
|
||||||
description = desc,
|
|
||||||
drawtype = "nodebox",
|
drawtype = "nodebox",
|
||||||
node_box = {
|
node_box = {
|
||||||
type = "fixed",
|
type = "fixed",
|
||||||
fixed = {0.5, 0.5, 0.5, -0.5, 0.3, -0.5}
|
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 = {
|
tiles = {
|
||||||
"technic_lv_led_top.png",
|
"technic_lv_led_top.png",
|
||||||
"technic_lv_led.png",
|
"technic_lv_led.png",
|
||||||
@ -45,55 +36,51 @@ minetest.register_node("technic:lv_led", {
|
|||||||
"technic_lv_led_side2.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"},
|
connect_sides = {"front", "back", "left", "right", "top", "bottom"},
|
||||||
can_dig = technic.machine_can_dig,
|
can_dig = technic.machine_can_dig,
|
||||||
technic_run = led_run,
|
technic_run = led_run,
|
||||||
|
}
|
||||||
|
|
||||||
|
local ndef
|
||||||
|
|
||||||
|
ndef = {
|
||||||
|
description = desc,
|
||||||
|
inventory_image = "technic_lv_led_inv.png",
|
||||||
|
sunlight_propagates = true,
|
||||||
|
groups = {cracky = 2, technic_machine = 1, technic_lv = 1},
|
||||||
|
|
||||||
on_construct = function(pos)
|
on_construct = function(pos)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string("infotext", desc)
|
meta:set_string("infotext", desc)
|
||||||
meta:set_int("LV_EU_demand", demand)
|
meta:set_int("LV_EU_demand", demand)
|
||||||
end,
|
end,
|
||||||
})
|
}
|
||||||
|
|
||||||
minetest.register_node("technic:lv_led_active", {
|
for k, v in pairs(common_fields) do
|
||||||
|
ndef[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:lv_led", ndef)
|
||||||
|
|
||||||
|
|
||||||
|
ndef = {
|
||||||
description = active_desc,
|
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",
|
paramtype = "light",
|
||||||
light_source = 9,
|
light_source = 9,
|
||||||
drop = "technic:lv_led",
|
drop = "technic:lv_led",
|
||||||
sunlight_propagates = true,
|
|
||||||
groups = {cracky = 2, technic_machine = 1, technic_lv = 1, not_in_creative_inventory = 1},
|
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_on_disable = function(pos)
|
||||||
technic.swap_node(pos, "technic:lv_led")
|
technic.swap_node(pos, "technic:lv_led")
|
||||||
end,
|
end,
|
||||||
})
|
}
|
||||||
|
|
||||||
|
for k, v in pairs(common_fields) do
|
||||||
|
ndef[k] = v
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_node("technic:lv_led_active", ndef)
|
||||||
|
|
||||||
|
|
||||||
technic.register_machine("LV", "technic:lv_led", technic.receiver)
|
technic.register_machine("LV", "technic:lv_led", technic.receiver)
|
||||||
technic.register_machine("LV", "technic:lv_led_active", technic.receiver)
|
technic.register_machine("LV", "technic:lv_led_active", technic.receiver)
|
||||||
|
Loading…
Reference in New Issue
Block a user