Add more nodes

master
Jean-Patrick Guerrero 2021-02-28 22:12:18 +01:00
parent b3fc6daf71
commit 98816ffce1
16 changed files with 128 additions and 90 deletions

16
LICENSE
View File

@ -1,15 +1,17 @@
┌──────────────────────────────────────────────────────────────────────┐
│ Copyright (c) 2015-2017 kilbith <jeanpatrick.guerrero@gmail.com> │
│ │
│ Code: BSD │
│ Textures: WTFPL (credits: Gambit, kilbith, Cisoun) │
│ Sounds: │
│ │
│ Code: BSD │
│ Textures: WTFPL (credits: Gambit, kilbith, Cisoun) │
│ Textures (radio, speaker, hanging candle, rooster) by │
gigomaf <bartiko2@poczta.fm> (CC BY-NC 3.0) │
│ Sounds: │
│ - xdecor_boiling_water.ogg - by Audionautics - CC BY-SA │
│ freesound.org/people/Audionautics/sounds/133901/ │
freesound.org/people/Audionautics/sounds/133901/
│ - xdecor_enchanting.ogg - by Timbre - CC BY-SA-NC │
│ freesound.org/people/Timbre/sounds/221683/ │
│ - xdecor_bouncy.ogg - by Blender Foundation - CC BY 3.0
opengameart.org/content/funny-comic-cartoon-bounce-sound │
│ - xdecor_bouncy.ogg - by Blender Foundation - CC BY 3.0
opengameart.org/content/funny-comic-cartoon-bounce-sound │
└──────────────────────────────────────────────────────────────────────┘

View File

@ -52,7 +52,7 @@ function xdecor.stairs_valid_def(def)
not (def.groups.not_cuttable == 1) and
not def.groups.wool and
(def.tiles and type(def.tiles[1]) == "string" and not
def.tiles[1]:find("default_mineral")) and
def.tiles[1]:find("default_mineral")) and
not def.mesecons and
def.description and
def.description ~= "" and

View File

@ -143,7 +143,7 @@ xdecor.register("candle", {
animation = {type="vertical_frames", length = 1.5}
},
{
name = "xdecor_candle_floor.png",
name = "xdecor_candle_hanging.png",
animation = {type="vertical_frames", length = 1.5}
},
{
@ -397,6 +397,15 @@ xdecor.register("ivy", {
sounds = default.node_sound_leaves_defaults()
})
xdecor.register("rooster", {
description = S("Rooster"),
drawtype = "torchlike",
inventory_image = "xdecor_rooster.png",
walkable = false,
groups = {snappy = 3, attached_node = 1},
tiles = {"xdecor_rooster.png"},
})
xdecor.register("lantern", {
description = S("Lantern"),
light_source = 13,
@ -418,6 +427,7 @@ xdecor.register("lantern", {
local xdecor_lightbox = {
iron = S("Iron Light Box"),
wooden = S("Wooden Light Box"),
wooden2 = S("Wooden Light Box 2"),
}
for l, desc in pairs(xdecor_lightbox) do
@ -609,3 +619,19 @@ xdecor.register("woodframed_glass", {
groups = {cracky = 2, oddly_breakable_by_hand = 1},
sounds = default.node_sound_glass_defaults()
})
for _, v in ipairs({"radio", "speaker"}) do
xdecor.register(v, {
description = v:gsub("^%l", string.upper),
on_rotate = screwdriver.rotate_simple,
tiles = {
"xdecor_" .. v .. "_top.png",
"xdecor_" .. v .. "_side.png",
"xdecor_" .. v .. "_side.png",
"xdecor_" .. v .. "_side.png",
"xdecor_" .. v .. "_back.png",
"xdecor_" .. v .. "_front.png",
},
groups = {cracky = 2, not_cuttable = 1},
})
end

View File

@ -180,6 +180,30 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "xdecor:radio",
type = "shapeless",
recipe = {"xdecor:speaker", "xdecor:speaker"}
})
minetest.register_craft({
output = "xdecor:rooster",
recipe = {
{"default:gold_ingot", "", "default:gold_ingot"},
{"", "default:gold_ingot", ""},
{"default:gold_ingot", "", "default:gold_ingot"}
}
})
minetest.register_craft({
output = "xdecor:speaker",
recipe = {
{"default:gold_ingot", "default:copper_ingot", "default:gold_ingot"},
{"default:copper_ingot", "", "default:copper_ingot"},
{"default:gold_ingot", "default:copper_ingot", "default:gold_ingot"}
}
})
minetest.register_craft({
output = "xdecor:stone_tile 2",
recipe = {
@ -267,3 +291,9 @@ minetest.register_craft({
}
})
minetest.register_craft({
output = "xdecor:wooden2_lightbox",
type = "shapeless",
recipe = {"xdecor:wooden_lightbox"},
})

View File

@ -1,37 +1,19 @@
local workbench = {}
WB = {}
local nodes = {}
screwdriver = screwdriver or {}
local min, ceil = math.min, math.ceil
local registered_nodes = minetest.registered_nodes
local S = minetest.get_translator("xdecor")
local FS = function(...) return minetest.formspec_escape(S(...)) end
-- Nodes allowed to be cut
-- Only the regular, solid blocks without metas or explosivity can be cut
local nodes = {}
for node, def in pairs(registered_nodes) do
for node, def in pairs(minetest.registered_nodes) do
if xdecor.stairs_valid_def(def) then
nodes[#nodes + 1] = node
end
end
-- Optionally, you can register custom cuttable nodes in the workbench
WB.custom_nodes_register = {
-- "default:leaves",
}
setmetatable(nodes, {
__concat = function(t1, t2)
for i = 1, #t2 do
t1[#t1 + 1] = t2[i]
end
return t1
end
})
nodes = nodes .. WB.custom_nodes_register
-- Nodeboxes definitions
workbench.defs = {
-- Name YieldX YZ WH L
@ -187,7 +169,7 @@ function workbench.allow_put(pos, listname, index, stack, player)
local stackname = stack:get_name()
if (listname == "tool" and stack:get_wear() > 0 and
workbench:repairable(stackname)) or
(listname == "input" and registered_nodes[stackname .. "_cube"]) or
(listname == "input" and minetest.registered_nodes[stackname .. "_cube"]) or
(listname == "hammer" and stackname == "xdecor:hammer") or
listname == "storage" then
return stack:get_count()
@ -232,7 +214,7 @@ function workbench.on_take(pos, listname, index, stack, player)
local stackname = stack:get_name()
if listname == "input" then
if stackname == inputname and registered_nodes[inputname .. "_cube"] then
if stackname == inputname and minetest.registered_nodes[inputname .. "_cube"] then
workbench:get_output(inv, input, stackname)
else
inv:set_list("forms", {})
@ -274,69 +256,67 @@ xdecor.register("workbench", {
allow_metadata_inventory_move = workbench.allow_move
})
minetest.register_on_mods_loaded(function()
for _, d in ipairs(workbench.defs) do
for i = 1, #nodes do
local node = nodes[i]
local mod_name, item_name = node:match("^(.-):(.*)")
local def = registered_nodes[node]
for _, d in ipairs(workbench.defs) do
for i = 1, #nodes do
local node = nodes[i]
local mod_name, item_name = node:match("^(.-):(.*)")
local def = minetest.registered_nodes[node]
if item_name and d[3] then
local groups = {}
local tiles
groups.not_in_creative_inventory = 1
if item_name and d[3] then
local groups = {}
local tiles
groups.not_in_creative_inventory = 1
for k, v in pairs(def.groups) do
if k ~= "wood" and k ~= "stone" and k ~= "level" then
groups[k] = v
end
for k, v in pairs(def.groups) do
if k ~= "wood" and k ~= "stone" and k ~= "level" then
groups[k] = v
end
if def.tiles then
if #def.tiles > 1 and (def.drawtype:sub(1,5) ~= "glass") then
tiles = def.tiles
else
tiles = {def.tiles[1]}
end
else
tiles = {def.tile_images[1]}
end
--TODO: Translation support for Stairs/Slab
if not registered_nodes["stairs:slab_" .. item_name] then
stairs.register_stair_and_slab(item_name, node,
groups, tiles, def.description .. " Stair",
def.description .. " Slab", def.sounds)
end
minetest.register_node(":" .. node .. "_" .. d[1], {
--TODO: Translation support
description = def.description .. " " .. d[1]:gsub("^%l", string.upper),
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
sounds = def.sounds,
tiles = tiles,
groups = groups,
-- `unpack` has been changed to `table.unpack` in newest Lua versions
node_box = xdecor.pixelbox(16, {unpack(d, 3)}),
sunlight_propagates = true,
on_place = minetest.rotate_node
})
elseif item_name and mod_name then
minetest.register_alias_force(
("%s:%s_innerstair"):format(mod_name, item_name),
("stairs:stair_inner_%s"):format(item_name)
)
minetest.register_alias_force(
("%s:%s_outerstair"):format(mod_name, item_name),
("stairs:stair_outer_%s"):format(item_name)
)
end
if def.tiles then
if #def.tiles > 1 and (def.drawtype:sub(1,5) ~= "glass") then
tiles = def.tiles
else
tiles = {def.tiles[1]}
end
else
tiles = {def.tile_images[1]}
end
--TODO: Translation support for Stairs/Slab
if not minetest.registered_nodes["stairs:slab_" .. item_name] then
stairs.register_stair_and_slab(item_name, node,
groups, tiles, def.description .. " Stair",
def.description .. " Slab", def.sounds)
end
minetest.register_node(":" .. node .. "_" .. d[1], {
--TODO: Translation support
description = def.description .. " " .. d[1]:gsub("^%l", string.upper),
paramtype = "light",
paramtype2 = "facedir",
drawtype = "nodebox",
sounds = def.sounds,
tiles = tiles,
groups = groups,
-- `unpack` has been changed to `table.unpack` in newest Lua versions
node_box = xdecor.pixelbox(16, {unpack(d, 3)}),
sunlight_propagates = true,
on_place = minetest.rotate_node
})
elseif item_name and mod_name then
minetest.register_alias_force(
("%s:%s_innerstair"):format(mod_name, item_name),
("stairs:stair_inner_%s"):format(item_name)
)
minetest.register_alias_force(
("%s:%s_outerstair"):format(mod_name, item_name),
("stairs:stair_outer_%s"):format(item_name)
)
end
end
end)
end
end
-- Craft items

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
textures/xdecor_rooster.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB