1
0
Fork 0

Add doors and fences to wood api

This commit is contained in:
cora 2022-08-10 06:25:15 +02:00
parent 121b122dfe
commit ddac066c7e
19 changed files with 71 additions and 61 deletions

View File

@ -157,8 +157,8 @@ function mcl_doors:register_door(name, def)
local left_node = minetest.get_node(pt_left) local left_node = minetest.get_node(pt_left)
-- Set door nodes -- Set door nodes
minetest.set_node(pt, {name=name.."_b_1", param2=p2}) minetest.set_node(pt, {name=name:gsub(":mcl_doors","mcl_doors").."_b_1", param2=p2})
minetest.set_node(pt2, {name=name.."_t_1", param2=p2}) minetest.set_node(pt2, {name=name:gsub(":mcl_doors","mcl_doors").."_t_1", param2=p2})
if def.sounds and def.sounds.place then if def.sounds and def.sounds.place then
minetest.sound_play(def.sounds.place, {pos=pt}, true) minetest.sound_play(def.sounds.place, {pos=pt}, true)
@ -217,9 +217,9 @@ function mcl_doors:register_door(name, def)
local p2 = minetest.get_node(pos).param2 local p2 = minetest.get_node(pos).param2
local np2 = params[p2+1] local np2 = params[p2+1]
minetest.swap_node(pos, {name=replace_dir, param2=np2}) minetest.swap_node(pos, {name=replace_dir:gsub(":mcl_doors","mcl_doors"), param2=np2})
pos.y = pos.y-dir pos.y = pos.y-dir
minetest.swap_node(pos, {name=replace, param2=np2}) minetest.swap_node(pos, {name=replace:gsub(":mcl_doors","mcl_doors"), param2=np2})
local door_switching_sound local door_switching_sound
if meta1:get_int("is_open") == 1 then if meta1:get_int("is_open") == 1 then
@ -265,7 +265,7 @@ function mcl_doors:register_door(name, def)
if not def.only_redstone_can_open then if not def.only_redstone_can_open then
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then if check_player_priv(pos, clicker) then
on_open_close(pos, 1, name.."_t_1", name.."_b_2", name.."_t_2") on_open_close(pos, 1, name:gsub(":mcl_doors","mcl_doors").."_t_1", name:gsub(":mcl_doors","mcl_doors").."_b_2", name:gsub(":mcl_doors","mcl_doors").."_t_2")
end end
end end
end end
@ -299,7 +299,7 @@ function mcl_doors:register_door(name, def)
else else
minetest.add_item(bottom, name) minetest.add_item(bottom, name)
local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z } local top = { x = bottom.x, y = bottom.y + 1, z = bottom.z }
if minetest.get_node(bottom).name ~= name.."_b_2" and minetest.get_node(top).name == name.."_t_1" then if minetest.get_node(bottom).name ~= name:gsub(":mcl_doors","mcl_doors").."_b_2" and minetest.get_node(top).name == name:gsub(":mcl_doors","mcl_doors").."_t_1" then
minetest.remove_node(top) minetest.remove_node(top)
end end
end end
@ -337,7 +337,7 @@ function mcl_doors:register_door(name, def)
else else
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then if check_player_priv(pos, clicker) then
on_open_close(pos, -1, name.."_b_1", name.."_t_2", name.."_b_2") on_open_close(pos, -1, name:gsub(":mcl_doors","mcl_doors").."_b_1", name:gsub(":mcl_doors","mcl_doors").."_t_2", name:gsub(":mcl_doors","mcl_doors").."_b_2")
end end
end end
end end
@ -370,7 +370,7 @@ function mcl_doors:register_door(name, def)
meta_top:set_int("rotation", 0) meta_top:set_int("rotation", 0)
else else
local bottom = { x = top.x, y = top.y - 1, z = top.z } local bottom = { x = top.x, y = top.y - 1, z = top.z }
if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name.."_b_1" and oldnode.name == name.."_t_1" then if minetest.get_node(top).name ~= name.."_t_2" and minetest.get_node(bottom).name == name:gsub(":mcl_doors","mcl_doors").."_b_1" and oldnode.name == name:gsub(":mcl_doors","mcl_doors").."_t_1" then
minetest.dig_node(bottom) minetest.dig_node(bottom)
end end
end end
@ -393,7 +393,7 @@ function mcl_doors:register_door(name, def)
local bottom = {x=top.x,y=top.y-1,z=top.z} local bottom = {x=top.x,y=top.y-1,z=top.z}
local meta_bottom = minetest_get_meta(bottom) local meta_bottom = minetest_get_meta(bottom)
meta_bottom:set_int("rotation", 1) meta_bottom:set_int("rotation", 1)
node.name = name .."_b_1" node.name = node.name:gsub(":mcl_doors","mcl_doors").."_b_1"
minetest.swap_node(bottom, node) minetest.swap_node(bottom, node)
return true return true
@ -409,7 +409,7 @@ function mcl_doors:register_door(name, def)
else else
on_rightclick = function(pos, node, clicker) on_rightclick = function(pos, node, clicker)
if check_player_priv(pos, clicker) then if check_player_priv(pos, clicker) then
on_open_close(pos, 1, name.."_t_2", name.."_b_1", name.."_t_1") on_open_close(pos, 1, name:gsub(":mcl_doors","mcl_doors").."_t_2", name:gsub(":mcl_doors","mcl_doors").."_b_1", name:gsub(":mcl_doors","mcl_doors").."_t_1")
end end
end end
end end

View File

@ -68,11 +68,11 @@ function mcl_doors:register_trapdoor(name, def)
-- Close -- Close
if minetest.get_item_group(me.name, "trapdoor") == 2 then if minetest.get_item_group(me.name, "trapdoor") == 2 then
minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 16}, true) minetest.sound_play(def.sound_close, {pos = pos, gain = 0.3, max_hear_distance = 16}, true)
tmp_node = {name=name, param1=me.param1, param2=me.param2} tmp_node = {name=name:gsub(":mcl_doors","mcl_doors"), param1=me.param1, param2=me.param2}
-- Open -- Open
else else
minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 16}, true) minetest.sound_play(def.sound_open, {pos = pos, gain = 0.3, max_hear_distance = 16}, true)
tmp_node = {name=name.."_open", param1=me.param1, param2=me.param2} tmp_node = {name=name:gsub(":mcl_doors","mcl_doors").."_open", param1=me.param1, param2=me.param2}
end end
minetest.set_node(pos, tmp_node) minetest.set_node(pos, tmp_node)
end end

View File

@ -0,0 +1 @@
doors_item_wood.png

View File

@ -0,0 +1 @@
mcl_doors_door_wood_lower.png

View File

@ -0,0 +1 @@
mcl_doors_door_wood_upper.png

View File

@ -0,0 +1 @@
doors_trapdoor.png

View File

@ -0,0 +1 @@
doors_trapdoor_side.png

View File

@ -0,0 +1 @@
mcl_fences_fence_big_oak.png

View File

@ -0,0 +1 @@
mcl_fences_fence_gate_big_oak.png

View File

@ -16,9 +16,9 @@ local propagule_allowed_nodes = {
"mcl_mud:mud", "mcl_mud:mud",
} }
local propagule_water_nodes = {"mcl_mud:mud","mcl_core:dirt","mcl_core:coarse_dirt","mcl_core:clay"} local propagule_water_nodes = {"mcl_mud:mud","mcl_core:dirt","mcl_core:coarse_dirt","mcl_core:clay"}
mcl_wood.register_wood("mangrove",false,true)
--"mcl_lush_caves:moss","mcl_lush_caves:rooted_dirt --"mcl_lush_caves:moss","mcl_lush_caves:rooted_dirt
mcl_wood.register_wood("mangrove",{nosap=true})
minetest.register_node("mcl_mangrove:mangrove_roots", { minetest.register_node("mcl_mangrove:mangrove_roots", {
description = "Mangrove_Roots", description = "Mangrove_Roots",
@ -244,43 +244,7 @@ minetest.register_node("mcl_mangrove:mangrove_mud_roots", {
_mcl_hardness = 0.7, _mcl_hardness = 0.7,
}) })
mcl_doors:register_door("mcl_mangrove:mangrove_door", {
description = ("Mangrove Door"),
_doc_items_longdesc = "",
_doc_items_usagehelp = "",
inventory_image = "mcl_mangrove_doors.png",
groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_mangrove_door_bottom.png", "mcl_wood_planks_mangrove.png"},
tiles_top = {"mcl_mangrove_door_top.png", "mcl_wood_planks_mangrove.png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
mcl_doors:register_trapdoor("mcl_mangrove:mangrove_trapdoor", {
description = S("Mangrove Trapdoor"),
_doc_items_longdesc = S("Wooden trapdoors are horizontal barriers which can be opened and closed by hand or a redstone signal. They occupy the upper or lower part of a block, depending on how they have been placed. When open, they can be climbed like a ladder."),
_doc_items_usagehelp = S("To open or close the trapdoor, rightclick it or send a redstone signal to it."),
tile_front = "mcl_mangrove_trapdoor.png",
tile_side = "mcl_wood_planks_mangrove.png",
wield_image = "mcl_mangrove_trapdoor.png",
groups = {handy=1,axey=1, mesecon_effector_on=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
mcl_fences.register_fence_and_fence_gate(
"mangrove_wood_fence",
S("Mangrove Wood Fence"),
S("Mangrove Wood Plank Fence"),
"mcl_mangrove_fence.png",
{handy=1,axey=1, flammable=2,fence_wood=1, fire_encouragement=5, fire_flammability=20},
minetest.registered_nodes["mcl_core:wood"]._mcl_hardness,
minetest.registered_nodes["mcl_core:wood"]._mcl_blast_resistance,
{"group:fence_wood"},
mcl_sounds.node_sound_wood_defaults(), "mcl_mangrove_mangrove_wood_fence_gate_open", "mcl_mangrove_mangrove_wood_fence_gate_close", 1, 1,
"mcl_mangrove_fence_gate.png")
minetest.register_craft({ minetest.register_craft({
output = "mcl_mangrove:mangrove_tree_bark 3", output = "mcl_mangrove:mangrove_tree_bark 3",

View File

Before

Width:  |  Height:  |  Size: 6.3 KiB

After

Width:  |  Height:  |  Size: 6.3 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@ -9,6 +9,9 @@ if mod_screwdriver then
on_rotate = screwdriver.rotate_3way on_rotate = screwdriver.rotate_3way
end end
local door_longdesc = S("Wooden doors are 2-block high barriers which can be opened or closed by hand and by a redstone signal.")
local door_usagehelp = S("To open or close a wooden door, rightclick it or supply its lower half with a redstone signal.")
-- Register tree trunk (wood) and bark -- Register tree trunk (wood) and bark
local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_variant) local function register_tree_trunk(subname, description_trunk, description_bark, longdesc, tile_inner, tile_bark, stripped_variant)
minetest.register_node(":mcl_wood:"..subname, { minetest.register_node(":mcl_wood:"..subname, {
@ -218,7 +221,8 @@ function readable_name(str)
end end
function mcl_wood.register_wood(name,nether,nosap) function mcl_wood.register_wood(name,p)
if not p then p = {} end
local rname = readable_name(name) local rname = readable_name(name)
register_tree_trunk("tree_"..name, S(rname.." Wood"), S(rname.." Bark"), S("The trunk of an "..name.." tree."), "mcl_wood_tree_"..name.."_top.png", "mcl_wood_tree_"..name..".png", "mcl_wood:stripped_"..name) register_tree_trunk("tree_"..name, S(rname.." Wood"), S(rname.." Bark"), S("The trunk of an "..name.." tree."), "mcl_wood_tree_"..name.."_top.png", "mcl_wood_tree_"..name..".png", "mcl_wood:stripped_"..name)
@ -226,7 +230,7 @@ function mcl_wood.register_wood(name,nether,nosap)
register_wooden_planks("wood_"..name, S(rname.." Wood Planks"), {"mcl_wood_planks_"..name..".png"}) register_wooden_planks("wood_"..name, S(rname.." Wood Planks"), {"mcl_wood_planks_"..name..".png"})
if not nosap then if not p.nosap then
register_sapling("sapling_"..name, S(rname.." Sapling"),S("When placed on soil (such as dirt) and exposed to light, an "..name.." sapling will grow into an "..name.." after some time."),S("Needs soil and light to grow"),"mcl_wood_sapling_"..name..".png", {-5/16, -0.5, -5/16, 5/16, 0.5, 5/16}) register_sapling("sapling_"..name, S(rname.." Sapling"),S("When placed on soil (such as dirt) and exposed to light, an "..name.." sapling will grow into an "..name.." after some time."),S("Needs soil and light to grow"),"mcl_wood_sapling_"..name..".png", {-5/16, -0.5, -5/16, 5/16, 0.5, 5/16})
end end
@ -244,4 +248,42 @@ function mcl_wood.register_wood(name,nether,nosap)
S(rname.." Wood Slab"), S(rname.." Wood Slab"),
mcl_sounds.node_sound_wood_defaults(), 3, 2, mcl_sounds.node_sound_wood_defaults(), 3, 2,
S("Double "..rname.." Wood Slab")) S("Double "..rname.." Wood Slab"))
mcl_fences.register_fence_and_fence_gate(
name.."_wood_fence",
S(rname.." Wood Fence"),
S(rname.." Wood Fence"),
"mcl_fences_fence_"..name..".png",
{handy=1,axey=1, flammable=2,fence_wood=1, fire_encouragement=5, fire_flammability=20},
minetest.registered_nodes["mcl_wood:wood_oak"]._mcl_hardness,
minetest.registered_nodes["mcl_wood:wood_oak"]._mcl_blast_resistance,
{"group:fence_wood"},
mcl_sounds.node_sound_wood_defaults(), "doors_fencegate_open", "doors_fencegate_close", 1, 1,
"mcl_fences_fence_gate_"..name..".png")
mcl_doors:register_door(":mcl_doors:door_"..name, {
description = S(rname.." Door"),
_doc_items_longdesc = door_longdesc,
_doc_items_usagehelp = door_usagehelp,
inventory_image = "mcl_doors_door_"..name..".png",
groups = {handy=1,axey=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
tiles_bottom = {"mcl_doors_door_"..name.."_lower.png", "mcl_wood_planks_"..name..".png"},
tiles_top = {"mcl_doors_door_"..name.."_upper.png", "mcl_wood_planks_"..name..".png"},
sounds = mcl_sounds.node_sound_wood_defaults(),
})
mcl_doors:register_trapdoor(":mcl_doors:trapdoor_"..name, {
description = S(rname.." Trapdoor"),
_doc_items_longdesc = S("Wooden trapdoors are horizontal barriers which can be opened and closed by hand or a redstone signal. They occupy the upper or lower part of a block, depending on how they have been placed. When open, they can be climbed like a ladder."),
_doc_items_usagehelp = S("To open or close the trapdoor, rightclick it or send a redstone signal to it."),
tile_front = "mcl_doors_trapdoor_"..name..".png",
tile_side = "mcl_wood_planks_"..name..".png",
wield_image = "mcl_doors_trapdoor_"..name..".png",
groups = {handy=1,axey=1, mesecon_effector_on=1, material_wood=1, flammable=-1},
_mcl_hardness = 3,
_mcl_blast_resistance = 3,
sounds = mcl_sounds.node_sound_wood_defaults(),
})
end end

View File

@ -1,23 +1,21 @@
local S = minetest.get_translator(minetest.get_current_modname()) local S = minetest.get_translator(minetest.get_current_modname())
local doc_mod = minetest.get_modpath("doc") local doc_mod = minetest.get_modpath("doc")
--[[]
local barks = { local barks = {
{ "", S("Oak Bark Stairs"), S("Oak Bark Slab"), S("Double Oak Bark Slab") }, { "oak", S("Oak Bark Stairs"), S("Oak Bark Slab"), S("Double Oak Bark Slab") },
{ "jungle", S("Jungle Bark Stairs"), S("Jungle Bark Slab"), S("Double Jungle Bark Slab") }, { "jungle", S("Jungle Bark Stairs"), S("Jungle Bark Slab"), S("Double Jungle Bark Slab") },
{ "acacia", S("Acacia Bark Stairs"), S("Acacia Bark Slab"), S("Double Acacia Bark Slab") }, { "acacia", S("Acacia Bark Stairs"), S("Acacia Bark Slab"), S("Double Acacia Bark Slab") },
{ "spruce", S("Spruce Bark Stairs"), S("Spruce Bark Slab"), S("Double Spruce Bark Slab") }, { "spruce", S("Spruce Bark Stairs"), S("Spruce Bark Slab"), S("Double Spruce Bark Slab") },
{ "birch", S("Birch Bark Stairs"), S("Birch Bark Slab"), S("Double Birch Bark Slab") }, { "birch", S("Birch Bark Stairs"), S("Birch Bark Slab"), S("Double Birch Bark Slab") },
{ "dark", S("Dark Oak Bark Stairs"), S("Dark Oak Bark Slab"), S("Double Dark Oak Bark Slab") }, { "dark_oak", S("Dark Oak Bark Stairs"), S("Dark Oak Bark Slab"), S("Double Dark Oak Bark Slab") },
} }
for b=1, #barks do for b=1, #barks do
local bark = barks[b] local bark = barks[b]
local sub = bark[1].."tree_bark" local sub = "tree_"..bark[1].."_bark"
local id = "mcl_core:tree" local id = "mcl_wood:tree_"..bark[1]
if bark[1] ~= "" then
id = "mcl_core:"..bark[1].."tree"
end
mcl_stairs.register_stair(sub, id, mcl_stairs.register_stair(sub, id,
{handy=1,axey=1, flammable=3, bark_stairs=1, material_wood=1, fire_encouragement=5, fire_flammability=5}, {handy=1,axey=1, flammable=3, bark_stairs=1, material_wood=1, fire_encouragement=5, fire_flammability=5},
{minetest.registered_nodes[id].tiles[3]}, {minetest.registered_nodes[id].tiles[3]},
@ -143,4 +141,3 @@ minetest.register_craft({
-- Same as wood slab -- Same as wood slab
burntime = 8, burntime = 8,
}) })
--]]

View File

@ -1,4 +1,4 @@
name = mclx_stairs name = mclx_stairs
description = Additional stairs and slabs not found in Minecraft 1.11 description = Additional stairs and slabs not found in Minecraft 1.11
depends = mcl_ocean, mcl_core, mcl_sounds, mcl_nether, mcl_end, mcl_colorblocks, mcl_stairs depends = mcl_ocean, mcl_core, mcl_sounds, mcl_nether, mcl_end, mcl_colorblocks, mcl_stairs, mcl_wood
optional_depends = doc optional_depends = doc