Skip to content
This repository was archived by the owner on Aug 9, 2023. It is now read-only.

Commit 98816ff

Browse files
committed
Add more nodes
1 parent b3fc6da commit 98816ff

16 files changed

+126
-88
lines changed

LICENSE

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
┌──────────────────────────────────────────────────────────────────────┐
22
│ Copyright (c) 2015-2017 kilbith <[email protected]> │
3-
│ │
4-
│ Code: BSD │
5-
│ Textures: WTFPL (credits: Gambit, kilbith, Cisoun) │
6-
│ Sounds: │
3+
│ │
4+
│ Code: BSD │
5+
│ Textures: WTFPL (credits: Gambit, kilbith, Cisoun) │
6+
│ Textures (radio, speaker, hanging candle, rooster) by │
7+
gigomaf <[email protected]> (CC BY-NC 3.0) │
8+
│ Sounds: │
79
│ - xdecor_boiling_water.ogg - by Audionautics - CC BY-SA │
8-
freesound.org/people/Audionautics/sounds/133901/
10+
freesound.org/people/Audionautics/sounds/133901/
911
│ - xdecor_enchanting.ogg - by Timbre - CC BY-SA-NC │
1012
│ freesound.org/people/Timbre/sounds/221683/ │
11-
│ - xdecor_bouncy.ogg - by Blender Foundation - CC BY 3.0
12-
opengameart.org/content/funny-comic-cartoon-bounce-sound │
13+
│ - xdecor_bouncy.ogg - by Blender Foundation - CC BY 3.0
14+
opengameart.org/content/funny-comic-cartoon-bounce-sound │
1315
└──────────────────────────────────────────────────────────────────────┘
1416

1517

handlers/helpers.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function xdecor.stairs_valid_def(def)
5252
not (def.groups.not_cuttable == 1) and
5353
not def.groups.wool and
5454
(def.tiles and type(def.tiles[1]) == "string" and not
55-
def.tiles[1]:find("default_mineral")) and
55+
def.tiles[1]:find("default_mineral")) and
5656
not def.mesecons and
5757
def.description and
5858
def.description ~= "" and

src/nodes.lua

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ xdecor.register("candle", {
143143
animation = {type="vertical_frames", length = 1.5}
144144
},
145145
{
146-
name = "xdecor_candle_floor.png",
146+
name = "xdecor_candle_hanging.png",
147147
animation = {type="vertical_frames", length = 1.5}
148148
},
149149
{
@@ -397,6 +397,15 @@ xdecor.register("ivy", {
397397
sounds = default.node_sound_leaves_defaults()
398398
})
399399

400+
xdecor.register("rooster", {
401+
description = S("Rooster"),
402+
drawtype = "torchlike",
403+
inventory_image = "xdecor_rooster.png",
404+
walkable = false,
405+
groups = {snappy = 3, attached_node = 1},
406+
tiles = {"xdecor_rooster.png"},
407+
})
408+
400409
xdecor.register("lantern", {
401410
description = S("Lantern"),
402411
light_source = 13,
@@ -418,6 +427,7 @@ xdecor.register("lantern", {
418427
local xdecor_lightbox = {
419428
iron = S("Iron Light Box"),
420429
wooden = S("Wooden Light Box"),
430+
wooden2 = S("Wooden Light Box 2"),
421431
}
422432

423433
for l, desc in pairs(xdecor_lightbox) do
@@ -609,3 +619,19 @@ xdecor.register("woodframed_glass", {
609619
groups = {cracky = 2, oddly_breakable_by_hand = 1},
610620
sounds = default.node_sound_glass_defaults()
611621
})
622+
623+
for _, v in ipairs({"radio", "speaker"}) do
624+
xdecor.register(v, {
625+
description = v:gsub("^%l", string.upper),
626+
on_rotate = screwdriver.rotate_simple,
627+
tiles = {
628+
"xdecor_" .. v .. "_top.png",
629+
"xdecor_" .. v .. "_side.png",
630+
"xdecor_" .. v .. "_side.png",
631+
"xdecor_" .. v .. "_side.png",
632+
"xdecor_" .. v .. "_back.png",
633+
"xdecor_" .. v .. "_front.png",
634+
},
635+
groups = {cracky = 2, not_cuttable = 1},
636+
})
637+
end

src/recipes.lua

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,30 @@ minetest.register_craft({
180180
}
181181
})
182182

183+
minetest.register_craft({
184+
output = "xdecor:radio",
185+
type = "shapeless",
186+
recipe = {"xdecor:speaker", "xdecor:speaker"}
187+
})
188+
189+
minetest.register_craft({
190+
output = "xdecor:rooster",
191+
recipe = {
192+
{"default:gold_ingot", "", "default:gold_ingot"},
193+
{"", "default:gold_ingot", ""},
194+
{"default:gold_ingot", "", "default:gold_ingot"}
195+
}
196+
})
197+
198+
minetest.register_craft({
199+
output = "xdecor:speaker",
200+
recipe = {
201+
{"default:gold_ingot", "default:copper_ingot", "default:gold_ingot"},
202+
{"default:copper_ingot", "", "default:copper_ingot"},
203+
{"default:gold_ingot", "default:copper_ingot", "default:gold_ingot"}
204+
}
205+
})
206+
183207
minetest.register_craft({
184208
output = "xdecor:stone_tile 2",
185209
recipe = {
@@ -267,3 +291,9 @@ minetest.register_craft({
267291
}
268292
})
269293

294+
minetest.register_craft({
295+
output = "xdecor:wooden2_lightbox",
296+
type = "shapeless",
297+
recipe = {"xdecor:wooden_lightbox"},
298+
})
299+

src/workbench.lua

Lines changed: 59 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,19 @@
11
local workbench = {}
2-
WB = {}
2+
local nodes = {}
3+
34
screwdriver = screwdriver or {}
45
local min, ceil = math.min, math.ceil
5-
local registered_nodes = minetest.registered_nodes
66
local S = minetest.get_translator("xdecor")
77
local FS = function(...) return minetest.formspec_escape(S(...)) end
88

99
-- Nodes allowed to be cut
1010
-- Only the regular, solid blocks without metas or explosivity can be cut
11-
local nodes = {}
12-
for node, def in pairs(registered_nodes) do
11+
for node, def in pairs(minetest.registered_nodes) do
1312
if xdecor.stairs_valid_def(def) then
1413
nodes[#nodes + 1] = node
1514
end
1615
end
1716

18-
-- Optionally, you can register custom cuttable nodes in the workbench
19-
WB.custom_nodes_register = {
20-
-- "default:leaves",
21-
}
22-
23-
setmetatable(nodes, {
24-
__concat = function(t1, t2)
25-
for i = 1, #t2 do
26-
t1[#t1 + 1] = t2[i]
27-
end
28-
29-
return t1
30-
end
31-
})
32-
33-
nodes = nodes .. WB.custom_nodes_register
34-
3517
-- Nodeboxes definitions
3618
workbench.defs = {
3719
-- Name YieldX YZ WH L
@@ -187,7 +169,7 @@ function workbench.allow_put(pos, listname, index, stack, player)
187169
local stackname = stack:get_name()
188170
if (listname == "tool" and stack:get_wear() > 0 and
189171
workbench:repairable(stackname)) or
190-
(listname == "input" and registered_nodes[stackname .. "_cube"]) or
172+
(listname == "input" and minetest.registered_nodes[stackname .. "_cube"]) or
191173
(listname == "hammer" and stackname == "xdecor:hammer") or
192174
listname == "storage" then
193175
return stack:get_count()
@@ -232,7 +214,7 @@ function workbench.on_take(pos, listname, index, stack, player)
232214
local stackname = stack:get_name()
233215

234216
if listname == "input" then
235-
if stackname == inputname and registered_nodes[inputname .. "_cube"] then
217+
if stackname == inputname and minetest.registered_nodes[inputname .. "_cube"] then
236218
workbench:get_output(inv, input, stackname)
237219
else
238220
inv:set_list("forms", {})
@@ -274,69 +256,67 @@ xdecor.register("workbench", {
274256
allow_metadata_inventory_move = workbench.allow_move
275257
})
276258

277-
minetest.register_on_mods_loaded(function()
278-
for _, d in ipairs(workbench.defs) do
279-
for i = 1, #nodes do
280-
local node = nodes[i]
281-
local mod_name, item_name = node:match("^(.-):(.*)")
282-
local def = registered_nodes[node]
283-
284-
if item_name and d[3] then
285-
local groups = {}
286-
local tiles
287-
groups.not_in_creative_inventory = 1
288-
289-
for k, v in pairs(def.groups) do
290-
if k ~= "wood" and k ~= "stone" and k ~= "level" then
291-
groups[k] = v
292-
end
293-
end
259+
for _, d in ipairs(workbench.defs) do
260+
for i = 1, #nodes do
261+
local node = nodes[i]
262+
local mod_name, item_name = node:match("^(.-):(.*)")
263+
local def = minetest.registered_nodes[node]
294264

295-
if def.tiles then
296-
if #def.tiles > 1 and (def.drawtype:sub(1,5) ~= "glass") then
297-
tiles = def.tiles
298-
else
299-
tiles = {def.tiles[1]}
300-
end
301-
else
302-
tiles = {def.tile_images[1]}
265+
if item_name and d[3] then
266+
local groups = {}
267+
local tiles
268+
groups.not_in_creative_inventory = 1
269+
270+
for k, v in pairs(def.groups) do
271+
if k ~= "wood" and k ~= "stone" and k ~= "level" then
272+
groups[k] = v
303273
end
274+
end
304275

305-
--TODO: Translation support for Stairs/Slab
306-
if not registered_nodes["stairs:slab_" .. item_name] then
307-
stairs.register_stair_and_slab(item_name, node,
308-
groups, tiles, def.description .. " Stair",
309-
def.description .. " Slab", def.sounds)
276+
if def.tiles then
277+
if #def.tiles > 1 and (def.drawtype:sub(1,5) ~= "glass") then
278+
tiles = def.tiles
279+
else
280+
tiles = {def.tiles[1]}
310281
end
282+
else
283+
tiles = {def.tile_images[1]}
284+
end
311285

312-
minetest.register_node(":" .. node .. "_" .. d[1], {
313-
--TODO: Translation support
314-
description = def.description .. " " .. d[1]:gsub("^%l", string.upper),
315-
paramtype = "light",
316-
paramtype2 = "facedir",
317-
drawtype = "nodebox",
318-
sounds = def.sounds,
319-
tiles = tiles,
320-
groups = groups,
321-
-- `unpack` has been changed to `table.unpack` in newest Lua versions
322-
node_box = xdecor.pixelbox(16, {unpack(d, 3)}),
323-
sunlight_propagates = true,
324-
on_place = minetest.rotate_node
325-
})
326-
327-
elseif item_name and mod_name then
328-
minetest.register_alias_force(
329-
("%s:%s_innerstair"):format(mod_name, item_name),
330-
("stairs:stair_inner_%s"):format(item_name)
331-
)
332-
minetest.register_alias_force(
333-
("%s:%s_outerstair"):format(mod_name, item_name),
334-
("stairs:stair_outer_%s"):format(item_name)
335-
)
286+
--TODO: Translation support for Stairs/Slab
287+
if not minetest.registered_nodes["stairs:slab_" .. item_name] then
288+
stairs.register_stair_and_slab(item_name, node,
289+
groups, tiles, def.description .. " Stair",
290+
def.description .. " Slab", def.sounds)
336291
end
292+
293+
minetest.register_node(":" .. node .. "_" .. d[1], {
294+
--TODO: Translation support
295+
description = def.description .. " " .. d[1]:gsub("^%l", string.upper),
296+
paramtype = "light",
297+
paramtype2 = "facedir",
298+
drawtype = "nodebox",
299+
sounds = def.sounds,
300+
tiles = tiles,
301+
groups = groups,
302+
-- `unpack` has been changed to `table.unpack` in newest Lua versions
303+
node_box = xdecor.pixelbox(16, {unpack(d, 3)}),
304+
sunlight_propagates = true,
305+
on_place = minetest.rotate_node
306+
})
307+
308+
elseif item_name and mod_name then
309+
minetest.register_alias_force(
310+
("%s:%s_innerstair"):format(mod_name, item_name),
311+
("stairs:stair_inner_%s"):format(item_name)
312+
)
313+
minetest.register_alias_force(
314+
("%s:%s_outerstair"):format(mod_name, item_name),
315+
("stairs:stair_outer_%s"):format(item_name)
316+
)
337317
end
338-
end
339-
end)
318+
end
319+
end
340320

341321
-- Craft items
342322

textures/xdecor_candle_hanging.png

15.3 KB
Loading

textures/xdecor_radio_back.png

1.16 KB
Loading

textures/xdecor_radio_front.png

1.18 KB
Loading

textures/xdecor_radio_side.png

15.3 KB
Loading

textures/xdecor_radio_top.png

1.19 KB
Loading

0 commit comments

Comments
 (0)