Add skulls (change walkability if shot by laser)

master
Wuzzy 2022-03-05 02:34:29 +01:00
parent 48a652b6bc
commit 7cbd327ad4
3 changed files with 110 additions and 1 deletions

View File

@ -198,6 +198,10 @@ local register_element = function(subname, def, options)
else
def_core.after_place_node = full_update
end
if options.not_walkable_if_off then
def_core.walkable = false
end
def_core.description = S("@1 (fixed)", def.description)
def_core.after_dig_node = full_update
def_core._after_rotate = after_rotate
@ -217,8 +221,14 @@ local register_element = function(subname, def, options)
minetest.register_node("lzr_laser:"..subname, def_core)
local def_core_on
if options.activate ~= false then
def_core_on = table.copy(def_core)
if options.not_walkable_if_off then
def_core_on.walkable = true
elseif options.not_walkable_if_on then
def_core_on.walkable = false
end
def_core_on.description = S("@1 (fixed, active)", def.description)
def_core_on._lzr_active = nil
def_core_on._lzr_inactive = "lzr_laser:"..subname
@ -477,6 +487,95 @@ register_element("detector", {
sounds = lzr_sounds.node_sound_wood_defaults(),
}, { allow_take = true, is_detector = true })
-- Is non-walkable if off,
-- and walkable if on.
register_element("skull_cursed", {
description = S("Cursed Skull"),
paramtype2 = "facedir",
--[[ TODO
tiles_off = {
"lzr_laser_cskull_top.png^lzr_laser_fixed.png",
"lzr_laser_cskull_bottom.png^lzr_laser_fixed.png",
"lzr_laser_cskull_side.png^lzr_laser_fixed.png",
"lzr_laser_cskull_side.png^lzr_laser_fixed.png",
"lzr_laser_cskull_back.png^lzr_laser_fixed.png",
"lzr_laser_cskull_front.png^lzr_laser_fixed.png",
},
tiles_on = {
"lzr_laser_cskull_on_top.png^lzr_laser_fixed.png",
"lzr_laser_cskull_on_bottom.png^lzr_laser_fixed.png",
"lzr_laser_cskull_on_side.png^lzr_laser_fixed.png",
"lzr_laser_cskull_on_side.png^lzr_laser_fixed.png",
"lzr_laser_cskull_on_back.png^lzr_laser_fixed.png",
"lzr_laser_cskull_on_front.png^lzr_laser_fixed.png",
},
tiles_takable_off = {
"lzr_laser_cskull_top.png",
"lzr_laser_cskull_bottom.png",
"lzr_laser_cskull_side.png",
"lzr_laser_cskull_side.png",
"lzr_laser_cskull_back.png",
"lzr_laser_cskull_front.png",
},
tiles_takable_on = {
"lzr_laser_cskull_on_top.png",
"lzr_laser_cskull_on_bottom.png",
"lzr_laser_cskull_on_side.png",
"lzr_laser_cskull_on_side.png",
"lzr_laser_cskull_on_back.png",
"lzr_laser_cskull_on_front.png",
},
]]
light_source_on = 5,
groups = { rotatable = 2, laser_block = 1 },
on_rotate = screwdriver.rotate_simple,
sounds = lzr_sounds.node_sound_stone_defaults(),
}, { allow_take = true, not_walkable_if_off = true })
-- Is walkable if off,
-- and non-walkable if on.
register_element("skull_shy", {
description = S("Shy Skull"),
paramtype2 = "facedir",
--[[ TODO
tiles_off = {
"lzr_laser_sskull_top.png^lzr_laser_fixed.png",
"lzr_laser_sskull_bottom.png^lzr_laser_fixed.png",
"lzr_laser_sskull_side.png^lzr_laser_fixed.png",
"lzr_laser_sskull_side.png^lzr_laser_fixed.png",
"lzr_laser_sskull_back.png^lzr_laser_fixed.png",
"lzr_laser_sskull_front.png^lzr_laser_fixed.png",
},
tiles_on = {
"lzr_laser_sskull_on_top.png^lzr_laser_fixed.png",
"lzr_laser_sskull_on_bottom.png^lzr_laser_fixed.png",
"lzr_laser_sskull_on_side.png^lzr_laser_fixed.png",
"lzr_laser_sskull_on_side.png^lzr_laser_fixed.png",
"lzr_laser_sskull_on_back.png^lzr_laser_fixed.png",
"lzr_laser_sskull_on_front.png^lzr_laser_fixed.png",
},
tiles_takable_off = {
"lzr_laser_sskull_top.png",
"lzr_laser_sskull_bottom.png",
"lzr_laser_sskull_side.png",
"lzr_laser_sskull_side.png",
"lzr_laser_sskull_back.png",
"lzr_laser_sskull_front.png",
},
tiles_takable_on = {
"lzr_laser_sskull_on_top.png",
"lzr_laser_sskull_on_bottom.png",
"lzr_laser_sskull_on_side.png",
"lzr_laser_sskull_on_side.png",
"lzr_laser_sskull_on_back.png",
"lzr_laser_sskull_on_front.png",
},
]]
light_source_on = 5,
groups = { rotatable = 2, laser_block = 1 },
on_rotate = screwdriver.rotate_simple,
sounds = lzr_sounds.node_sound_stone_defaults(),
}, { allow_take = true, not_walkable_if_on = true })
minetest.register_node("lzr_laser:barricade", {
description = S("Barricade"),

View File

@ -1,2 +1,2 @@
name = lzr_laser
depends = lzr_globals, lzr_sounds
depends = lzr_globals, lzr_sounds, screwdriver2

View File

@ -50,6 +50,16 @@ function lzr_laser.add_laser(pos, dir, varea, vdata)
vdata[vi] = minetest.get_content_id("lzr_laser:laser_"..place_dirstring)
pos = vector.add(pos, dir)
return {{pos, dir}}
-- Laser through skull
elseif minetest.get_item_group(nodename, "skull_shy") > 0 or minetest.get_item_group(nodename, "skull_cursed") > 0 then
local def = minetest.registered_nodes[nodename]
local active = def._lzr_active
if active then
-- Activate skull node
vdata[vi] = minetest.get_content_id(def._lzr_active)
end
pos = vector.add(pos, dir)
return {{pos, dir}}
-- Mirror laser
elseif minetest.get_item_group(nodename, "mirror") > 0 then
local mirror_dir = lzr_laser.get_mirrored_laser_dir(pos, dir)