Refactor laser blocks
parent
c97838477f
commit
b6d29a4444
|
@ -100,10 +100,31 @@ local after_rotate = function()
|
||||||
full_update()
|
full_update()
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_node("lzr_laser:mirror", {
|
local register_element = function(subname, def)
|
||||||
|
local def_core = table.copy(def)
|
||||||
|
def_core.after_place_node = full_update
|
||||||
|
def_core.after_dig_node = full_update
|
||||||
|
def_core.after_rotate = after_rotate
|
||||||
|
def_core.sounds = lzr_sounds.node_sound_wood_defaults()
|
||||||
|
def_core._lzr_active = "lzr_laser:"..subname.."_on"
|
||||||
|
def_core.tiles = def.tiles_off
|
||||||
|
def_core.groups[subname] = 1
|
||||||
|
|
||||||
|
local def_on = table.copy(def_core)
|
||||||
|
def_on._lzr_active = nil
|
||||||
|
def_on._lzr_inactive = "lzr_laser:"..subname
|
||||||
|
def_on.tiles = def.tiles_on
|
||||||
|
def_on.drop = "lzr_laser:"..subname
|
||||||
|
def_on.groups[subname] = 2
|
||||||
|
|
||||||
|
minetest.register_node("lzr_laser:"..subname, def_core)
|
||||||
|
minetest.register_node("lzr_laser:"..subname.."_on", def_on)
|
||||||
|
end
|
||||||
|
|
||||||
|
register_element("mirror", {
|
||||||
description = S("Mirror"),
|
description = S("Mirror"),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {
|
tiles_off = {
|
||||||
"lzr_laser_mirror_top.png",
|
"lzr_laser_mirror_top.png",
|
||||||
"lzr_laser_mirror_top.png^[transformFY",
|
"lzr_laser_mirror_top.png^[transformFY",
|
||||||
"lzr_laser_mirror_hole.png",
|
"lzr_laser_mirror_hole.png",
|
||||||
|
@ -111,20 +132,7 @@ minetest.register_node("lzr_laser:mirror", {
|
||||||
"lzr_laser_mirror_block.png",
|
"lzr_laser_mirror_block.png",
|
||||||
"lzr_laser_mirror_hole.png",
|
"lzr_laser_mirror_hole.png",
|
||||||
},
|
},
|
||||||
|
tiles_on = {
|
||||||
after_place_node = full_update,
|
|
||||||
after_dig_node = full_update,
|
|
||||||
after_rotate = after_rotate,
|
|
||||||
|
|
||||||
sounds = lzr_sounds.node_sound_wood_defaults(),
|
|
||||||
groups = { rotatable = 1, mirror = 1, laser_block = 1, dig_immediate = 3 },
|
|
||||||
_lzr_active = "lzr_laser:mirror_on",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("lzr_laser:mirror_on", {
|
|
||||||
description = S("Mirror (active)"),
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
tiles = {
|
|
||||||
"lzr_laser_mirror_on_top.png",
|
"lzr_laser_mirror_on_top.png",
|
||||||
"lzr_laser_mirror_on_top.png^[transformFY",
|
"lzr_laser_mirror_on_top.png^[transformFY",
|
||||||
"lzr_laser_mirror_on_hole.png",
|
"lzr_laser_mirror_on_hole.png",
|
||||||
|
@ -132,20 +140,13 @@ minetest.register_node("lzr_laser:mirror_on", {
|
||||||
"lzr_laser_mirror_on_block.png",
|
"lzr_laser_mirror_on_block.png",
|
||||||
"lzr_laser_mirror_on_hole.png",
|
"lzr_laser_mirror_on_hole.png",
|
||||||
},
|
},
|
||||||
after_place_node = full_update,
|
groups = { rotatable = 1, laser_block = 1, dig_immediate = 3 },
|
||||||
after_dig_node = full_update,
|
|
||||||
after_rotate = after_rotate,
|
|
||||||
|
|
||||||
sounds = lzr_sounds.node_sound_wood_defaults(),
|
|
||||||
groups = { rotatable = 1, mirror = 2, laser_block = 1, dig_immediate = 3, not_in_creative_inventory = 1 },
|
|
||||||
_lzr_inactive = "lzr_laser:mirror",
|
|
||||||
drop = "lzr_laser:mirror",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("lzr_laser:emitter", {
|
register_element("emitter", {
|
||||||
description = S("Emitter"),
|
description = S("Emitter"),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {
|
tiles_off = {
|
||||||
"lzr_laser_emitter.png",
|
"lzr_laser_emitter.png",
|
||||||
"lzr_laser_emitter.png",
|
"lzr_laser_emitter.png",
|
||||||
"lzr_laser_emitter.png",
|
"lzr_laser_emitter.png",
|
||||||
|
@ -153,57 +154,42 @@ minetest.register_node("lzr_laser:emitter", {
|
||||||
"lzr_laser_emitter.png",
|
"lzr_laser_emitter.png",
|
||||||
"lzr_laser_emitter_front.png",
|
"lzr_laser_emitter_front.png",
|
||||||
},
|
},
|
||||||
after_place_node = full_update,
|
tiles_on = {
|
||||||
after_dig_node = full_update,
|
|
||||||
after_rotate = after_rotate,
|
|
||||||
|
|
||||||
on_rightclick = function(pos, node)
|
|
||||||
minetest.swap_node(pos, {name="lzr_laser:emitter_on", param2=node.param2})
|
|
||||||
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
|
|
||||||
end,
|
|
||||||
on_punch = function(pos, node)
|
|
||||||
minetest.swap_node(pos, {name="lzr_laser:emitter_on", param2=node.param2})
|
|
||||||
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
|
|
||||||
end,
|
|
||||||
|
|
||||||
sounds = lzr_sounds.node_sound_wood_defaults(),
|
|
||||||
groups = { emitter = 1, laser_block = 1, choppy = 3 },
|
|
||||||
_lzr_active = "lzr_laser:emitter_on",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("lzr_laser:emitter_on", {
|
|
||||||
description = S("Emitter (active)"),
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
tiles = {
|
|
||||||
"lzr_laser_emitter_on.png",
|
"lzr_laser_emitter_on.png",
|
||||||
"lzr_laser_emitter_on.png",
|
"lzr_laser_emitter_on.png",
|
||||||
"lzr_laser_emitter_on.png",
|
"lzr_laser_emitter_on.png",
|
||||||
"lzr_laser_emitter_on.png",
|
"lzr_laser_emitter_on.png",
|
||||||
"lzr_laser_emitter_on.png",
|
"lzr_laser_emitter_on.png",
|
||||||
"lzr_laser_emitter_on_front.png",
|
"lzr_laser_emitter_on_front.png",
|
||||||
},
|
|
||||||
after_place_node = full_update,
|
|
||||||
after_dig_node = full_update,
|
|
||||||
after_rotate = after_rotate,
|
|
||||||
|
|
||||||
|
},
|
||||||
on_rightclick = function(pos, node)
|
on_rightclick = function(pos, node)
|
||||||
minetest.swap_node(pos, {name="lzr_laser:emitter", param2=node.param2})
|
local nname
|
||||||
|
if node.name == "lzr_laser:emitter" then
|
||||||
|
nname = "lzr_laser:emitter_on"
|
||||||
|
else
|
||||||
|
nname = "lzr_laser:emitter"
|
||||||
|
end
|
||||||
|
minetest.swap_node(pos, {name=nname, param2=node.param2})
|
||||||
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
|
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
|
||||||
end,
|
end,
|
||||||
on_punch = function(pos, node)
|
on_punch = function(pos, node)
|
||||||
minetest.swap_node(pos, {name="lzr_laser:emitter", param2=node.param2})
|
local nname
|
||||||
|
if node.name == "lzr_laser:emitter" then
|
||||||
|
nname = "lzr_laser:emitter_on"
|
||||||
|
else
|
||||||
|
nname = "lzr_laser:emitter"
|
||||||
|
end
|
||||||
|
minetest.swap_node(pos, {name=nname, param2=node.param2})
|
||||||
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
|
lzr_laser.full_laser_update(lzr_globals.PLAYFIELD_START, lzr_globals.PLAYFIELD_END)
|
||||||
end,
|
end,
|
||||||
|
groups = { laser_block = 1 },
|
||||||
sounds = lzr_sounds.node_sound_wood_defaults(),
|
|
||||||
groups = { emitter = 2, laser_block = 1, choppy = 3 },
|
|
||||||
_lzr_inactive = "lzr_laser:emitter",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_node("lzr_laser:detector", {
|
register_element("detector", {
|
||||||
description = S("Detector"),
|
description = S("Detector"),
|
||||||
paramtype2 = "facedir",
|
paramtype2 = "facedir",
|
||||||
tiles = {
|
tiles_off = {
|
||||||
"lzr_laser_detector.png",
|
"lzr_laser_detector.png",
|
||||||
"lzr_laser_detector.png",
|
"lzr_laser_detector.png",
|
||||||
"lzr_laser_detector.png",
|
"lzr_laser_detector.png",
|
||||||
|
@ -211,19 +197,7 @@ minetest.register_node("lzr_laser:detector", {
|
||||||
"lzr_laser_detector.png",
|
"lzr_laser_detector.png",
|
||||||
"lzr_laser_detector_front.png",
|
"lzr_laser_detector_front.png",
|
||||||
},
|
},
|
||||||
after_place_node = full_update,
|
tiles_on = {
|
||||||
after_dig_node = full_update,
|
|
||||||
after_rotate = after_rotate,
|
|
||||||
|
|
||||||
sounds = lzr_sounds.node_sound_wood_defaults(),
|
|
||||||
groups = { detector = 1, laser_block = 1, choppy = 3 },
|
|
||||||
_lzr_active = "lzr_laser:detector_on",
|
|
||||||
})
|
|
||||||
|
|
||||||
minetest.register_node("lzr_laser:detector_on", {
|
|
||||||
description = S("Detector (active)"),
|
|
||||||
paramtype2 = "facedir",
|
|
||||||
tiles = {
|
|
||||||
"lzr_laser_detector_on.png",
|
"lzr_laser_detector_on.png",
|
||||||
"lzr_laser_detector_on.png",
|
"lzr_laser_detector_on.png",
|
||||||
"lzr_laser_detector_on.png",
|
"lzr_laser_detector_on.png",
|
||||||
|
@ -231,13 +205,6 @@ minetest.register_node("lzr_laser:detector_on", {
|
||||||
"lzr_laser_detector_on.png",
|
"lzr_laser_detector_on.png",
|
||||||
"lzr_laser_detector_on_front.png",
|
"lzr_laser_detector_on_front.png",
|
||||||
},
|
},
|
||||||
after_place_node = full_update,
|
groups = { laser_block = 1 },
|
||||||
after_dig_node = full_update,
|
|
||||||
after_rotate = after_rotate,
|
|
||||||
|
|
||||||
sounds = lzr_sounds.node_sound_wood_defaults(),
|
|
||||||
groups = { detector = 2, laser_block = 1, choppy = 3, not_in_creative_inventory = 1 },
|
|
||||||
_lzr_inactive = "lzr_laser:detector",
|
|
||||||
drop = "lzr_laser:detector",
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue