This commit is contained in:
root 2021-10-25 14:38:22 +02:00
parent 7e3de5f6fc
commit a9bba98e20
47 changed files with 2041 additions and 1780 deletions

View file

@ -0,0 +1,27 @@
quiet = 1
codes = true
exclude_files = {
".luarocks/*",
"worldeditadditions/utils/bit.lua"
}
ignore = {
"631", "61[124]",
"542",
"412",
"321/bit",
"21[123]"
}
-- Read-write globals (i.e. they can be defined)
globals = {
"flowerpot"
}
-- Read-only globals
read_globals = {
"minetest",
"default"
}
std = "max"

View file

@ -84,7 +84,7 @@ function flowerpot.register_node(nodename)
local desc = nodedef.description local desc = nodedef.description
local name = nodedef.name:gsub(":", "_") local name = nodedef.name:gsub(":", "_")
local tiles = {} local tiles
if nodedef.drawtype == "plantlike" then if nodedef.drawtype == "plantlike" then
tiles = { tiles = {
@ -109,6 +109,7 @@ function flowerpot.register_node(nodename)
tiles = tiles, tiles = tiles,
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
collision_box = { collision_box = {
type = "fixed", type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, -1/8, 1/4}, fixed = {-1/4, -1/2, -1/4, 1/4, -1/8, 1/4},
@ -151,6 +152,7 @@ minetest.register_node("flowerpot:empty", {
}, },
paramtype = "light", paramtype = "light",
sunlight_propagates = true, sunlight_propagates = true,
use_texture_alpha = minetest.features.use_texture_alpha_string_modes and "clip" or true,
collision_box = { collision_box = {
type = "fixed", type = "fixed",
fixed = {-1/4, -1/2, -1/4, 1/4, -1/8, 1/4}, fixed = {-1/4, -1/2, -1/4, 1/4, -1/8, 1/4},

View file

@ -1,8 +1,9 @@
-- Load support for intllib. -- Load support for intllib.
local MP = minetest.get_modpath(minetest.get_current_modname()) local MP = minetest.get_modpath(minetest.get_current_modname()) .. "/"
local S = minetest.get_translator and minetest.get_translator("mob_horse") or local S = minetest.get_translator and minetest.get_translator("mob_horse") or
dofile(MP .. "/intllib.lua") dofile(MP .. "intllib.lua")
-- 0.4.17 or 5.0 check -- 0.4.17 or 5.0 check
local y_off = 20 local y_off = 20
@ -10,6 +11,7 @@ if minetest.features.object_independent_selectionbox then
y_off = 10 y_off = 10
end end
-- horse shoes (speed, jump, break, overlay texture) -- horse shoes (speed, jump, break, overlay texture)
local shoes = { local shoes = {
["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"}, ["mobs:horseshoe_steel"] = {7, 4, 2, "mobs_horseshoe_steelo.png"},
@ -19,6 +21,7 @@ local shoes = {
["mobs:horseshoe_crystal"] = {11, 6, 9, "mobs_horseshoe_crystalo.png"} ["mobs:horseshoe_crystal"] = {11, 6, 9, "mobs_horseshoe_crystalo.png"}
} }
-- rideable horse -- rideable horse
mobs:register_mob("mob_horse:horse", { mobs:register_mob("mob_horse:horse", {
type = "animal", type = "animal",
@ -39,7 +42,7 @@ mobs:register_mob("mob_horse:horse", {
walk_start = 75, walk_start = 75,
walk_end = 100, walk_end = 100,
run_start = 75, run_start = 75,
run_end = 100, run_end = 100
}, },
textures = { textures = {
{"mobs_horse.png"}, -- textures by Mjollna {"mobs_horse.png"}, -- textures by Mjollna
@ -227,16 +230,28 @@ mobs:register_mob("mob_horse:horse", {
end end
}) })
mobs:spawn({
name = "mob_horse:horse", -- check for custom spawn.lua
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"}, local input = io.open(MP .. "spawn.lua", "r")
min_light = 14,
interval = 60, if input then
chance = 16000, input:close()
min_height = 10, input = nil
max_height = 31000, dofile(MP .. "spawn.lua")
day_toggle = true, else
})
mobs:spawn({
name = "mob_horse:horse",
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"},
min_light = 14,
interval = 60,
chance = 16000,
min_height = 10,
max_height = 31000,
day_toggle = true
})
end
mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1) mobs:register_egg("mob_horse:horse", S("Horse"), "wool_brown.png", 1)
@ -252,14 +267,14 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:steelblock", ""}, {"", "default:steelblock", ""},
{"default:steel_ingot", "", "default:steel_ingot"}, {"default:steel_ingot", "", "default:steel_ingot"},
{"default:steel_ingot", "", "default:steel_ingot"}, {"default:steel_ingot", "", "default:steel_ingot"}
} }
}) })
-- bronze horseshoes -- bronze horseshoes
minetest.register_craftitem(":mobs:horseshoe_bronze", { minetest.register_craftitem(":mobs:horseshoe_bronze", {
description = S("Bronze HorseShoes (use on horse to apply)"), description = S("Bronze HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_bronze.png", inventory_image = "mobs_horseshoe_bronze.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -267,14 +282,14 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:bronzeblock", ""}, {"", "default:bronzeblock", ""},
{"default:bronze_ingot", "", "default:bronze_ingot"}, {"default:bronze_ingot", "", "default:bronze_ingot"},
{"default:bronze_ingot", "", "default:bronze_ingot"}, {"default:bronze_ingot", "", "default:bronze_ingot"}
} }
}) })
-- mese horseshoes -- mese horseshoes
minetest.register_craftitem(":mobs:horseshoe_mese", { minetest.register_craftitem(":mobs:horseshoe_mese", {
description = S("Mese HorseShoes (use on horse to apply)"), description = S("Mese HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_mese.png", inventory_image = "mobs_horseshoe_mese.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -282,14 +297,14 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:mese", ""}, {"", "default:mese", ""},
{"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"}, {"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"},
{"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"}, {"default:mese_crystal_fragment", "", "default:mese_crystal_fragment"}
} }
}) })
-- diamond horseshoes -- diamond horseshoes
minetest.register_craftitem(":mobs:horseshoe_diamond", { minetest.register_craftitem(":mobs:horseshoe_diamond", {
description = S("Diamond HorseShoes (use on horse to apply)"), description = S("Diamond HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_diamond.png", inventory_image = "mobs_horseshoe_diamond.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -297,7 +312,7 @@ minetest.register_craft({
recipe = { recipe = {
{"", "default:diamondblock", ""}, {"", "default:diamondblock", ""},
{"default:diamond", "", "default:diamond"}, {"default:diamond", "", "default:diamond"},
{"default:diamond", "", "default:diamond"}, {"default:diamond", "", "default:diamond"}
} }
}) })
@ -306,7 +321,7 @@ if minetest.get_modpath("ethereal") then
minetest.register_craftitem(":mobs:horseshoe_crystal", { minetest.register_craftitem(":mobs:horseshoe_crystal", {
description = S("Crystal HorseShoes (use on horse to apply)"), description = S("Crystal HorseShoes (use on horse to apply)"),
inventory_image = "mobs_horseshoe_crystal.png", inventory_image = "mobs_horseshoe_crystal.png"
}) })
minetest.register_craft({ minetest.register_craft({
@ -314,12 +329,13 @@ minetest.register_craft({
recipe = { recipe = {
{"", "ethereal:crystal_block", ""}, {"", "ethereal:crystal_block", ""},
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"}, {"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"},
{"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"}, {"ethereal:crystal_ingot", "", "ethereal:crystal_ingot"}
} }
}) })
end end
-- lucky blocks -- lucky blocks
if minetest.get_modpath("lucky_block") then if minetest.get_modpath("lucky_block") then

View file

@ -0,0 +1,72 @@
--[[ Spawn Template, defaults to values shown if line not provided
mobs:spawn({
name = "",
- Name of mob, must be provided e.g. "mymod:my_mob"
nodes = {"group:soil, "group:stone"},
- Nodes to spawn on top of.
neighbors = {"air"},
- Nodes to spawn beside.
min_light = 0,
- Minimum light level.
max_light = 15,
- Maximum light level, 15 is sunlight only.
interval = 30,
- Spawn interval in seconds.
chance = 5000,
- Spawn chance, 1 in every 5000 nodes.
active_object_count = 1,
- Active mobs of this type in area.
min_height = -31000,
- Minimum height level.
max_height = 31000,
- Maximum height level.
day_toggle = nil,
- Daytime toggle, true to spawn during day, false for night, nil for both
on_spawn = nil,
- On spawn function to run when mob spawns in world
on_map_load = nil,
- On map load, when true mob only spawns in newly generated map areas
})
]]--
-- Horse
mobs:spawn({
name = "mob_horse:horse",
nodes = {"default:dirt_with_grass", "ethereal:dry_dirt"},
min_light = 14,
interval = 60,
chance = 16000,
min_height = 10,
max_height = 31000,
day_toggle = true
})

View file

@ -77,7 +77,7 @@ minetest.register_node("morelights_vintage:chain_ceiling_b", {
minetest.register_node("morelights_vintage:block", { minetest.register_node("morelights_vintage:block", {
description = S("Vintage Light Block"), description = S("Vintage Light Block"),
tiles = {"morelights_vintage_block.png"}, tiles = {"morelights_vintage_block_glass.png^morelights_vintage_block_frame.png"},
paramtype = "light", paramtype = "light",
light_source = minetest.LIGHT_MAX, light_source = minetest.LIGHT_MAX,
groups = {cracky = 2, oddly_breakable_by_hand = 3, handy = 1}, groups = {cracky = 2, oddly_breakable_by_hand = 3, handy = 1},
@ -93,9 +93,10 @@ minetest.register_node("morelights_vintage:smallblock", {
fixed = {-1/4, -1/2, -1/4, 1/4, 0, 1/4} fixed = {-1/4, -1/2, -1/4, 1/4, 0, 1/4}
}, },
tiles = { tiles = {
"morelights_vintage_block.png", "morelights_vintage_block_glass.png^morelights_vintage_block_frame.png",
"morelights_vintage_block.png", "morelights_vintage_block_glass.png^morelights_vintage_block_frame.png",
"[combine:16x16:0,4=morelights_vintage_block.png" "[combine:16x16:0,4=" ..
"(morelights_vintage_block_glass.png^morelights_vintage_block_frame.png)"
}, },
use_texture_alpha = "opaque", use_texture_alpha = "opaque",
paramtype = "light", paramtype = "light",
@ -116,7 +117,7 @@ minetest.register_node("morelights_vintage:lantern_f", {
drawtype = "mesh", drawtype = "mesh",
mesh = "morelights_vintage_lantern_f.obj", mesh = "morelights_vintage_lantern_f.obj",
tiles = { tiles = {
"morelights_vintage_lantern.png", "morelights_vintage_lantern_frame.png^morelights_vintage_lantern_glass.png",
"morelights_metal_dark_32.png" "morelights_metal_dark_32.png"
}, },
use_texture_alpha = "opaque", use_texture_alpha = "opaque",
@ -159,7 +160,7 @@ minetest.register_node("morelights_vintage:lantern_c", {
drawtype = "mesh", drawtype = "mesh",
mesh = "morelights_vintage_lantern_c.obj", mesh = "morelights_vintage_lantern_c.obj",
tiles = { tiles = {
"morelights_vintage_lantern.png", "morelights_vintage_lantern_frame.png^morelights_vintage_lantern_glass.png",
"morelights_metal_dark_32.png" "morelights_metal_dark_32.png"
}, },
use_texture_alpha = "opaque", use_texture_alpha = "opaque",
@ -185,7 +186,7 @@ minetest.register_node("morelights_vintage:lantern_w", {
drawtype = "mesh", drawtype = "mesh",
mesh = "morelights_vintage_lantern_w.obj", mesh = "morelights_vintage_lantern_w.obj",
tiles = { tiles = {
"morelights_vintage_lantern.png", "morelights_vintage_lantern_frame.png^morelights_vintage_lantern_glass.png",
"morelights_metal_dark_32.png" "morelights_metal_dark_32.png"
}, },
use_texture_alpha = "clip", use_texture_alpha = "clip",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 272 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 422 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 368 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 B

View file

@ -14,21 +14,21 @@ local cdoor_list = { --Number , Description , Inven Image , Image
-- {"Castle Door 13" , "door13"}, -- {"Castle Door 13" , "door13"},
} }
local function add_door(desc, img)
for i in ipairs(cdoor_list) do doors.register("my_castle_doors:"..img.."_locked", {
local desc = cdoor_list[i][1] description = desc.." Locked",
local img = cdoor_list[i][2] inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }},
doors.register("my_castle_doors:"..img.."_locked", { protected = true,
description = desc.." Locked", })
inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }},
protected = true,
})
end end
for _,cdoor in ipairs(cdoor_list) do
add_door(unpack(cdoor))
end
---[[ Crafts ---[[ Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -14,21 +14,21 @@ local cdoor_list = { --Number , Description , Inven Image , Image
{"Castle Door 13" , "door13"}, {"Castle Door 13" , "door13"},
} }
local function add_door(desc, img)
for i in ipairs(cdoor_list) do doors.register_door("my_castle_doors:"..img, {
local desc = cdoor_list[i][1] description = desc,
local img = cdoor_list[i][2] inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mydoors_"..img..".png", backface_culling = true}},
doors.register_door("my_castle_doors:"..img, { protected = false,
description = desc, })
inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mydoors_"..img..".png", backface_culling = true}},
protected = false,
})
end end
for _,cdoor in ipairs(cdoor_list) do
add_door(unpack(cdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -3,21 +3,21 @@ local cdoor_list = { --Number , Description , Inven Image , Image
-- {"Cottage Door 2" , "door2"}, -- {"Cottage Door 2" , "door2"},
} }
local function add_door(desc, img)
for i in ipairs(cdoor_list) do doors.register_door("my_cottage_doors:"..img.."_locked", {
local desc = cdoor_list[i][1] description = desc.." Locked",
local img = cdoor_list[i][2] inventory_image = "mycdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mycdoors_"..img..".png", backface_culling = true}},
doors.register_door("my_cottage_doors:"..img.."_locked", { protected = true,
description = desc.." Locked", })
inventory_image = "mycdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mycdoors_"..img..".png", backface_culling = true}},
protected = true,
})
end end
for _,cdoor in ipairs(cdoor_list) do
add_door(unpack(cdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -3,21 +3,21 @@ local cdoor_list = { --Number , Description , Inven Image , Image
{"Cottage Door 2" , "door2"}, {"Cottage Door 2" , "door2"},
} }
local function add_door(desc, img)
for i in ipairs(cdoor_list) do doors.register_door("my_cottage_doors:"..img, {
local desc = cdoor_list[i][1] description = desc,
local img = cdoor_list[i][2] inventory_image = "mycdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mycdoors_"..img..".png", backface_culling = true}},
doors.register_door("my_cottage_doors:"..img, { protected = false,
description = desc, })
inventory_image = "mycdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mycdoors_"..img..".png", backface_culling = true}},
protected = false,
})
end end
for _,cdoor in ipairs(cdoor_list) do
add_door(unpack(cdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -6,31 +6,26 @@ local cdoor_list = { --Number , Description , Inven Image , Image
{ "5", "Mese Door" , "mese", "mese_crystal"}, { "5", "Mese Door" , "mese", "mese_crystal"},
} }
local function add_door(num, desc, img, itm)
doors.register_door("my_default_doors:door"..num.."_locked", {
description = desc.." Locked",
inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mydoors_"..img..".png", backface_culling = true}},
protected = true,
})
for i in ipairs(cdoor_list) do -- Crafts
local num = cdoor_list[i][1] minetest.register_craft({
local desc = cdoor_list[i][2] output = "my_default_doors:door"..num.."_locked 1",
local img = cdoor_list[i][3] recipe = {
local itm = cdoor_list[i][4] {"", "", ""},
{"default:"..itm, "doors:door_steel", "default:"..itm},
{"", "default:steel_ingot", ""}
doors.register_door("my_default_doors:door"..num.."_locked", { }
description = desc.." Locked", })
inventory_image = "mydoors_"..img.."_inv.png", end
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mydoors_"..img..".png", backface_culling = true}}, for _,cdoor in ipairs(cdoor_list) do
protected = true, add_door(unpack(cdoor))
})
-- Crafts
minetest.register_craft({
output = "my_default_doors:door"..num.."_locked 1",
recipe = {
{"", "", ""},
{"default:"..itm, "doors:door_steel", "default:"..itm},
{"", "default:steel_ingot", ""}
}
})
end end

View file

@ -6,31 +6,26 @@ local cdoor_list = { --Number , Description , Inven Image , Image
{ "5", "Mese Door" , "mese", "mese_crystal"}, { "5", "Mese Door" , "mese", "mese_crystal"},
} }
local function add_door(num, desc, img, itm)
doors.register_door("my_default_doors:door"..num, {
description = desc,
inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mydoors_"..img..".png", backface_culling = true}},
protected = false,
})
for i in ipairs(cdoor_list) do -- Crafts
local num = cdoor_list[i][1] minetest.register_craft({
local desc = cdoor_list[i][2] output = "my_default_doors:door"..num.." 1",
local img = cdoor_list[i][3] recipe = {
local itm = cdoor_list[i][4] {"", "", ""},
{"default:"..itm, "doors:door_steel", "default:"..itm},
{"", "", ""}
doors.register_door("my_default_doors:door"..num, { }
description = desc, })
inventory_image = "mydoors_"..img.."_inv.png", end
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mydoors_"..img..".png", backface_culling = true}}, for _,cdoor in ipairs(cdoor_list) do
protected = false, add_door(unpack(cdoor))
})
-- Crafts
minetest.register_craft({
output = "my_default_doors:door"..num.." 1",
recipe = {
{"", "", ""},
{"default:"..itm, "doors:door_steel", "default:"..itm},
{"", "", ""}
}
})
end end

View file

@ -8,9 +8,9 @@ local door_wood = { -- color, desc, image
{"black", "Black", "black"}, {"black", "Black", "black"},
} }
local function my_door_wood_block_stairs(nodename, def) local function my_door_wood_block_stairs(nodename, def)
local mod = string.match (nodename,"(.+):") local mod = string.match(nodename, "(.+):")
local name = string.match (nodename,":(.+)") local name = string.match(nodename, ":(.+)")
minetest.register_node(nodename,def) minetest.register_node(nodename, def)
if minetest.get_modpath("moreblocks") then if minetest.get_modpath("moreblocks") then
stairsplus:register_all( stairsplus:register_all(
mod, mod,
@ -33,30 +33,29 @@ local function my_door_wood_block_stairs(nodename, def)
) )
end end
end end
for i in ipairs(door_wood) do
local color = door_wood[i][1]
local desc = door_wood[i][2]
local img = door_wood[i][3]
my_door_wood_block_stairs("my_door_wood:wood_"..color, { local function add_door(color, desc, img)
description = desc.." Wood", my_door_wood_block_stairs("my_door_wood:wood_"..color, {
drawtype = "normal", description = desc.." Wood",
paramtype = "light", drawtype = "normal",
tiles = {"mydoors_"..img.."_wood.png"}, paramtype = "light",
paramtype = "light", tiles = {"mydoors_"..img.."_wood.png"},
groups = {cracky = 2, choppy = 2}, paramtype = "light",
sounds = default.node_sound_wood_defaults(), groups = {cracky = 2, choppy = 2},
sounds = default.node_sound_wood_defaults(),
})
}) -- Crafts
minetest.register_craft({
-- Crafts output = "my_door_wood:wood_"..color,
recipe = {
minetest.register_craft({ {"default:wood", "", ""},
output = "my_door_wood:wood_"..color, {"dye:"..color, "", ""},
recipe = { {"", "", ""}
{"default:wood", "", ""}, }
{"dye:"..color, "", ""}, })
{"", "", ""} end
}
}) for _,door in ipairs(door_wood) do
add_door(unpack(door))
end end

View file

@ -9,21 +9,21 @@ local fdoor_list = { --Number , Description , Inven Image , Image
{"Fancy Door 8" , "door8"}, {"Fancy Door 8" , "door8"},
} }
local function add_door(desc, img)
for i in ipairs(fdoor_list) do doors.register_door("my_fancy_doors:"..img.."_locked", {
local desc = fdoor_list[i][1] description = desc.." Locked",
local img = fdoor_list[i][2] inventory_image = "myfdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "myfdoors_"..img..".png", backface_culling = true }},
doors.register_door("my_fancy_doors:"..img.."_locked", { protected = true,
description = desc.." Locked", })
inventory_image = "myfdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "myfdoors_"..img..".png", backface_culling = true }},
protected = true,
})
end end
for _,fdoor in ipairs(fdoor_list) do
add_door(unpack(fdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -9,21 +9,21 @@ local fdoor_list = { --Number , Description , Inven Image , Image
-- {"Fancy Door 8" , "door8"}, -- {"Fancy Door 8" , "door8"},
} }
local function add_door(desc, img)
for i in ipairs(fdoor_list) do doors.register_door("my_fancy_doors:"..img, {
local desc = fdoor_list[i][1] description = desc,
local img = fdoor_list[i][2] inventory_image = "myfdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "myfdoors_"..img..".png", backface_culling = true }},
doors.register_door("my_fancy_doors:"..img, { protected = false,
description = desc, })
inventory_image = "myfdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "myfdoors_"..img..".png", backface_culling = true }},
protected = false,
})
end end
for _,fdoor in ipairs(fdoor_list) do
add_door(unpack(fdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -1,190 +1,210 @@
local doorcolors = {"white","red","black"} local doorcolors = {"white","red","black"}
for i = 1,#doorcolors do
local col = doorcolors[i]
minetest.register_node("my_future_doors:door1a_"..col, { local function add_door(col)
description = "Door 1a", minetest.register_node("my_future_doors:door1a_"..col, {
tiles = { description = "Door 1a",
"myndoors_door1_"..col..".png", tiles = {
"myndoors_door1_"..col..".png", "myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png", "myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png", "myndoors_door1_"..col..".png",
"myndoors_door1_"..col.."b.png", "myndoors_door1_"..col..".png",
"myndoors_door1_"..col.."b.png" "myndoors_door1_"..col.."b.png",
}, "myndoors_door1_"..col.."b.png"
drawtype = "nodebox", },
paramtype = "light", drawtype = "nodebox",
paramtype2 = "facedir", paramtype = "light",
groups = {cracky = 3}, paramtype2 = "facedir",
node_box = { groups = {cracky = 3},
type = "fixed", node_box = {
fixed = { type = "fixed",
{-0.4375, -0.5, -0.1875, 0.4375, 0.5, -0.0625}, fixed = {
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5}, {-0.4375, -0.5, -0.1875, 0.4375, 0.5, -0.0625},
{0.4375, -0.5, -0.5, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
{0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625}, { 0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
{0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5}, { 0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5}, { 0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
{-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625}, {-0.625, -0.5, -0.5625,-0.4375, 0.5, -0.5},
} {-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
}, }
selection_box = { },
type = "fixed", selection_box = {
fixed = { type = "fixed",
{-0.4375, -0.5, -0.1875, 0.4375, 1.5, -0.0625}, --door fixed = {
{0.4375, -0.5, -0.5625, 0.625, 1.4375, 0.5625}, --right {-0.4375, -0.5, -0.1875, 0.4375, 1.5, -0.0625}, --door
{-0.625, -0.5, -0.5625, -0.4375, 1.4375, 0.5625}, --left { 0.4375, -0.5, -0.5625, 0.625, 1.4375, 0.5625}, --right
{-0.625, 1.4375, -0.5625, 0.625, 1.625, 0.5625}, --top {-0.625, -0.5, -0.5625, -0.4375, 1.4375, 0.5625}, --left
} {-0.625, 1.4375,-0.5625, 0.625, 1.625, 0.5625}, --top
}, }
},
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local pos1 = pointed_thing.above local pos1 = pointed_thing.above
local pos2 = {x=pos1.x, y=pos1.y, z=pos1.z} local pos2 = vector.add(pos1, {x=0,y=1,z=0})
pos2.y = pos2.y+1
if if not placer or not placer:is_player() then
not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or return
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or end
not placer or
not placer:is_player() then if not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
return not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to then
end minetest.chat_send_player(placer:get_player_name(), "Not enough room")
return minetest.item_place(itemstack, placer, pointed_thing) return
end, end
after_place_node = function(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos) local player_name = placer:get_player_name()
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1b_"..col,param2=node.param2}) if minetest.is_protected(pos1, player_name) then
end, minetest.record_protection_violation(pos1, player_name)
after_destruct = function(pos, oldnode) return
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) end
end, if minetest.is_protected(pos2, player_name) then
on_rightclick = function(pos, node, player, itemstack, pointed_thing) minetest.record_protection_violation(pos2, player_name)
local timer = minetest.get_node_timer(pos) return
if node.name == "my_future_doors:door1a_"..col then end
minetest.set_node(pos,{name="my_future_doors:door1c_"..col,param2=node.param2}) return minetest.item_place(itemstack, placer, pointed_thing)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1d_"..col,param2=node.param2}) end,
timer:start(3) after_place_node = function(pos, placer, itemstack, pointed_thing)
end local node = minetest.get_node(pos)
end, minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_future_doors:door1b_"..col, param2=node.param2})
}) end,
minetest.register_node("my_future_doors:door1b_"..col, { after_destruct = function(pos, oldnode)
tiles = { minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
"myndoors_door1_"..col..".png", end,
"myndoors_door1_"..col..".png", on_rightclick = function(pos, node, player, itemstack, pointed_thing)
"myndoors_door1_"..col..".png", if node.name == "my_future_doors:door1a_"..col then
"myndoors_door1_"..col..".png", local timer = minetest.get_node_timer(pos)
"myndoors_door1_"..col.."b.png", minetest.set_node(pos, {name="my_future_doors:door1c_"..col, param2=node.param2})
"myndoors_door1_"..col.."b.png" minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_future_doors:door1d_"..col, param2=node.param2})
}, timer:start(3)
drawtype = "nodebox", end
paramtype = "light", end,
paramtype2 = "facedir", })
groups = {cracky = 1}, minetest.register_node("my_future_doors:door1b_"..col, {
node_box = { tiles = {
type = "fixed", "myndoors_door1_"..col..".png",
fixed = { "myndoors_door1_"..col..".png",
{-0.4375, -0.5, -0.1875, 0.4375, 0.5, -0.0625}, "myndoors_door1_"..col..".png",
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5}, "myndoors_door1_"..col..".png",
{0.4375, -0.5, -0.5, 0.5, 0.5, 0.5}, "myndoors_door1_"..col.."b.png",
{0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625}, "myndoors_door1_"..col.."b.png"
{0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5}, },
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5}, drawtype = "nodebox",
{-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625}, paramtype = "light",
{-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5}, paramtype2 = "facedir",
{-0.625, 0.4375, -0.5625, 0.625, 0.625, -0.5}, groups = {cracky = 1},
{-0.625, 0.4375, 0.5, 0.625, 0.625, 0.5625}, node_box = {
type = "fixed",
fixed = {
{-0.4375, -0.5, -0.1875, 0.4375, 0.5, -0.0625},
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
{ 0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
{ 0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
{ 0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
{-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
{-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
{-0.625, 0.4375, -0.5625, 0.625, 0.625, -0.5},
{-0.625, 0.4375, 0.5, 0.625, 0.625, 0.5625},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.5, -0.5, -0.5},
}
},
})
minetest.register_node("my_future_doors:door1c_"..col, {
tiles = {
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col.."b.png",
"myndoors_door1_"..col.."b.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
{ 0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
{ 0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
{ 0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
{-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
}
},
selection_box = {
type = "fixed",
fixed = {
{ 0.4375, -0.5, -0.5625, 0.625, 1.4375, 0.5625}, --right
{-0.625, -0.5, -0.5625, -0.4375, 1.4375, 0.5625}, --left
{-0.625, 1.4375, -0.5625, 0.625, 1.625, 0.5625}, --top
}
},
drop = "my_future_doors:door1a_"..col,
after_place_node = function(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos)
local timer = minetest.get_node_timer(pos)
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_future_doors:door1d_"..col, param2=node.param2})
timer:start(3)
end,
after_destruct = function(pos, oldnode)
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
end,
on_timer = function(pos, elapsed)
local node = minetest.get_node(pos)
minetest.set_node(pos, {name="my_future_doors:door1a_"..col, param2=node.param2})
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_future_doors:door1b_"..col, param2=node.param2})
end,
})
minetest.register_node("my_future_doors:door1d_"..col, {
tiles = {
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col.."b.png",
"myndoors_door1_"..col.."b.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
{ 0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
{ 0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
{ 0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
{-0.625, -0.5, 0.5, -0.4375, 0.4375, 0.5625},
{-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
{-0.625, 0.4375, -0.5625, 0.625, 0.625, -0.5},
{-0.625, 0.4375, 0.5, 0.625, 0.625, 0.5625},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.5, -0.5, -0.5},
}
},
})
minetest.register_craft({
output = "my_future_doors:door1a_"..col.." 1",
recipe = {
{"my_door_wood:wood_"..col, "wool:"..col, "my_door_wood:wood_"..col},
{"wool:"..col, "my_door_wood:wood_"..col, "wool:"..col},
{"my_door_wood:wood_"..col, "wool:"..col, "my_door_wood:wood_"..col}
} }
}, })
selection_box = { end
type = "fixed",
fixed = { for _,col in ipairs(doorcolors) do
{-0.5, -0.5, -0.5, -0.5, -0.5, -0.5}, add_door(col)
}
},
})minetest.register_node("my_future_doors:door1c_"..col, {
tiles = {
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col.."b.png",
"myndoors_door1_"..col.."b.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
{0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
{0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
{0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
{-0.625, -0.5, 0.5, -0.4375, 0.5, 0.5625},
}
},
selection_box = {
type = "fixed",
fixed = {
{0.4375, -0.5, -0.5625, 0.625, 1.4375, 0.5625}, --right
{-0.625, -0.5, -0.5625, -0.4375, 1.4375, 0.5625}, --left
{-0.625, 1.4375, -0.5625, 0.625, 1.625, 0.5625}, --top
}
},
after_place_node = function(pos, placer, itemstack, pointed_thing)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1d_"..col,param2=nodeu.param2})
end,
after_destruct = function(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
end,
on_timer = function(pos, elapsed)
local node = minetest.get_node(pos)
minetest.set_node(pos,{name="my_future_doors:door1a_"..col,param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_future_doors:door1b_"..col,param2=node.param2})
end,
})
minetest.register_node("my_future_doors:door1d_"..col, {
tiles = {
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col..".png",
"myndoors_door1_"..col.."b.png",
"myndoors_door1_"..col.."b.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.4375, 0.5, 0.5},
{0.4375, -0.5, -0.5, 0.5, 0.5, 0.5},
{0.4375, -0.5, 0.5, 0.625, 0.5, 0.5625},
{0.4375, -0.5, -0.5625, 0.625, 0.5, -0.5},
{-0.625, -0.5, -0.5625, -0.4375, 0.5, -0.5},
{-0.625, -0.5, 0.5, -0.4375, 0.4375, 0.5625},
{-0.5, 0.4375, -0.5, 0.5, 0.5, 0.5},
{-0.625, 0.4375, -0.5625, 0.625, 0.625, -0.5},
{-0.625, 0.4375, 0.5, 0.625, 0.625, 0.5625},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.5, -0.5, -0.5, -0.5},
}
},
})
minetest.register_craft({
output = "my_future_doors:door1a_"..col.." 1",
recipe = {
{"my_door_wood:wood_"..col, "wool:"..col, "my_door_wood:wood_"..col},
{"wool:"..col, "my_door_wood:wood_"..col, "wool:"..col},
{"my_door_wood:wood_"..col, "wool:"..col, "my_door_wood:wood_"..col}
}
})
end end

View file

@ -1,270 +1,247 @@
local doors = { local doors = {
{"my_future_doors:door2a","my_future_doors:door2b","my_future_doors:door2c","my_future_doors:door2d","2","Steel"}, {"my_future_doors:door2a","my_future_doors:door2b","my_future_doors:door2c","my_future_doors:door2d","2","Steel",
{"my_future_doors:door3a","my_future_doors:door3b","my_future_doors:door3c","my_future_doors:door3d","3","Squared"}, {{"default:steel_ingot", "default:steelblock", ""},
{"my_future_doors:door4a","my_future_doors:door4b","my_future_doors:door4c","my_future_doors:door4d","4","Dark"}, {"default:steel_ingot", "default:steel_ingot", ""},
{"my_future_doors:door6a","my_future_doors:door6b","my_future_doors:door6c","my_future_doors:door6d","6","Points"}, {"default:steelblock", "default:steel_ingot", ""}}},
{"my_future_doors:door7a","my_future_doors:door7b","my_future_doors:door7c","my_future_doors:door7d","7","Snow Flake"}, {"my_future_doors:door3a","my_future_doors:door3b","my_future_doors:door3c","my_future_doors:door3d","3","Squared",
{"my_future_doors:door8a","my_future_doors:door8b","my_future_doors:door8c","my_future_doors:door8d","8","Blue Steel"}, {{"default:steel_ingot","default:steel_ingot", ""},
{"my_future_doors:door9a","my_future_doors:door9b","my_future_doors:door9c","my_future_doors:door9d","9","Tan Steel"}, {"default:steel_ingot", "default:steel_ingot", ""},
} {"default:steelblock", "default:steelblock", ""}}},
{"my_future_doors:door4a","my_future_doors:door4b","my_future_doors:door4c","my_future_doors:door4d","4","Dark",
local recipes = { {{"default:steel_ingot","default:steel_ingot", ""},
{{"default:steel_ingot", "default:steelblock", ""}, {"default:steel_ingot", "default:steel_ingot", "dye:black"},
{"default:steel_ingot", "default:steel_ingot", ""}, {"default:steelblock", "default:steelblock", ""}}},
{"default:steelblock", "default:steel_ingot", ""}}, {"my_future_doors:door6a","my_future_doors:door6b","my_future_doors:door6c","my_future_doors:door6d","6","Points",
{{"default:steel_ingot","default:steel_ingot", ""}, {{"default:steel_ingot","default:steel_ingot", ""},
{"default:steel_ingot", "default:steel_ingot", ""}, {"default:steelblock", "default:steelblock", ""},
{"default:steelblock", "default:steelblock", ""}}, {"default:steel_ingot", "default:steel_ingot", ""}}},
{{"default:steel_ingot","default:steel_ingot", ""}, {"my_future_doors:door7a","my_future_doors:door7b","my_future_doors:door7c","my_future_doors:door7d","7","Snow Flake",
{"default:steel_ingot", "default:steel_ingot", "dye:black"}, {{"default:steel_ingot", "default:steelblock", ""},
{"default:steelblock", "default:steelblock", ""}}, {"default:steel_ingot", "default:steel_ingot", ""},
{{"default:steel_ingot","default:steel_ingot", ""}, { "default:steel_ingot", "default:steelblock",""}}},
{"default:steelblock", "default:steelblock", ""}, {"my_future_doors:door8a","my_future_doors:door8b","my_future_doors:door8c","my_future_doors:door8d","8","Blue Steel",
{"default:steel_ingot", "default:steel_ingot", ""}}, {{"default:steel_ingot", "default:steelblock", ""},
{{"default:steel_ingot", "default:steelblock", ""}, {"default:steel_ingot", "default:steel_ingot", "dye:blue"},
{"default:steel_ingot", "default:steel_ingot", ""}, { "default:steel_ingot", "default:steelblock",""}}},
{ "default:steel_ingot", "default:steelblock",""}}, {"my_future_doors:door9a","my_future_doors:door9b","my_future_doors:door9c","my_future_doors:door9d","9","Tan Steel",
{{"default:steel_ingot", "default:steelblock", ""}, {{"default:steel_ingot", "default:steelblock", ""},
{"default:steel_ingot", "default:steel_ingot", "dye:blue"}, {"default:steel_ingot", "default:steel_ingot", "dye:brown"},
{ "default:steel_ingot", "default:steelblock",""}}, { "default:steel_ingot", "default:steelblock",""}}},
{{"default:steel_ingot", "default:steelblock", ""},
{"default:steel_ingot", "default:steel_ingot", "dye:brown"},
{ "default:steel_ingot", "default:steelblock",""}},
} }
for i in ipairs (doors) do
local doora = doors[i][1]
local doorb = doors[i][2]
local doorc = doors[i][3]
local doord = doors[i][4]
local num = doors[i][5]
local des = doors[i][6]
local recipe = recipes[i]
local function onplace(itemstack, placer, pointed_thing) local function add_door(doora, doorb, doorc, doord, num, des, recipe)
local pos1 = pointed_thing.above local function onplace(itemstack, placer, pointed_thing)
local pos2 = {x=pos1.x, y=pos1.y, z=pos1.z} local pos1 = pointed_thing.above
pos2.y = pos2.y+1 local pos2 = vector.add(pos1, {x=0,y=1,z=0})
if
not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or if not placer or not placer:is_player() then
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or return
not placer or end
not placer:is_player() then
return if not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
end not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to then
local pt = pointed_thing.above minetest.chat_send_player(placer:get_player_name(), "Not enough room")
local pt2 = {x=pt.x, y=pt.y, z=pt.z} return
pt2.y = pt2.y+1 end
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pt3 = {x=pt.x, y=pt.y, z=pt.z} local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local p4 = 0 local p4 = (p2+2)%4
if p2 == 0 then local pos3 = vector.add(pos1, minetest.facedir_to_dir((p2-1)%4))
pt3.x = pt3.x-1
p4 = 2 local player_name = placer:get_player_name()
elseif p2 == 1 then if minetest.is_protected(pos1, player_name) then
pt3.z = pt3.z+1 minetest.record_protection_violation(pos1, player_name)
p4 = 3 return
elseif p2 == 2 then end
pt3.x = pt3.x+1 if minetest.is_protected(pos2, player_name) then
p4 = 0 minetest.record_protection_violation(pos2, player_name)
elseif p2 == 3 then return
pt3.z = pt3.z-1 end
p4 = 1
end if minetest.get_node(pos3).name == doora then
if minetest.get_node(pt3).name == doora then minetest.set_node(pos1, {name=doora, param2=p4})
minetest.set_node(pt, {name=doora, param2=p4}) minetest.set_node(pos2, {name=doorb, param2=p4})
minetest.set_node(pt2, {name=doorb, param2=p4}) else
else minetest.set_node(pos1, {name=doora, param2=p2})
minetest.set_node(pt, {name=doora, param2=p2}) minetest.set_node(pos2, {name=doorb, param2=p2})
minetest.set_node(pt2, {name=doorb, param2=p2}) end
end
itemstack: take_item() if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
itemstack:take_item()
end
return itemstack return itemstack
end end
local function afterdestruct(pos, oldnode) local function afterdestruct(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
end end
local function rightclick(pos, node, player, itemstack, pointed_thing) local function rightclick(pos, node, player, itemstack, pointed_thing)
local timer = minetest.get_node_timer(pos) local timer = minetest.get_node_timer(pos)
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
local c = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
local d = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
minetest.set_node(pos, {name=doorc, param2=node.param2}) minetest.set_node(pos, {name=doorc, param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doord, param2=node.param2}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doord, param2=node.param2})
if a.name == doora then -- Open neighbouring doors
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doorc, param2=a.param2}) for i=0,3 do
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doord, param2=a.param2}) local dir = minetest.facedir_to_dir(i)
end local neighbour_pos = vector.add(pos, dir)
if b.name == doora then local neighbour = minetest.get_node(neighbour_pos)
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doorc, param2=b.param2}) if neighbour.name == "my_misc_doors:door2a" then
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doord, param2=b.param2}) minetest.set_node(neighbour_pos, {name=doorc, param2=neighbour.param2})
end minetest.set_node(vector.add(neighbour_pos, {x=0,y=1,z=0}), {name=doord, param2=neighbour.param2})
if c.name == doora then end
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doorc, param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doord, param2=c.param2})
end
if d.name == doora then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doorc, param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doord, param2=d.param2})
end end
timer:start(3) timer:start(3)
end
end local function afterplace(pos, placer, itemstack, pointed_thing)
local node = minetest.get_node(pos)
local timer = minetest.get_node_timer(pos)
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doord, param2=node.param2})
timer:start(3)
end
local function afterplace(pos, placer, itemstack, pointed_thing) local function ontimer(pos, elapsed)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name=doord,param2=nodeu.param2}) local node = minetest.get_node(pos)
end
local function ontimer(pos, elapsed)
local node = minetest.get_node(pos)
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
local c = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
local d = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
minetest.set_node(pos, {name=doora, param2=node.param2}) minetest.set_node(pos, {name=doora, param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doorb, param2=node.param2}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doorb, param2=node.param2})
if a.name == doorc then -- Close neighbouring doors
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doora, param2=a.param2}) for i=0,3 do
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doorb, param2=a.param2}) local dir = minetest.facedir_to_dir(i)
end local neighbour_pos = vector.add(pos, dir)
if b.name == doorc then local neighbour = minetest.get_node(neighbour_pos)
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doora, param2=b.param2}) if neighbour.name == "my_misc_doors:door2c" then
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doorb, param2=b.param2}) minetest.set_node(neighbour_pos, {name=doora, param2=neighbour.param2})
end minetest.set_node(vector.add(neighbour_pos, {x=0,y=1,z=0}), {name=doorb, param2=neighbour.param2})
if c.name == doorc then end
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doora, param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doorb, param2=c.param2})
end
if d.name == doorc then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doora, param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doorb, param2=d.param2})
end end
end
minetest.register_node(doora, {
description = des.." Sliding Door",
inventory_image = "myndoors_door"..num.."a_inv.png",
wield_image = "myndoors_door"..num.."a_inv.png",
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottom.png",
"myndoors_door"..num.."a_bottom.png^[transformFX"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 0.5, 0.0625}
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}
}
},
on_place = onplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doorb, {
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottom.png^[transformFY",
"myndoors_door"..num.."a_bottom.png^[transformFX^[transformFY"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 0.5, 0.0625}
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_node(doorc, {
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottomo.png",
"myndoors_door"..num.."a_bottomo.png^[transformFX"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = doora,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, -0.25, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, -0.25, 1.5, 0.0625},
}
},
after_place_node = afterplace,
after_destruct = afterdestruct,
on_timer = ontimer,
})
minetest.register_node(doord, {
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottomo.png^[transformFY",
"myndoors_door"..num.."a_bottomo.png^[transformFX^[transformFY"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, -0.25, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_craft({
output = "my_future_doors:door"..num.."a 2",
recipe = recipe
})
end end
minetest.register_node(doora, { for i, door in ipairs(doors) do
description = des.." Sliding Door", add_door(unpack(door))
inventory_image = "myndoors_door"..num.."a_inv.png",
wield_image = "myndoors_door"..num.."a_inv.png",
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottom.png",
"myndoors_door"..num.."a_bottom.png^[transformFX"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 0.5, 0.0625}
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}
}
},
on_place = onplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doorb, {
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottom.png^[transformFY",
"myndoors_door"..num.."a_bottom.png^[transformFX^[transformFY"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, 0.5, 0.5, 0.0625}
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})minetest.register_node(doorc, {
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottomo.png",
"myndoors_door"..num.."a_bottomo.png^[transformFX"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = doora,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, -0.25, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, -0.25, 1.5, 0.0625},
}
},
after_place_node = afterplace,
after_destruct = afterdestruct,
on_timer = ontimer,
})
minetest.register_node(doord, {
tiles = {
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_edge.png",
"myndoors_door"..num.."a_bottomo.png^[transformFY",
"myndoors_door"..num.."a_bottomo.png^[transformFX^[transformFY"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.5, -0.0625, -0.25, 0.5, 0.0625},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_craft({
output = "my_future_doors:door"..num.."a 2",
recipe = recipe
})
end end

View file

@ -11,11 +11,11 @@ minetest.register_node("my_garage_door:garage_door", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625}, {-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625}, {-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625},
{-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625}, {-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625},
{-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625}, {-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625},
{-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625}, {-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
} }
}, },
selection_box = { selection_box = {
@ -25,38 +25,74 @@ minetest.register_node("my_garage_door:garage_door", {
} }
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local p = pointed_thing.above local pos1 = pointed_thing.above
local p2 = minetest.dir_to_facedir(placer:get_look_dir()) local pos2 = vector.add(pos1, {x=0,y=1,z=0})
print(p2)
minetest.set_node(p, {name = "my_garage_door:garage_door",param2 = p2}) if not placer or not placer:is_player() then
minetest.set_node({x=p.x,y=p.y+1,z=p.z}, {name = "my_garage_door:garage_door_top",param2 = p2}) return
end
if not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to then
minetest.chat_send_player(placer:get_player_name(), "Not enough room")
return
end
local player_name = placer:get_player_name()
if minetest.is_protected(pos1, player_name) then
minetest.record_protection_violation(pos1, player_name)
return
end
if minetest.is_protected(pos2, player_name) then
minetest.record_protection_violation(pos2, player_name)
return
end
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
minetest.set_node(pos1, {name = "my_garage_door:garage_door", param2 = p2})
minetest.set_node(pos2, {name = "my_garage_door:garage_door_top", param2 = p2})
if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
itemstack:take_item()
end
return itemstack
end, end,
after_destruct = function(pos, oldnode) after_destruct = function(pos, oldnode)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "air"}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name = "air"})
end, end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local p2 = node.param2 --minetest.dir_to_facedir(player:get_look_dir()) local p2 = node.param2
local t1 = {x=pos.x,y=pos.y+1,z=pos.z} local dir = minetest.facedir_to_dir(p2)
local t2 = {x=pos.x,y=pos.y+1,z=pos.z} local above = vector.add(pos, {x=0,y=1,z=0})
if p2 == 0 then
t1 = {x=pos.x,y=pos.y+1,z=pos.z+1} local t1 = vector.add(above, dir)
t2 = {x=pos.x,y=pos.y+1,z=pos.z+2} local t2 = vector.add(t1, dir)
elseif p2 == 1 then
t1 = {x=pos.x+1,y=pos.y+1,z=pos.z} if not player or not player:is_player() then
t2 = {x=pos.x+2,y=pos.y+1,z=pos.z} return
elseif p2 == 2 then
t1 = {x=pos.x,y=pos.y+1,z=pos.z-1}
t2 = {x=pos.x,y=pos.y+1,z=pos.z-2}
elseif p2 == 3 then
t1 = {x=pos.x-1,y=pos.y+1,z=pos.z}
t2 = {x=pos.x-2,y=pos.y+1,z=pos.z}
end end
minetest.set_node(t1,{name="my_garage_door:garage_door_open",param2=p2})
minetest.set_node(t2,{name="my_garage_door:garage_door_open2",param2=p2}) if not minetest.registered_nodes[minetest.get_node(t1).name].buildable_to or
minetest.set_node(pos,{name="air"}) not minetest.registered_nodes[minetest.get_node(t2).name].buildable_to then
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) minetest.chat_send_player(player:get_player_name(), "Not enough room to open")
--end return
end
local player_name = player:get_player_name()
if minetest.is_protected(t1, player_name) then
minetest.record_protection_violation(t1, player_name)
return
end
if minetest.is_protected(t2, player_name) then
minetest.record_protection_violation(t2, player_name)
return
end
minetest.set_node(t1, {name="my_garage_door:garage_door_open", param2=p2})
minetest.set_node(t2, {name="my_garage_door:garage_door_open2", param2=p2})
minetest.set_node(pos, {name="air"})
minetest.set_node(above, {name="air"})
end, end,
}) })
minetest.register_node("my_garage_door:garage_door_top", { minetest.register_node("my_garage_door:garage_door_top", {
@ -73,11 +109,11 @@ minetest.register_node("my_garage_door:garage_door_top", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625}, {-1.5, -0.5, -0.125, 1.5, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625}, {-1.5, -0.5, -0.1875, 1.5, -0.3125, -0.0625},
{-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625}, {-1.5, -0.25, -0.1875, 1.5, -0.0624999, -0.0625},
{-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625}, {-1.5, 0, -0.1875, 1.5, 0.1875, -0.0625},
{-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625}, {-1.5, 0.25, -0.1875, 1.5, 0.4375, -0.0625},
} }
}, },
selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}}, selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},
@ -95,41 +131,48 @@ minetest.register_node("my_garage_door:garage_door_open", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5}, {-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5},
{-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5}, {-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5},
{-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25}, {-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25},
{-1.5, 0.375, -0.1875, 1.5, 0.5, 0}, {-1.5, 0.375, -0.1875, 1.5, 0.5, 0},
{-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25}, {-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
} }
}, },
selection_box = {type = "fixed",fixed = {{-1.5, 0.375, -0.5, 1.5, 0.5, 1.5},}}, selection_box = {type = "fixed",fixed = {{-1.5, 0.375, -0.5, 1.5, 0.5, 1.5},}},
on_rightclick = function(pos, node, player, itemstack, pointed_thing) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local p2 = node.param2 --minetest.dir_to_facedir(player:get_look_dir()) local p2 = node.param2
local t1 = {x=pos.x,y=pos.y+1,z=pos.z} local dir = minetest.facedir_to_dir((p2+2)%4)
local t2 = {x=pos.x,y=pos.y+1,z=pos.z}
local t3 local t1 = vector.add(pos, dir)
if p2 == 0 then local t2 = vector.subtract(t1, {x=0,y=1,z=0})
t1 = {x=pos.x,y=pos.y,z=pos.z-1}
t2 = {x=pos.x,y=pos.y-1,z=pos.z-1} if not player or not player:is_player() then
t3 = {x=pos.x,y=pos.y,z=pos.z+1} return
elseif p2 == 1 then
t1 = {x=pos.x-1,y=pos.y,z=pos.z}
t2 = {x=pos.x-1,y=pos.y-1,z=pos.z}
t3 = {x=pos.x+1,y=pos.y,z=pos.z}
elseif p2 == 2 then
t1 = {x=pos.x,y=pos.y,z=pos.z+1}
t2 = {x=pos.x,y=pos.y-1,z=pos.z+1}
t3 = {x=pos.x,y=pos.y,z=pos.z-1}
elseif p2 == 3 then
t1 = {x=pos.x+1,y=pos.y,z=pos.z}
t2 = {x=pos.x+1,y=pos.y-1,z=pos.z}
t3 = {x=pos.x-1,y=pos.y,z=pos.z}
end end
minetest.set_node(t1,{name="my_garage_door:garage_door_top",param2=p2})
minetest.set_node(t2,{name="my_garage_door:garage_door",param2=p2}) if not minetest.registered_nodes[minetest.get_node(t1).name].buildable_to or
minetest.set_node(pos,{name="air"}) not minetest.registered_nodes[minetest.get_node(t2).name].buildable_to then
minetest.set_node(t3,{name="air"}) minetest.chat_send_player(player:get_player_name(), "Not enough room to close")
return
end
local player_name = player:get_player_name()
if minetest.is_protected(t1, player_name) then
minetest.record_protection_violation(t1, player_name)
return
end
if minetest.is_protected(t2, player_name) then
minetest.record_protection_violation(t2, player_name)
return
end
local t3 = vector.subtract(pos, dir)
minetest.set_node(t1, {name="my_garage_door:garage_door_top", param2=p2})
minetest.set_node(t2, {name="my_garage_door:garage_door", param2=p2})
minetest.set_node(pos, {name="air"})
minetest.set_node(t3, {name="air"})
end, end,
}) })
minetest.register_node("my_garage_door:garage_door_open2", { minetest.register_node("my_garage_door:garage_door_open2", {
@ -146,11 +189,11 @@ minetest.register_node("my_garage_door:garage_door_open2", {
node_box = { node_box = {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5}, {-1.5, 0.4375, -0.5, 1.5, 0.375, 0.5},
{-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5}, {-1.5, 0.375, 0.3125, 1.5, 0.5, 0.5},
{-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25}, {-1.5, 0.375, 0.0625, 1.5, 0.5, 0.25},
{-1.5, 0.375, -0.1875, 1.5, 0.5, 0}, {-1.5, 0.375, -0.1875, 1.5, 0.5, 0},
{-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25}, {-1.5, 0.375, -0.4375, 1.5, 0.5, -0.25},
} }
}, },
selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}}, selection_box = {type = "fixed",fixed = {{0, 0, 0, 0, 0, 0},}},

View file

@ -10,23 +10,22 @@ local hdoor_list = { --Number , Description , default image
{ "bookshelf", "Hidden Bookshelf Door" , "mydoors_bookshelf" , "door9"}, { "bookshelf", "Hidden Bookshelf Door" , "mydoors_bookshelf" , "door9"},
} }
local function add_door(img, desc)
for i in ipairs(hdoor_list) do doors.register_door("my_hidden_doors:hidden_door"..img, {
local img = hdoor_list[i][1] description = desc.." Locked",
local desc = hdoor_list[i][2] inventory_image = "mydoors_"..img.."_inv.png",
--local dimg = hdoor_list[i][3] groups = {choppy=2,cracky=2,door=1},
only_placer_can_open = false,
tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }},
doors.register_door("my_hidden_doors:hidden_door"..img, { protected = false,
description = desc.." Locked", })
inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
only_placer_can_open = false,
tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }},
protected = false,
})
end end
for _,hdoor in ipairs(hdoor_list) do
add_door(unpack(hdoor))
end
doors.register_door("my_hidden_doors:hidden_door_grey", { doors.register_door("my_hidden_doors:hidden_door_grey", {
description = "Grey Door Locked", description = "Grey Door Locked",
inventory_image = "mydoors_grey_inv.png", inventory_image = "mydoors_grey_inv.png",
@ -34,6 +33,8 @@ doors.register_door("my_hidden_doors:hidden_door_grey", {
tiles = {{ name = "mydoors_grey.png", backface_culling = true }}, tiles = {{ name = "mydoors_grey.png", backface_culling = true }},
protected = false, protected = false,
}) })
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -17,10 +17,10 @@ minetest.register_node("my_misc_doors:door2a", {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.4375, -0.5, -0.0625, -0.3125, 0.5, 0.0625}, {-0.4375, -0.5, -0.0625, -0.3125, 0.5, 0.0625},
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}, {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{0.3125, -0.5, -0.0625, 0.4375, 0.5, 0.0625}, { 0.3125, -0.5, -0.0625, 0.4375, 0.5, 0.0625},
{0.125, -0.5, -0.0625, 0.25, 0.5, 0.0625}, { 0.125, -0.5, -0.0625, 0.25, 0.5, 0.0625},
{-0.25, -0.5, -0.0625, -0.125, 0.5, 0.0625}, {-0.25, -0.5, -0.0625, -0.125, 0.5, 0.0625},
} }
}, },
selection_box = { selection_box = {
@ -30,76 +30,68 @@ minetest.register_node("my_misc_doors:door2a", {
} }
}, },
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local pos1 = pointed_thing.above local pos1 = pointed_thing.above
local pos2 = {x=pos1.x, y=pos1.y, z=pos1.z} local pos2 = vector.add(pos1, {x=0,y=1,z=0})
pos2.y = pos2.y+1
if if not placer or not placer:is_player() then
not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or return
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or end
not placer or
not placer:is_player() then if not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
return not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to then
end minetest.chat_send_player(placer:get_player_name(), "Not enough room")
local pt = pointed_thing.above return
local pt2 = {x=pt.x, y=pt.y, z=pt.z} end
pt2.y = pt2.y+1
local p2 = minetest.dir_to_facedir(placer:get_look_dir()) local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pt3 = {x=pt.x, y=pt.y, z=pt.z} local p4 = (p2+2)%4
local p4 = 0 local pos3 = vector.add(pos1, minetest.facedir_to_dir((p2-1)%4))
if p2 == 0 then
pt3.x = pt3.x-1 local player_name = placer:get_player_name()
p4 = 2 if minetest.is_protected(pos1, player_name) then
elseif p2 == 1 then minetest.record_protection_violation(pos1, player_name)
pt3.z = pt3.z+1 return
p4 = 3 end
elseif p2 == 2 then if minetest.is_protected(pos2, player_name) then
pt3.x = pt3.x+1 minetest.record_protection_violation(pos2, player_name)
p4 = 0 return
elseif p2 == 3 then end
pt3.z = pt3.z-1
p4 = 1 if minetest.get_node(pos3).name == "my_misc_doors:door2a" then
end minetest.set_node(pos1, {name="my_misc_doors:door2a", param2=p4})
if minetest.get_node(pt3).name == "my_misc_doors:door2a" then minetest.set_node(pos2, {name="my_misc_doors:door2b", param2=p4})
minetest.set_node(pt, {name="my_misc_doors:door2a", param2=p4}) else
minetest.set_node(pt2, {name="my_misc_doors:door2b", param2=p4}) minetest.set_node(pos1, {name="my_misc_doors:door2a", param2=p2})
else minetest.set_node(pos2, {name="my_misc_doors:door2b", param2=p2})
minetest.set_node(pt, {name="my_misc_doors:door2a", param2=p2}) end
minetest.set_node(pt2, {name="my_misc_doors:door2b", param2=p2})
end if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
end, itemstack:take_item()
after_destruct = function(pos, oldnode) end
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) return itemstack
end, end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing) after_destruct = function(pos, oldnode)
local timer = minetest.get_node_timer(pos) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1}) end,
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1}) on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local c = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z}) local timer = minetest.get_node_timer(pos)
local d = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
minetest.set_node(pos, {name="my_misc_doors:door2c", param2=node.param2}) minetest.set_node(pos, {name="my_misc_doors:door2c", param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2d", param2=node.param2}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_misc_doors:door2d", param2=node.param2})
if a.name == "my_misc_doors:door2a" then -- Open neighbouring doors
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name="my_misc_doors:door2c", param2=a.param2}) for i=0,3 do
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name="my_misc_doors:door2d", param2=a.param2}) local dir = minetest.facedir_to_dir(i)
end local neighbour_pos = vector.add(pos, dir)
if b.name == "my_misc_doors:door2a" then local neighbour = minetest.get_node(neighbour_pos)
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name="my_misc_doors:door2c", param2=b.param2}) if neighbour.name == "my_misc_doors:door2a" then
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name="my_misc_doors:door2d", param2=b.param2}) minetest.set_node(neighbour_pos, {name="my_misc_doors:door2c", param2=neighbour.param2})
end minetest.set_node(vector.add(neighbour_pos, {x=0,y=1,z=0}), {name="my_misc_doors:door2d", param2=neighbour.param2})
if c.name == "my_misc_doors:door2a" then end
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name="my_misc_doors:door2c", param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2d", param2=c.param2})
end
if d.name == "my_misc_doors:door2a" then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name="my_misc_doors:door2c", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2d", param2=d.param2})
end end
timer:start(3) timer:start(3)
end,
end,
}) })
minetest.register_node("my_misc_doors:door2b", { minetest.register_node("my_misc_doors:door2b", {
tiles = { tiles = {
@ -113,10 +105,10 @@ minetest.register_node("my_misc_doors:door2b", {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.4375, -0.5, -0.0625, -0.3125, 0.5, 0.0625}, {-0.4375, -0.5, -0.0625, -0.3125, 0.5, 0.0625},
{-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625}, {-0.0625, -0.5, -0.0625, 0.0625, 0.5, 0.0625},
{0.3125, -0.5, -0.0625, 0.4375, 0.5, 0.0625}, { 0.3125, -0.5, -0.0625, 0.4375, 0.5, 0.0625},
{0.125, -0.5, -0.0625, 0.25, 0.5, 0.0625}, { 0.125, -0.5, -0.0625, 0.25, 0.5, 0.0625},
{-0.25, -0.5, -0.0625, -0.125, 0.5, 0.0625}, {-0.25, -0.5, -0.0625, -0.125, 0.5, 0.0625},
} }
}, },
selection_box = { selection_box = {
@ -143,10 +135,10 @@ minetest.register_node("my_misc_doors:door2c", {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.4375, -0.375, -0.0625, -0.3125, -0.5, 0.0625}, {-0.4375, -0.375, -0.0625, -0.3125, -0.5, 0.0625},
{-0.0625, -0.375, -0.0625, 0.0625, -0.5, 0.0625}, {-0.0625, -0.375, -0.0625, 0.0625, -0.5, 0.0625},
{0.3125, -0.375, -0.0625, 0.4375, -0.5, 0.0625}, { 0.3125, -0.375, -0.0625, 0.4375, -0.5, 0.0625},
{0.125, -0.375, -0.0625, 0.25, -0.5, 0.0625}, { 0.125, -0.375, -0.0625, 0.25, -0.5, 0.0625},
{-0.25, -0.375, -0.0625, -0.125, -0.5, 0.0625}, {-0.25, -0.375, -0.0625, -0.125, -0.5, 0.0625},
} }
}, },
selection_box = { selection_box = {
@ -155,39 +147,32 @@ minetest.register_node("my_misc_doors:door2c", {
{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0},
} }
}, },
after_place_node = function(pos, placer, itemstack, pointed_thing) drop = "my_misc_doors:door2a",
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_misc_doors:door2d",param2=nodeu.param2}) after_place_node = function(pos, placer, itemstack, pointed_thing)
end, local node = minetest.get_node(pos)
after_destruct = function(pos, oldnode) local timer = minetest.get_node_timer(pos)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_misc_doors:door2d",param2=node.param2})
end, timer:start(3)
on_timer = function(pos, elapsed) end,
local node = minetest.get_node(pos) after_destruct = function(pos, oldnode)
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1}) end,
local c = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z}) on_timer = function(pos, elapsed)
local d = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z}) local node = minetest.get_node(pos)
minetest.set_node(pos, {name="my_misc_doors:door2a", param2=node.param2}) minetest.set_node(pos, {name="my_misc_doors:door2a", param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2b", param2=node.param2}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="my_misc_doors:door2b", param2=node.param2})
if a.name == "my_misc_doors:door2c" then -- Close neighbouring doors
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name="my_misc_doors:door2a", param2=a.param2}) for i=0,3 do
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name="my_misc_doors:door2b", param2=a.param2}) local dir = minetest.facedir_to_dir(i)
local neighbour_pos = vector.add(pos, dir)
local neighbour = minetest.get_node(neighbour_pos)
if neighbour.name == "my_misc_doors:door2c" then
minetest.set_node(neighbour_pos, {name="my_misc_doors:door2a", param2=neighbour.param2})
minetest.set_node(vector.add(neighbour_pos, {x=0,y=1,z=0}), {name="my_misc_doors:door2b", param2=neighbour.param2})
end
end end
if b.name == "my_misc_doors:door2c" then end,
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name="my_misc_doors:door2a", param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name="my_misc_doors:door2b", param2=b.param2})
end
if c.name == "my_misc_doors:door2c" then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name="my_misc_doors:door2a", param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2b", param2=c.param2})
end
if d.name == "my_misc_doors:door2c" then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name="my_misc_doors:door2a", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name="my_misc_doors:door2b", param2=d.param2})
end
end,
}) })
minetest.register_node("my_misc_doors:door2d", { minetest.register_node("my_misc_doors:door2d", {
tiles = { tiles = {
@ -206,10 +191,10 @@ minetest.register_node("my_misc_doors:door2d", {
type = "fixed", type = "fixed",
fixed = { fixed = {
{-0.4375, 0.375, -0.0625, -0.3125, 0.5, 0.0625}, {-0.4375, 0.375, -0.0625, -0.3125, 0.5, 0.0625},
{-0.0625, 0.375, -0.0625, 0.0625, 0.5, 0.0625}, {-0.0625, 0.375, -0.0625, 0.0625, 0.5, 0.0625},
{0.3125, 0.375, -0.0625, 0.4375, 0.5, 0.0625}, { 0.3125, 0.375, -0.0625, 0.4375, 0.5, 0.0625},
{0.125, 0.375, -0.0625, 0.25, 0.5, 0.0625}, { 0.125, 0.375, -0.0625, 0.25, 0.5, 0.0625},
{-0.25, 0.375, -0.0625, -0.125, 0.5, 0.0625}, {-0.25, 0.375, -0.0625, -0.125, 0.5, 0.0625},
} }
}, },
selection_box = { selection_box = {

View file

@ -6,21 +6,21 @@ local mdoor_list = { --Number , Description , Inven Image , Image
-- {"Misc Door 5" , "door5"}, -- {"Misc Door 5" , "door5"},
} }
local function add_door(desc, img)
for i in ipairs(mdoor_list) do doors.register_door("my_misc_doors:"..img.."_locked", {
local desc = mdoor_list[i][1] description = desc.." Locked",
local img = mdoor_list[i][2] inventory_image = "mymdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mymdoors_"..img..".png", backface_culling = true }},
doors.register_door("my_misc_doors:"..img.."_locked", { protected = true,
description = desc.." Locked", })
inventory_image = "mymdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mymdoors_"..img..".png", backface_culling = true }},
protected = true,
})
end end
for _,mdoor in ipairs(mdoor_list) do
add_door(unpack(mdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -6,21 +6,21 @@ local mdoor_list = { --Number , Description , Inven Image , Image
{"Misc Door 5" , "door5"}, {"Misc Door 5" , "door5"},
} }
local function add_door(desc, img)
for i in ipairs(mdoor_list) do doors.register_door("my_misc_doors:"..img, {
local desc = mdoor_list[i][1] description = desc,
local img = mdoor_list[i][2] inventory_image = "mymdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mymdoors_"..img..".png", backface_culling = true }},
doors.register_door("my_misc_doors:"..img, { protected = false,
description = desc, })
inventory_image = "mymdoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1},
tiles = {{name="mymdoors_"..img..".png", backface_culling = true }},
protected = false,
})
end end
for _,mdoor in ipairs(mdoor_list) do
add_door(unpack(mdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -4,21 +4,22 @@ local cdoor_list = { --Number , Description , Inven Image , Image
{ "3", "Old Door 3" , "old3"}, { "3", "Old Door 3" , "old3"},
{ "4", "Old Door 4" , "old4"}, { "4", "Old Door 4" , "old4"},
} }
for i in ipairs(cdoor_list) do
local num = cdoor_list[i][1]
local desc = cdoor_list[i][2]
local img = cdoor_list[i][3]
local function add_door(num, desc, img)
doors.register_door("my_old_doors:door"..num.."_locked", { doors.register_door("my_old_doors:door"..num.."_locked", {
description = desc.." Locked", description = desc.." Locked",
inventory_image = "mydoors_"..img.."_inv.png", inventory_image = "mydoors_"..img.."_inv.png",
groups = {choppy=2,cracky=2,door=1}, groups = {choppy=2,cracky=2,door=1},
tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }}, tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }},
protected = true, protected = true,
}) })
end end
for _,cdoor in ipairs(cdoor_list) do
add_door(unpack(cdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -4,20 +4,22 @@ local cdoor_list = { --Number , Description , Inven Image , Image
-- { "3", "Old Door 3" , "old3"}, -- { "3", "Old Door 3" , "old3"},
-- { "4", "Old Door 4" , "old4"}, -- { "4", "Old Door 4" , "old4"},
} }
for i in ipairs(cdoor_list) do
local num = cdoor_list[i][1]
local desc = cdoor_list[i][2]
local img = cdoor_list[i][3]
doors.register_door("my_old_doors:door"..num, { local function add_door(num, desc, img)
description = desc, doors.register_door("my_old_doors:door"..num, {
inventory_image = "mydoors_"..img.."_inv.png", description = desc,
groups = {choppy=2,cracky=2,door=1}, inventory_image = "mydoors_"..img.."_inv.png",
tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }}, groups = {choppy=2,cracky=2,door=1},
protected = true, tiles = {{ name = "mydoors_"..img..".png", backface_culling = true }},
}) protected = true,
})
end end
for _,cdoor in ipairs(cdoor_list) do
add_door(unpack(cdoor))
end
-- Crafts -- Crafts
minetest.register_craft({ minetest.register_craft({

View file

@ -1,4 +1,3 @@
local doorcol = { local doorcol = {
{"white", "White", "^[colorize:white:120"}, {"white", "White", "^[colorize:white:120"},
{"red", "Red", "^[colorize:red:120"}, {"red", "Red", "^[colorize:red:120"},
@ -7,103 +6,114 @@ local doorcol = {
{"grey", "Grey", "^[colorize:white:120^[colorize:black:120"}, {"grey", "Grey", "^[colorize:white:120^[colorize:black:120"},
{"dark_grey", "Dark grey", "^[colorize:white:120^[colorize:black:200"}, {"dark_grey", "Dark grey", "^[colorize:white:120^[colorize:black:200"},
{"yellow", "Yellow", "^[colorize:yellow:100"}, {"yellow", "Yellow", "^[colorize:yellow:100"},
} }
for i in ipairs (doorcol) do
local col = doorcol[i][1]
local des = doorcol[i][2]
local tint = doorcol[i][3]
minetest.register_node("my_saloon_doors:door1a_"..col, { local function add_door(col, des, tint)
description = des.." Saloon Door ", minetest.register_node("my_saloon_doors:door1a_"..col, {
tiles = {"mydoors_saloon_bottom.png"..tint}, description = des.." Saloon Door ",
drawtype = "nodebox", tiles = {"mydoors_saloon_bottom.png"..tint},
paramtype = "light", drawtype = "nodebox",
paramtype2 = "facedir", paramtype = "light",
groups = {cracky = 3}, paramtype2 = "facedir",
node_box = { groups = {cracky = 3},
type = "fixed", node_box = {
fixed = { type = "fixed",
{-0.5, -0.1875, -0.0625, 0, 0.75, 0.0625}, fixed = {
{-0.5, 0.75, -0.0625, -0.0625, 0.8125, 0.0625}, {-0.5, -0.1875, -0.0625, 0, 0.75, 0.0625},
{-0.5, 0.8125, -0.0625, -0.125, 0.875, 0.0625}, {-0.5, 0.75, -0.0625, -0.0625, 0.8125, 0.0625},
{-0.5, 0.875, -0.0625, -0.1875, 0.9375, 0.0625}, {-0.5, 0.8125, -0.0625, -0.125, 0.875, 0.0625},
{-0.5, 0.9375, -0.0625, -0.3125, 1, 0.0625}, {-0.5, 0.875, -0.0625, -0.1875, 0.9375, 0.0625},
{-0, -0.1875, -0.0625, 0.5, 0.75, 0.0625}, {-0.5, 0.9375, -0.0625, -0.3125, 1, 0.0625},
{0.0625, 0.75, -0.0625, 0.5, 0.8125, 0.0625}, {-0, -0.1875, -0.0625, 0.5, 0.75, 0.0625},
{0.125, 0.8125, -0.0625, 0.5, 0.875, 0.0625}, { 0.0625, 0.75, -0.0625, 0.5, 0.8125, 0.0625},
{0.1875, 0.875, -0.0625, 0.5, 0.9375, 0.0625}, { 0.125, 0.8125, -0.0625, 0.5, 0.875, 0.0625},
{0.3125, 0.9375, -0.0625, 0.5, 1, 0.0625}, { 0.1875, 0.875, -0.0625, 0.5, 0.9375, 0.0625},
} { 0.3125, 0.9375, -0.0625, 0.5, 1, 0.0625},
}, }
selection_box = { },
type = "fixed", selection_box = {
fixed = { type = "fixed",
{-0.5, -0.1875, -0.0625, 0.5, 1, 0.0625}, fixed = {
} {-0.5, -0.1875, -0.0625, 0.5, 1, 0.0625},
}, }
},
on_place = function(itemstack, placer, pointed_thing) on_place = function(itemstack, placer, pointed_thing)
local pos1 = pointed_thing.above local pos1 = pointed_thing.above
local pos2 = {x=pos1.x, y=pos1.y, z=pos1.z} local pos2 = vector.add(pos1, {x=0,y=1,z=0})
pos2.y = pos2.y+1
if if not placer or not placer:is_player() then
not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or return
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or end
not placer or
not placer:is_player() then
return
end
return minetest.item_place(itemstack, placer, pointed_thing)
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local timer = minetest.get_node_timer(pos) if not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
local par1 = node.param2 not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to then
local par2 = minetest.dir_to_facedir(player:get_look_dir()) minetest.chat_send_player(placer:get_player_name(), "Not enough room")
if par1 + par2 == 1 or return
par1 + par2 == 3 or end
par1 + par2 == 5 then
par2 = par1
end
if node.name == "my_saloon_doors:door1a_"..col then
minetest.set_node(pos,{name="my_saloon_doors:door1b_"..col,param2=par2})
timer:start(3)
end
end,
})
minetest.register_node("my_saloon_doors:door1b_"..col, {
tiles = {"mydoors_saloon_bottom.png^[transformFY"..tint},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.1875, -0.0625, -0.375, 0.75, 0.5},
{-0.5, 0.75, -0.0625, -0.375, 0.8125, 0.4375},
{-0.5, 0.8125, -0.0625, -0.375, 0.875, 0.375},
{-0.5, 0.875, -0.0625, -0.375, 0.9375, 0.3125},
{-0.5, 0.9375, -0.0625, -0.375, 1, 0.1875},
{0.375, -0.1875, -0.0625, 0.5, 0.75, 0.5},
{0.375, 0.75, -0.0625, 0.5, 0.8125, 0.4375},
{0.375, 0.8125, -0.0625, 0.5, 0.875, 0.375},
{0.375, 0.875, -0.0625, 0.5, 0.9375, 0.3125},
{0.375, 0.9375, -0.0625, 0.5, 1, 0.1875},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
on_timer = function(pos, elapsed) local player_name = placer:get_player_name()
local node = minetest.get_node(pos) if minetest.is_protected(pos1, player_name) then
minetest.set_node(pos,{name="my_saloon_doors:door1a_"..col,param2=node.param2}) minetest.record_protection_violation(pos1, player_name)
-- minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="my_saloon_doors:door1b_"..col,param2=node.param2}) return
end, end
}) if minetest.is_protected(pos2, player_name) then
minetest.record_protection_violation(pos2, player_name)
return
end
return minetest.item_place(itemstack, placer, pointed_thing)
end,
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
local timer = minetest.get_node_timer(pos)
local par1 = node.param2
local par2 = minetest.dir_to_facedir(player:get_look_dir())
if par1 + par2 == 1 or
par1 + par2 == 3 or
par1 + par2 == 5 then
par2 = par1
end
if node.name == "my_saloon_doors:door1a_"..col then
minetest.set_node(pos, {name="my_saloon_doors:door1b_"..col, param2=par2})
timer:start(3)
end
end,
})
minetest.register_node("my_saloon_doors:door1b_"..col, {
tiles = {"mydoors_saloon_bottom.png^[transformFY"..tint},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.5, -0.1875, -0.0625, -0.375, 0.75, 0.5},
{-0.5, 0.75, -0.0625, -0.375, 0.8125, 0.4375},
{-0.5, 0.8125, -0.0625, -0.375, 0.875, 0.375},
{-0.5, 0.875, -0.0625, -0.375, 0.9375, 0.3125},
{-0.5, 0.9375, -0.0625, -0.375, 1, 0.1875},
{ 0.375, -0.1875, -0.0625, 0.5, 0.75, 0.5},
{ 0.375, 0.75, -0.0625, 0.5, 0.8125, 0.4375},
{ 0.375, 0.8125, -0.0625, 0.5, 0.875, 0.375},
{ 0.375, 0.875, -0.0625, 0.5, 0.9375, 0.3125},
{ 0.375, 0.9375, -0.0625, 0.5, 1, 0.1875},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
on_timer = function(pos, elapsed)
local node = minetest.get_node(pos)
minetest.set_node(pos, {name="my_saloon_doors:door1a_"..col, param2=node.param2})
-- minetest.set_node(vector.add(pos, {x=0,y=1,z=0}),{name="my_saloon_doors:door1b_"..col,param2=node.param2})
end,
})
end
for _,door in ipairs(doorcol) do
add_door(unpack(door))
end end

View file

@ -1,3 +1,2 @@
dofile(minetest.get_modpath("my_sliding_doors").."/jdoors1.lua") dofile(minetest.get_modpath("my_sliding_doors").."/jdoors1.lua")
dofile(minetest.get_modpath("my_sliding_doors").."/jdoors2.lua") dofile(minetest.get_modpath("my_sliding_doors").."/jdoors2.lua")

View file

@ -2,437 +2,470 @@ local doors = {
{"my_sliding_doors:door1a","my_sliding_doors:door1b","my_sliding_doors:door1c","my_sliding_doors:door1d","1","White"}, {"my_sliding_doors:door1a","my_sliding_doors:door1b","my_sliding_doors:door1c","my_sliding_doors:door1d","1","White"},
{"my_sliding_doors:door2a","my_sliding_doors:door2b","my_sliding_doors:door2c","my_sliding_doors:door2d","2","Flower"}, {"my_sliding_doors:door2a","my_sliding_doors:door2b","my_sliding_doors:door2c","my_sliding_doors:door2d","2","Flower"},
{"my_sliding_doors:door3a","my_sliding_doors:door3b","my_sliding_doors:door3c","my_sliding_doors:door3d","3","Framed"}, {"my_sliding_doors:door3a","my_sliding_doors:door3b","my_sliding_doors:door3c","my_sliding_doors:door3d","3","Framed"},
} }
for i in ipairs (doors) do
local doora = doors[i][1]
local doorb = doors[i][2]
local doorc = doors[i][3]
local doord = doors[i][4]
local num = doors[i][5]
local des = doors[i][6]
function onplace(itemstack, placer, pointed_thing) local function add_door(doora, doorb, doorc, doord, num, des)
local function onplace(itemstack, placer, pointed_thing)
local pos1 = pointed_thing.above
local pos = pos1
local pos2 = minetest.find_node_near(pos1, 1, {doora})
local par = minetest.dir_to_facedir(placer:get_look_dir())
local par2 = par + 2
local above = vector.add(pos, {x=0,y=1,z=0})
if not placer or not placer:is_player() then
return
end
local pos1 = pointed_thing.above if not minetest.registered_nodes[minetest.get_node(pos).name].buildable_to or
local pos = pos1 not minetest.registered_nodes[minetest.get_node(above).name].buildable_to then
local pos2 = minetest.find_node_near(pos1, 1, {doora}) minetest.chat_send_player(placer:get_player_name(), "Not enough room")
local par = minetest.dir_to_facedir(placer:get_look_dir()) return
local par2 = par + 2 end
local player_name = placer:get_player_name()
if minetest.is_protected(pos, player_name) then
minetest.record_protection_violation(pos, player_name)
return
end
if minetest.is_protected(above, player_name) then
minetest.record_protection_violation(above, player_name)
return
end
if par2 == 4 then par2 = 0 end if par2 == 4 then par2 = 0 end
if par2 == 5 then par2 = 1 end if par2 == 5 then par2 = 1 end
if pos2 == nil then if pos2 == nil then
minetest.set_node(pos, {name=doora,param2=par}) minetest.set_node(pos, {name=doora,param2=par})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doorb,param2=par}) minetest.set_node(above, {name=doorb,param2=par})
else else
minetest.set_node(pos, {name=doora.."2",param2=par2}) minetest.set_node(pos, {name=doora.."2",param2=par2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doorb.."2",param2=par2}) minetest.set_node(above, {name=doorb.."2",param2=par2})
end end
end if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
itemstack:take_item()
end
return itemstack
function afterdestruct(pos, oldnode) end
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"})
end
function rightclick(pos, node, player, itemstack, pointed_thing) local function afterdestruct(pos, oldnode)
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
end
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1}) local function rightclick(pos, node, player, itemstack, pointed_thing)
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
local c = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
local d = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
if node.name == doora then if node.name == doora then
minetest.set_node(pos, {name=doorc, param2=node.param2}) minetest.set_node(pos, {name=doorc, param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doord, param2=node.param2}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doord, param2=node.param2})
elseif node.name == doorc then elseif node.name == doorc then
minetest.set_node(pos, {name=doora, param2=node.param2}) minetest.set_node(pos, {name=doora, param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doorb, param2=node.param2}) minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doorb, param2=node.param2})
end end
if a.name == doora then -- Open neighbouring doors
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doorc, param2=a.param2}) for i=0,3 do
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doord, param2=a.param2}) local dir = minetest.facedir_to_dir(i)
local neighbour_pos = vector.add(pos, dir)
local neighbour_above = vector.add(neighbour_pos, {x=0,y=1,z=0})
local neighbour = minetest.get_node(neighbour_pos)
if neighbour.name == doora then
minetest.set_node(neighbour_pos, {name=doorc, param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doord, param2=neighbour.param2})
elseif neighbour.name == doora.."2" then
minetest.set_node(neighbour_pos, {name=doorc.."2", param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doord.."2", param2=neighbour.param2})
elseif neighbour.name == doorc then
minetest.set_node(neighbour_pos, {name=doora, param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doorb, param2=neighbour.param2})
elseif neighbour.name == doorc.."2" then
minetest.set_node(neighbour_pos, {name=doora.."2", param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doorb.."2", param2=neighbour.param2})
end
end end
if b.name == doora then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doorc, param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doord, param2=b.param2})
end
if c.name == doora then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doorc, param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doord, param2=c.param2})
end
if d.name == doora then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doorc, param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doord, param2=d.param2})
end
if a.name == doora.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doorc.."2", param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doord.."2", param2=a.param2})
end
if b.name == doora.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doorc.."2", param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doord.."2", param2=b.param2})
end
if c.name == doora.."2" then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doorc.."2", param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doord.."2", param2=c.param2})
end
if d.name == doora.."2" then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doorc.."2", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doord.."2", param2=d.param2})
end
if a.name == doorc then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doora, param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doorb, param2=a.param2})
end
if b.name == doorc then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doora, param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doorb, param2=b.param2})
end
if c.name == doorc then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doora, param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doorb, param2=c.param2})
end
if d.name == doorc then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doora, param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doorb, param2=d.param2})
end
if a.name == doorc.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doora.."2", param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doorb.."2", param2=a.param2})
end
if b.name == doorc.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doora.."2", param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doorb.."2", param2=b.param2})
end
if c.name == doorc.."2" then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doora.."2", param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doorb.."2", param2=c.param2})
end
if d.name == doorc.."2" then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doora.."2", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doorb.."2", param2=d.param2})
end
end
function afterplace(pos, placer, itemstack, pointed_thing)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name=doord,param2=nodeu.param2})
end
minetest.register_node(doora, {
description = des.." Sliding Door",
inventory_image = "myjdoors_door"..num.."a_inv.png",
wield_image = "myjdoors_door"..num.."a_inv.png",
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{0.375, -0.5, 0.1875, 0.5, 0.5, 0.0625},
{-0.5, -0.5, 0.1875, -0.375, 0.5, 0.0625},
{-0.5, -0.5, 0.1875, 0.5, -0.375, 0.0625},
{-0.5, -0.5, 0.125, 0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {type = "fixed",fixed = {{-1.5, -0.5, -0.0625, -0.5, 1.5, 0.0625},{-0.5, -0.5, 0.0625, 0.5, 1.5, 0.1875}}},
on_place = onplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doorb, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{0.375, -0.5, 0.1875, 0.5, 0.5, 0.0625},
{-0.5, -0.5, 0.1875, -0.375, 0.5, 0.0625},
{-0.5, 0.5, 0.1875, 0.5, 0.375, 0.0625},
{-0.5, -0.5, 0.125, 0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})minetest.register_node(doorc, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = doora,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, 0.1875, -0.5, 0.5, 0.0625},
{-1.5, -0.5, 0.1875, -1.375, 0.5, 0.0625},
{-1.5, -0.5, 0.1875, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0.125, -0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{-1.5, -0.5, -0.0625, -0.5, 1.5, 0.1875}
}
},
after_place_node = afterplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doord, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, 0.1875, -0.5, 0.5, 0.0625},
{-1.5, -0.5, 0.1875, -1.375, 0.5, 0.0625},
{-1.5, 0.5, 0.1875, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0.125, -0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_node("my_sliding_doors:jpanel"..num, {
description = des.." Panel",
inventory_image = "myjdoors_panel"..num.."_inv.png",
wield_image = "myjdoors_panel"..num.."_inv.png",
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{0.375, -0.5, -0.0625, 0.5, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, 0.5, -0.375, 0.0625},
{-0.4375, -0.5, 0, 0.4375, 0.5, 0.02},
}
},
selection_box = {type = "fixed",fixed = {{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}}},
collision_box = {type = "fixed",fixed = {{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}}},
on_place = function(itemstack, placer, pointed_thing)
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pos = pointed_thing.above
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if na.name == "air" then
minetest.set_node(pos,{name = "my_sliding_doors:jpanel"..num, param2 = p2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "my_sliding_doors:jpanel_top"..num, param2 = p2})
else
return
end end
end,
on_destruct = function(pos) local function afterplace(pos, placer, itemstack, pointed_thing)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) local node = minetest.get_node(pos)
end, minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doord,param2=node.param2})
})
minetest.register_node("my_sliding_doors:jpanel_top"..num, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = "",
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{0.375, -0.5, -0.0625, 0.5, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, 0.5, -0.0625, 0.5, 0.375, 0.0625},
{-0.4375, -0.5, 0, 0.4375, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0}
}
},
})
minetest.register_node("my_sliding_doors:jpanel_corner_"..num, {
description = des.." Panel Corner",
inventory_image = "myjdoors_panel"..num.."_corner_inv.png",
wield_image = "myjdoors_panel"..num.."_corner_inv.png",
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.5, 0.0625001, 0.5, -0.375},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, 0.0624999, -0.375, 0.0625},
{-0.5, -0.5, 0, 0, 0.5, 0.02},
{-0.0625, -0.5, -0.5, 0.0625, -0.375, 0.0625},
{0.02, -0.5, -0.5, 0, 0.5, 0},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.5, 0.0625, 1.5, 0},
{-0.5, -0.5, -0.0625, 0, 1.5, 0.0625},
}
},
on_place = function(itemstack, placer, pointed_thing)
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pos = pointed_thing.above
local na = minetest.get_node({x=pos.x,y=pos.y+1,z=pos.z})
if na.name == "air" then
minetest.set_node(pos,{name = "my_sliding_doors:jpanel_corner_"..num, param2 = p2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name = "my_sliding_doors:jpanel_corner_top"..num, param2 = p2})
else
return
end end
end,
on_destruct = function(pos) minetest.register_node(doora, {
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) description = des.." Sliding Door",
end, inventory_image = "myjdoors_door"..num.."a_inv.png",
}) wield_image = "myjdoors_door"..num.."a_inv.png",
minetest.register_node("my_sliding_doors:jpanel_corner_top"..num, { tiles = {
tiles = { "myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png", "myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png", "myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png", "myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png", "myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_top.png", "myjdoors_door"..num.."a_bottom.png"
"myjdoors_door"..num.."a_top.png" },
}, drawtype = "nodebox",
drawtype = "nodebox", paramtype = "light",
paramtype = "light", paramtype2 = "facedir",
paramtype2 = "facedir", sunlight_propagates = true,
sunlight_propagates = true, groups = {cracky = 3},
drop = "", node_box = {
groups = {cracky = 3}, type = "fixed",
node_box = { fixed = {
type = "fixed", { 0.375, -0.5, 0.1875, 0.5, 0.5, 0.0625},
fixed = { {-0.5, -0.5, 0.1875, -0.375, 0.5, 0.0625},
{-0.0625, -0.5, -0.5, 0.0625001, 0.5, -0.375},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625}, {-0.5, -0.5, 0.1875, 0.5, -0.375, 0.0625},
{-0.5, 0.375, -0.0625, 0.0625, 0.5, 0.0625}, {-0.5, -0.5, 0.125, 0.5, 0.5, 0.145},
{-0.5, -0.5, 0, 0, 0.5, 0.02},
{-0.0625, 0.375, -0.5, 0.0625, 0.5, 0.0625}, {-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{0.02, -0.5, -0.5, 0, 0.5, 0}, {-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
}
}, {-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
selection_box = { {-1.5, -0.5, 0, -0.5, 0.5, 0.02},
type = "fixed", }
fixed = { },
{0, 0, 0, 0, 0, 0} selection_box = {
} type = "fixed",
}, fixed = {
}) {-1.5, -0.5, -0.0625, -0.5, 1.5, 0.0625},
{-0.5, -0.5, 0.0625, 0.5, 1.5, 0.1875}
}
},
on_place = onplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doorb, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{ 0.375, -0.5, 0.1875, 0.5, 0.5, 0.0625},
{-0.5, -0.5, 0.1875, -0.375, 0.5, 0.0625},
{-0.5, 0.5, 0.1875, 0.5, 0.375, 0.0625},
{-0.5, -0.5, 0.125, 0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_node(doorc, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = doora,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, 0.1875, -0.5, 0.5, 0.0625},
{-1.5, -0.5, 0.1875, -1.375, 0.5, 0.0625},
{-1.5, -0.5, 0.1875, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0.125, -0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{-1.5, -0.5, -0.0625, -0.5, 1.5, 0.1875}
}
},
after_place_node = afterplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doord, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, 0.1875, -0.5, 0.5, 0.0625},
{-1.5, -0.5, 0.1875, -1.375, 0.5, 0.0625},
{-1.5, 0.5, 0.1875, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0.125, -0.5, 0.5, 0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_node("my_sliding_doors:jpanel"..num, {
description = des.." Panel",
inventory_image = "myjdoors_panel"..num.."_inv.png",
wield_image = "myjdoors_panel"..num.."_inv.png",
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{ 0.375, -0.5, -0.0625, 0.5, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, 0.5, -0.375, 0.0625},
{-0.4375, -0.5, 0, 0.4375, 0.5, 0.02},
}
},
selection_box = {type = "fixed", fixed = {{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}}},
collision_box = {type = "fixed", fixed = {{-0.5, -0.5, -0.0625, 0.5, 1.5, 0.0625}}},
on_place = function(itemstack, placer, pointed_thing)
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pos = pointed_thing.above
local pos2 = vector.add(pos, {x=0,y=1,z=0})
local na = minetest.get_node(pos2)
if not placer or not placer:is_player() then
return
end
if not minetest.registered_nodes[minetest.get_node(pos).name].buildable_to or
not minetest.registered_nodes[na.name].buildable_to then
minetest.chat_send_player(placer:get_player_name(), "Not enough room")
return
end
local player_name = placer:get_player_name()
if minetest.is_protected(pos, player_name) then
minetest.record_protection_violation(pos, player_name)
return
end
if minetest.is_protected(pos2, player_name) then
minetest.record_protection_violation(pos2, player_name)
return
end
if na.name == "air" then
minetest.set_node(pos, {name = "my_sliding_doors:jpanel"..num, param2 = p2})
minetest.set_node(pos2, {name = "my_sliding_doors:jpanel_top"..num, param2 = p2})
else
return
end
if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
itemstack:take_item()
end
return itemstack
end,
on_destruct = function(pos)
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
end,
})
minetest.register_node("my_sliding_doors:jpanel_top"..num, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = "",
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{ 0.375, -0.5, -0.0625, 0.5, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, 0.5, -0.0625, 0.5, 0.375, 0.0625},
{-0.4375, -0.5, 0, 0.4375, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0}
}
},
})
minetest.register_node("my_sliding_doors:jpanel_corner_"..num, {
description = des.." Panel Corner",
inventory_image = "myjdoors_panel"..num.."_corner_inv.png",
wield_image = "myjdoors_panel"..num.."_corner_inv.png",
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.5, 0.0625001, 0.5, -0.375},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, -0.5, -0.0625, 0.0624999, -0.375, 0.0625},
{-0.5, -0.5, 0, 0, 0.5, 0.02},
{-0.0625, -0.5, -0.5, 0.0625, -0.375, 0.0625},
{ 0.02, -0.5, -0.5, 0, 0.5, 0},
}
},
selection_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.5, 0.0625, 1.5, 0},
{-0.5, -0.5, -0.0625, 0, 1.5, 0.0625},
}
},
on_place = function(itemstack, placer, pointed_thing)
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pos = pointed_thing.above
local pos2 = vector.add(pos, {x=0,y=1,z=0})
local na = minetest.get_node(pos2)
if not placer or not placer:is_player() then
return
end
if not minetest.registered_nodes[minetest.get_node(pos).name].buildable_to or
not minetest.registered_nodes[na.name].buildable_to then
minetest.chat_send_player(placer:get_player_name(), "Not enough room")
return
end
local player_name = placer:get_player_name()
if minetest.is_protected(pos, player_name) then
minetest.record_protection_violation(pos, player_name)
return
end
if minetest.is_protected(pos2, player_name) then
minetest.record_protection_violation(pos2, player_name)
return
end
if na.name == "air" then
minetest.set_node(pos, {name = "my_sliding_doors:jpanel_corner_"..num, param2 = p2})
minetest.set_node(pos2, {name = "my_sliding_doors:jpanel_corner_top"..num, param2 = p2})
else
return
end
if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
itemstack:take_item()
end
return itemstack
end,
on_destruct = function(pos)
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
end,
})
minetest.register_node("my_sliding_doors:jpanel_corner_top"..num, {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png",
"myjdoors_door"..num.."a_top.png",
"myjdoors_door"..num.."a_top.png",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = "",
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{-0.0625, -0.5, -0.5, 0.0625001, 0.5, -0.375},
{-0.5, -0.5, -0.0625, -0.375, 0.5, 0.0625},
{-0.5, 0.375, -0.0625, 0.0625, 0.5, 0.0625},
{-0.5, -0.5, 0, 0, 0.5, 0.02},
{-0.0625, 0.375, -0.5, 0.0625, 0.5, 0.0625},
{ 0.02, -0.5, -0.5, 0, 0.5, 0},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0}
}
},
})
end
for _,door in ipairs(doors) do
add_door(unpack(door))
end end

View file

@ -2,295 +2,262 @@ local doors = {
{"my_sliding_doors:door1a","my_sliding_doors:door1b","my_sliding_doors:door1c","my_sliding_doors:door1d","1","White Right"}, {"my_sliding_doors:door1a","my_sliding_doors:door1b","my_sliding_doors:door1c","my_sliding_doors:door1d","1","White Right"},
{"my_sliding_doors:door2a","my_sliding_doors:door2b","my_sliding_doors:door2c","my_sliding_doors:door2d","2","Flower Right"}, {"my_sliding_doors:door2a","my_sliding_doors:door2b","my_sliding_doors:door2c","my_sliding_doors:door2d","2","Flower Right"},
{"my_sliding_doors:door3a","my_sliding_doors:door3b","my_sliding_doors:door3c","my_sliding_doors:door3d","3","Framed Right"}, {"my_sliding_doors:door3a","my_sliding_doors:door3b","my_sliding_doors:door3c","my_sliding_doors:door3d","3","Framed Right"},
} }
for i in ipairs (doors) do
local doora = doors[i][1]
local doorb = doors[i][2]
local doorc = doors[i][3]
local doord = doors[i][4]
local num = doors[i][5]
--local des = doors[i][6]
function onplace(itemstack, placer, pointed_thing) local function add_door(doora, doorb, doorc, doord, num)
local pos1 = pointed_thing.above local function onplace(itemstack, placer, pointed_thing)
local pos2 = {x=pos1.x, y=pos1.y + 1, z=pos1.z} local pos1 = pointed_thing.above
if local pos2 = vector.add(pos, {x=0,y=1,z=0})
not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to or if not placer or not placer:is_player() then
not placer or not placer:is_player() then return
return end
if not minetest.registered_nodes[minetest.get_node(pos1).name].buildable_to or
not minetest.registered_nodes[minetest.get_node(pos2).name].buildable_to then
minetest.chat_send_player(placer:get_player_name(), "Not enough room")
return
end
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local p4 = (p2+2)%4
local pos3 = vector.add(pos1, minetest.facedir_to_dir((p2-1)%4))
local player_name = placer:get_player_name()
if minetest.is_protected(pos1, player_name) then
minetest.record_protection_violation(pos1, player_name)
return
end
if minetest.is_protected(pos2, player_name) then
minetest.record_protection_violation(pos2, player_name)
return
end
if minetest.is_protected(pos3, player_name) then
minetest.record_protection_violation(pos3, player_name)
return
end
if minetest.get_node(pos3).name ~= "air" then
minetest.chat_send_player(placer:get_player_name(), "Not enough room")
return
end
if minetest.get_node(pos3).name == doora then
minetest.set_node(pos1, {name=doora.."2", param2=p2})
minetest.set_node(pos2, {name=doorb.."2", param2=p2})
else
minetest.set_node(pos1, {name=doora.."2", param2=p2})
minetest.set_node(pos2, {name=doorb.."2", param2=p2})
end
if not (minetest.settings:get_bool("creative_mode") or minetest.check_player_privs(placer:get_player_name(), {creative = true})) then
itemstack:take_item()
end
return itemstack
end end
local pt = pointed_thing.above local function afterdestruct(pos, oldnode)
local pt2 = {x=pt.x, y=pt.y, z=pt.z} minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name="air"})
pt2.y = pt2.y+1
local p2 = minetest.dir_to_facedir(placer:get_look_dir())
local pt3 = {x=pt.x, y=pt.y, z=pt.z}
if p2 == 0 then
pt3.x = pt3.x-1
elseif p2 == 1 then
pt3.z = pt3.z+1
elseif p2 == 2 then
pt3.x = pt3.x+1
elseif p2 == 3 then
pt3.z = pt3.z-1
end end
if minetest.get_node(pt3).name ~= "air" then
minetest.chat_send_player(placer:get_player_name(),"Not enough room") local function rightclick(pos, node, player, itemstack, pointed_thing)
return if node.name == doora.."2" then
minetest.set_node(pos, {name=doorc.."2", param2=node.param2})
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doord.."2", param2=node.param2})
elseif node.name == doorc.."2" then
minetest.set_node(pos, {name=doora.."2", param2=node.param2})
minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doorb.."2", param2=node.param2})
end
-- Open neighbouring doors
for i=0,3 do
local dir = minetest.facedir_to_dir(i)
local neighbour_pos = vector.add(pos, dir)
local neighbour_above = vector.add(neighbour_pos, {x=0,y=1,z=0})
local neighbour = minetest.get_node(neighbour_pos)
if neighbour.name == doora then
minetest.set_node(neighbour_pos, {name=doorc, param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doord, param2=neighbour.param2})
elseif neighbour.name == doora.."2" then
minetest.set_node(neighbour_pos, {name=doorc.."2", param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doord.."2", param2=neighbour.param2})
elseif neighbour.name == doorc then
minetest.set_node(neighbour_pos, {name=doora, param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doorb, param2=neighbour.param2})
elseif neighbour.name == doorc.."2" then
minetest.set_node(neighbour_pos, {name=doora.."2", param2=neighbour.param2})
minetest.set_node(neighbour_above, {name=doorb.."2", param2=neighbour.param2})
end
end
end end
if minetest.get_node(pt3).name == doora then
minetest.set_node(pt, {name=doora.."2", param2=p2}) local function afterplace(pos, placer, itemstack, pointed_thing)
minetest.set_node(pt2, {name=doorb.."2", param2=p2}) local node = minetest.get_node(pos)
else minetest.set_node(vector.add(pos, {x=0,y=1,z=0}), {name=doord,param2=node.param2})
minetest.set_node(pt, {name=doora.."2", param2=p2})
minetest.set_node(pt2, {name=doorb.."2", param2=p2})
end end
minetest.register_node(doora.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = doora,
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{ 0.375, -0.5, -0.1875, 0.5, 0.5, -0.0625},
{-0.5, -0.5, -0.1875, -0.375, 0.5, -0.0625},
{-0.5, -0.5, -0.1875, 0.5, -0.375, -0.0625},
{-0.5, -0.5, -0.125, 0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{-1.5, -0.5, -0.0625, -0.5, 1.5, 0.0625},
{-0.5, -0.5, -0.0625, 0.5, 1.5, -0.1875}
}
},
on_place = onplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doorb.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{ 0.375, -0.5, -0.1875, 0.5, 0.5, -0.0625},
{-0.5, -0.5, -0.1875, -0.375, 0.5, -0.0625},
{-0.5, 0.5, -0.1875, 0.5, 0.375, -0.0625},
{-0.5, -0.5, -0.125, 0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
minetest.register_node(doorc.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = doora,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, -0.1875, -0.5, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, -1.375, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, -0.5, -0.375, -0.0625},
{-1.5, -0.5, -0.125, -0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{-1.5, -0.5, 0.0625, -0.5, 1.5, -0.1875}
}
},
after_place_node = afterplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doord.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, -0.1875, -0.5, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, -1.375, 0.5, -0.0625},
{-1.5, 0.5, -0.1875, -0.5, 0.375, -0.0625},
{-1.5, -0.5, -0.125, -0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
end end
function afterdestruct(pos, oldnode) for _,door in ipairs(doors) do
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name="air"}) add_door(unpack(door))
end
function rightclick(pos, node, player, itemstack, pointed_thing)
local a = minetest.get_node({x=pos.x, y=pos.y, z=pos.z-1})
local b = minetest.get_node({x=pos.x, y=pos.y, z=pos.z+1})
local c = minetest.get_node({x=pos.x+1, y=pos.y, z=pos.z})
local d = minetest.get_node({x=pos.x-1, y=pos.y, z=pos.z})
if node.name == doora.."2" then
minetest.set_node(pos, {name=doorc.."2", param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doord.."2", param2=node.param2})
elseif node.name == doorc.."2" then
minetest.set_node(pos, {name=doora.."2", param2=node.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z}, {name=doorb.."2", param2=node.param2})
end
if a.name == doora then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doorc, param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doord, param2=a.param2})
end
if b.name == doora then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doorc, param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doord, param2=b.param2})
end
if c.name == doora then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doorc, param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doord, param2=c.param2})
end
if d.name == doora then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doorc, param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doord, param2=d.param2})
end
if a.name == doora.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doorc.."2", param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doord.."2", param2=a.param2})
end
if b.name == doora.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doorc.."2", param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doord.."2", param2=b.param2})
end
if c.name == doora.."2" then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doorc.."2", param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doord.."2", param2=c.param2})
end
if d.name == doora.."2" then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doorc.."2", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doord.."2", param2=d.param2})
end
if a.name == doorc then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doora, param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doorb, param2=a.param2})
end
if b.name == doorc then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doora, param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doorb, param2=b.param2})
end
if c.name == doorc then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doora, param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doorb, param2=c.param2})
end
if d.name == doorc then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doora, param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doorb, param2=d.param2})
end
if a.name == doorc.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z-1}, {name=doora.."2", param2=a.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z-1}, {name=doorb.."2", param2=a.param2})
end
if b.name == doorc.."2" then
minetest.set_node({x=pos.x, y=pos.y, z=pos.z+1}, {name=doora.."2", param2=b.param2})
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z+1}, {name=doorb.."2", param2=b.param2})
end
if c.name == doorc.."2" then
minetest.set_node({x=pos.x+1, y=pos.y, z=pos.z}, {name=doora.."2", param2=c.param2})
minetest.set_node({x=pos.x+1,y=pos.y+1,z=pos.z}, {name=doorb.."2", param2=c.param2})
end
if d.name == doorc.."2" then
minetest.set_node({x=pos.x-1, y=pos.y, z=pos.z}, {name=doora.."2", param2=d.param2})
minetest.set_node({x=pos.x-1,y=pos.y+1,z=pos.z}, {name=doorb.."2", param2=d.param2})
end
end
function afterplace(pos, placer, itemstack, pointed_thing)
minetest.set_node({x=pos.x,y=pos.y+1,z=pos.z},{name=doord,param2=nodeu.param2})
end
minetest.register_node(doora.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
drop = doora,
sunlight_propagates = true,
groups = {cracky = 3},
node_box = {
type = "fixed",
fixed = {
{0.375, -0.5, -0.1875, 0.5, 0.5, -0.0625},
{-0.5, -0.5, -0.1875, -0.375, 0.5, -0.0625},
{-0.5, -0.5, -0.1875, 0.5, -0.375, -0.0625},
{-0.5, -0.5, -0.125, 0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {type = "fixed",fixed = {{-1.5, -0.5, -0.0625, -0.5, 1.5, 0.0625},{-0.5, -0.5, -0.0625, 0.5, 1.5, -0.1875}}},
on_place = onplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doorb.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{0.375, -0.5, -0.1875, 0.5, 0.5, -0.0625},
{-0.5, -0.5, -0.1875, -0.375, 0.5, -0.0625},
{-0.5, 0.5, -0.1875, 0.5, 0.375, -0.0625},
{-0.5, -0.5, -0.125, 0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})minetest.register_node(doorc.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_bottom.png^[transformFX",
"myjdoors_door"..num.."a_bottom.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
drop = doora,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, -0.1875, -0.5, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, -1.375, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, -0.5, -0.375, -0.0625},
{-1.5, -0.5, -0.125, -0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -0.5, -0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{-1.5, -0.5, 0.0625, -0.5, 1.5, -0.1875}
}
},
after_place_node = afterplace,
after_destruct = afterdestruct,
on_rightclick = rightclick,
})
minetest.register_node(doord.."2", {
tiles = {
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_edge.png",
"myjdoors_door"..num.."a_top.png^[transformFX",
"myjdoors_door"..num.."a_top.png"
},
drawtype = "nodebox",
paramtype = "light",
paramtype2 = "facedir",
sunlight_propagates = true,
groups = {cracky = 1},
node_box = {
type = "fixed",
fixed = {
{-0.625, -0.5, -0.1875, -0.5, 0.5, -0.0625},
{-1.5, -0.5, -0.1875, -1.375, 0.5, -0.0625},
{-1.5, 0.5, -0.1875, -0.5, 0.375, -0.0625},
{-1.5, -0.5, -0.125, -0.5, 0.5, -0.145},
{-0.625, -0.5, -0.0625, -0.5, 0.5, 0.0625},
{-1.5, -0.5, -0.0625, -1.375, 0.5, 0.0625},
{-1.5, 0.5, -0.0625, -0.5, 0.375, 0.0625},
{-1.5, -0.5, 0, -0.5, 0.5, 0.02},
}
},
selection_box = {
type = "fixed",
fixed = {
{0, 0, 0, 0, 0, 0},
}
},
})
end end

View file

@ -61,7 +61,7 @@ Change log:
- 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet) - 3.1 - Ability to hide protection blocks using /protector_hide and /protector_show , italian local added (thanks Hamlet)
- 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both. Added 'protector_msg' setting for player text. - 3.2 - Defaults to Minetest translation if found, otherwise intllib fallback if loaded, locale files updated for both. Added 'protector_msg' setting for player text.
- 3.3 - Added support for playerfactions new api (thanks louisroyer), added limiter to protection radius of 22. - 3.3 - Added support for playerfactions new api (thanks louisroyer), added limiter to protection radius of 22.
- 3.4 - Player flip and hurt functions moved to minetest.register_protection_violation function (thanks hlqkj) - 3.4 - Player flip and hurt functions moved to minetest.register_protection_violation function (thanks hlqkj), added 'protector_crafts' setting, changed wood doors n chests to immediate_dig for mineclone2 fix.
Lucky Blocks: 10 Lucky Blocks: 10

View file

@ -9,6 +9,9 @@ local F = minetest.formspec_escape
-- MineClone2 support -- MineClone2 support
local mcl = not minetest.registered_items["default:steel_ingot"] local mcl = not minetest.registered_items["default:steel_ingot"]
-- Are crafts enabled?
local protector_crafts = minetest.settings:get_bool("protector_crafts") ~= false
-- Registers a door -- Registers a door
function register_door(name, def) function register_door(name, def)
def.groups.not_in_creative_inventory = 1 def.groups.not_in_creative_inventory = 1
@ -308,7 +311,7 @@ register_door(name, {
description = S("Protected Wooden Door"), description = S("Protected Wooden Door"),
inventory_image = "doors_wood.png^protector_logo.png", inventory_image = "doors_wood.png^protector_logo.png",
groups = { groups = {
snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, snappy = 1, choppy = 2, dig_immediate = 2,
unbreakable = 1, --door = 1 unbreakable = 1, --door = 1
}, },
tiles_bottom = {"doors_wood_b.png^protector_logo.png", "doors_brown.png"}, tiles_bottom = {"doors_wood_b.png^protector_logo.png", "doors_brown.png"},
@ -317,29 +320,31 @@ register_door(name, {
sunlight = false, sunlight = false,
}) })
if mcl then if protector_crafts then
minetest.register_craft({ if mcl then
output = name, minetest.register_craft({
recipe = { output = name,
{"mcl_doors:wooden_door", "mcl_core:gold_ingot"} recipe = {
} {"mcl_doors:wooden_door", "mcl_core:gold_ingot"}
}) }
else })
minetest.register_craft({ else
output = name, minetest.register_craft({
recipe = { output = name,
{"group:wood", "group:wood"}, recipe = {
{"group:wood", "default:copper_ingot"}, {"group:wood", "group:wood"},
{"group:wood", "group:wood"} {"group:wood", "default:copper_ingot"},
} {"group:wood", "group:wood"}
}) }
})
minetest.register_craft({ minetest.register_craft({
output = name, output = name,
recipe = { recipe = {
{"doors:door_wood", "default:copper_ingot"} {"doors:door_wood", "default:copper_ingot"}
} }
}) })
end
end end
-- Protected Steel Door -- Protected Steel Door
@ -359,29 +364,31 @@ register_door(name, {
sunlight = false, sunlight = false,
}) })
if mcl then if protector_crafts then
minetest.register_craft({ if mcl then
output = name, minetest.register_craft({
recipe = { output = name,
{"mcl_doors:iron_door", "mcl_core:gold_ingot"} recipe = {
} {"mcl_doors:iron_door", "mcl_core:gold_ingot"}
}) }
else })
minetest.register_craft({ else
output = name, minetest.register_craft({
recipe = { output = name,
{"default:steel_ingot", "default:steel_ingot"}, recipe = {
{"default:steel_ingot", "default:copper_ingot"}, {"default:steel_ingot", "default:steel_ingot"},
{"default:steel_ingot", "default:steel_ingot"} {"default:steel_ingot", "default:copper_ingot"},
} {"default:steel_ingot", "default:steel_ingot"}
}) }
})
minetest.register_craft({ minetest.register_craft({
output = name, output = name,
recipe = { recipe = {
{"doors:door_steel", "default:copper_ingot"} {"doors:door_steel", "default:copper_ingot"}
} }
}) })
end
end end
----trapdoor---- ----trapdoor----
@ -454,34 +461,36 @@ register_trapdoor("protector:trapdoor", {
tile_front = "doors_trapdoor.png^protector_logo.png", tile_front = "doors_trapdoor.png^protector_logo.png",
tile_side = "doors_trapdoor_side.png", tile_side = "doors_trapdoor_side.png",
groups = { groups = {
snappy = 1, choppy = 2, oddly_breakable_by_hand = 2, snappy = 1, choppy = 2, dig_immediate = 2,
unbreakable = 1, --door = 1 unbreakable = 1, --door = 1
}, },
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
if mcl then if protector_crafts then
minetest.register_craft({ if mcl then
output = "protector:trapdoor", minetest.register_craft({
recipe = { output = "protector:trapdoor",
{"mcl_doors:trapdoor", "mcl_core:gold_ingot"} recipe = {
} {"mcl_doors:trapdoor", "mcl_core:gold_ingot"}
}) }
else })
minetest.register_craft({ else
output = "protector:trapdoor 2", minetest.register_craft({
recipe = { output = "protector:trapdoor 2",
{"group:wood", "default:copper_ingot", "group:wood"}, recipe = {
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "default:copper_ingot", "group:wood"},
} {"group:wood", "group:wood", "group:wood"},
}) }
})
minetest.register_craft({ minetest.register_craft({
output = "protector:trapdoor", output = "protector:trapdoor",
recipe = { recipe = {
{"doors:trapdoor", "default:copper_ingot"} {"doors:trapdoor", "default:copper_ingot"}
} }
}) })
end
end end
-- Protected Steel Trapdoor -- Protected Steel Trapdoor
@ -499,28 +508,30 @@ register_trapdoor("protector:trapdoor_steel", {
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
}) })
if mcl then if protector_crafts then
minetest.register_craft({ if mcl then
output = "protector:trapdoor_steel", minetest.register_craft({
recipe = { output = "protector:trapdoor_steel",
{"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"} recipe = {
} {"mcl_doors:iron_trapdoor", "mcl_core:gold_ingot"}
}) }
else })
minetest.register_craft({ else
output = "protector:trapdoor_steel", minetest.register_craft({
recipe = { output = "protector:trapdoor_steel",
{"default:copper_ingot", "default:steel_ingot"}, recipe = {
{"default:steel_ingot", "default:steel_ingot"}, {"default:copper_ingot", "default:steel_ingot"},
} {"default:steel_ingot", "default:steel_ingot"},
}) }
})
minetest.register_craft({ minetest.register_craft({
output = "protector:trapdoor_steel", output = "protector:trapdoor_steel",
recipe = { recipe = {
{"doors:trapdoor_steel", "default:copper_ingot"} {"doors:trapdoor_steel", "default:copper_ingot"}
} }
}) })
end
end end
-- Protected Chest -- Protected Chest
@ -533,7 +544,7 @@ minetest.register_node("protector:chest", {
"default_chest_side.png", "default_chest_front.png^protector_logo.png" "default_chest_side.png", "default_chest_front.png^protector_logo.png"
}, },
paramtype2 = "facedir", paramtype2 = "facedir",
groups = {choppy = 2, oddly_breakable_by_hand = 2, unbreakable = 1}, groups = {dig_immediate = 2, unbreakable = 1},
legacy_facedir_simple = true, legacy_facedir_simple = true,
is_ground_content = false, is_ground_content = false,
sounds = default.node_sound_wood_defaults(), sounds = default.node_sound_wood_defaults(),
@ -720,27 +731,29 @@ end)
-- Protected Chest recipes -- Protected Chest recipes
if mcl then if protector_crafts then
minetest.register_craft({ if mcl then
output = "protector:chest", minetest.register_craft({
recipe = { output = "protector:chest",
{"mcl_chests:chest", "mcl_core:gold_ingot"}, recipe = {
} {"mcl_chests:chest", "mcl_core:gold_ingot"},
}) }
else })
minetest.register_craft({ else
output = "protector:chest", minetest.register_craft({
recipe = { output = "protector:chest",
{"group:wood", "group:wood", "group:wood"}, recipe = {
{"group:wood", "default:copper_ingot", "group:wood"}, {"group:wood", "group:wood", "group:wood"},
{"group:wood", "group:wood", "group:wood"}, {"group:wood", "default:copper_ingot", "group:wood"},
} {"group:wood", "group:wood", "group:wood"},
}) }
})
minetest.register_craft({ minetest.register_craft({
output = "protector:chest", output = "protector:chest",
recipe = { recipe = {
{"default:chest", "default:copper_ingot"}, {"default:chest", "default:copper_ingot"},
} }
}) })
end
end end

View file

@ -28,5 +28,8 @@ protector_hud_interval (Protector HUD Interval) int 5
# Enables craft recipe for protection block # Enables craft recipe for protection block
protector_recipe (Enable Protector recipe) bool true protector_recipe (Enable Protector recipe) bool true
# Enables craft recipes for protected doors and chest
protector_crafts (Enable Protector door/chest recipes) bool true
# Enables protection messages in player chat # Enables protection messages in player chat
protector_msg (Enable Protector Messages) bool true protector_msg (Enable Protector Messages) bool true

View file

@ -0,0 +1,3 @@
SPECOPSOUTFIT3
SPECOPSOUTFIT3
CC BY-NC-SA 4.0

View file

@ -0,0 +1,3 @@
THE TRUE AESTHER
THE TRUE AESTHER gaming
CC 0 (1.0)

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 465 B

View file

@ -152,6 +152,10 @@ minetest.after(0.01, function()
end end
end end
end end
for _, callback in ipairs(ui.initialized_callbacks) do
callback()
end
end) end)
@ -212,10 +216,15 @@ function ui.register_craft(options)
if options.type == "normal" and options.width == 0 then if options.type == "normal" and options.width == 0 then
options = { type = "shapeless", items = options.items, output = options.output, width = 0 } options = { type = "shapeless", items = options.items, output = options.output, width = 0 }
end end
if not ui.crafts_for.recipe[itemstack:get_name()] then local item_name = itemstack:get_name()
ui.crafts_for.recipe[itemstack:get_name()] = {} if not ui.crafts_for.recipe[item_name] then
ui.crafts_for.recipe[item_name] = {}
end
table.insert(ui.crafts_for.recipe[item_name],options)
for _, callback in ipairs(ui.craft_registered_callbacks) do
callback(item_name, options)
end end
table.insert(ui.crafts_for.recipe[itemstack:get_name()],options)
end end
@ -309,6 +318,32 @@ function ui.register_button(name, def)
table.insert(ui.buttons, def) table.insert(ui.buttons, def)
end end
function ui.register_on_initialized(callback)
if type(callback) ~= "function" then
error(("Initialized callback must be a function, %s given."):format(type(callback)))
end
table.insert(ui.initialized_callbacks, callback)
end
function ui.register_on_craft_registered(callback)
if type(callback) ~= "function" then
error(("Craft registered callback must be a function, %s given."):format(type(callback)))
end
table.insert(ui.craft_registered_callbacks, callback)
end
function ui.get_recipe_list(output)
return ui.crafts_for.recipe[output]
end
function ui.get_registered_outputs()
local outputs = {}
for item_name, _ in pairs(ui.crafts_for.recipe) do
table.insert(outputs, item_name)
end
return outputs
end
function ui.is_creative(playername) function ui.is_creative(playername)
return minetest.check_player_privs(playername, {creative=true}) return minetest.check_player_privs(playername, {creative=true})
or minetest.settings:get_bool("creative_mode") or minetest.settings:get_bool("creative_mode")

View file

@ -24,8 +24,7 @@ minetest.register_on_joinplayer(function(player)
unified_inventory.alternate[player_name] = 1 unified_inventory.alternate[player_name] = 1
unified_inventory.current_item[player_name] = nil unified_inventory.current_item[player_name] = nil
unified_inventory.current_craft_direction[player_name] = "recipe" unified_inventory.current_craft_direction[player_name] = "recipe"
unified_inventory.set_inventory_formspec(player, unified_inventory.set_inventory_formspec(player, unified_inventory.default)
unified_inventory.default)
-- Refill slot -- Refill slot
local refill = minetest.create_detached_inventory(player_name.."refill", { local refill = minetest.create_detached_inventory(player_name.."refill", {

View file

@ -20,6 +20,64 @@ Grouped by use-case, afterwards sorted alphabetically.
* Checks whether creative is enabled or the player has `creative` * Checks whether creative is enabled or the player has `creative`
Callbacks
---------
Register a callback that will be run whenever a craft is registered via unified_inventory.register_craft:
unified_inventory.register_on_craft_registered(
function (item_name, options)
-- item_name (string): name of the output item, equivalent to `ItemStack:get_name()`
-- options (table): definition table of crafts registered by `unified_inventory.register_craft`
end
)
Register a callback that will be run after all mods have loaded and after the unified_inventory mod has initialised all its internal structures:
unified_inventory.register_on_initialized(callback)
-- The callback is passed no arguments
Accessing Data
--------------
These methods should be used instead of accessing the unified_inventory data structures directly - this will ensure your code survives any potential restructuring of the mod.
Get a list of recipes for a particular output item:
unified_inventory.get_recipe_list(output_item)
Returns a list of tables, each holding a recipe definition, like:
{
{
type = "normal",
items = { "default:stick", "default:stick", "default:stick", "default:stick" },
output = "default:wood",
width = 2
},
{
type = "shapeless",
items = { "default:tree" },
output = "default:wood 4",
width = 0
},
...
}
Get a list of all the output items crafts have been registered for:
unified_inventory.get_registered_outputs()
Returns a list of item names, like:
{
"default:stone",
"default:chest",
"default:brick",
"doors:door_wood",
...
}
Pages Pages
----- -----

View file

@ -24,6 +24,8 @@ unified_inventory = {
filtered_items_list = {}, filtered_items_list = {},
pages = {}, pages = {},
buttons = {}, buttons = {},
initialized_callbacks = {},
craft_registered_callbacks = {},
-- Homepos stuff -- Homepos stuff
home_pos = {}, home_pos = {},

View file

@ -375,6 +375,5 @@ function ui.apply_filter(player, filter, search_dir)
ui.current_index[player_name] = 1 ui.current_index[player_name] = 1
ui.activefilter[player_name] = filter ui.activefilter[player_name] = filter
ui.active_search_direction[player_name] = search_dir ui.active_search_direction[player_name] = search_dir
ui.set_inventory_formspec(player, ui.set_inventory_formspec(player, ui.current_page[player_name])
ui.current_page[player_name])
end end

View file

@ -330,8 +330,9 @@ minetest.register_on_player_receive_fields(function(player, formname, fields)
end end
end) end)
-- waypoints_temp must be initialized before the general unified_inventory
minetest.register_on_joinplayer(function(player) -- joinplayer callback is run for updating the inventory
table.insert(minetest.registered_on_joinplayers, 1, function(player)
local player_name = player:get_player_name() local player_name = player:get_player_name()
local waypoints = get_waypoint_data(player) local waypoints = get_waypoint_data(player)