itemstack:replace("bucket:bucket_empty")
end
end,
- collision_box = xdecor.pixelnodebox(16, cauldron_cbox)
+ collision_box = xdecor.pixelbox(16, cauldron_cbox)
})
xdecor.register("cauldron_idle", {
tiles = {"xdecor_cauldron_top_idle.png", "xdecor_cauldron_sides.png"},
drop = "xdecor:cauldron_empty",
infotext = "Cauldron (idle)",
- collision_box = xdecor.pixelnodebox(16, cauldron_cbox),
+ collision_box = xdecor.pixelbox(16, cauldron_cbox),
on_rightclick = fill_water_bucket
})
animation = {type="vertical_frames", length=3.0} },
"xdecor_cauldron_sides.png"
},
- collision_box = xdecor.pixelnodebox(16, cauldron_cbox),
+ collision_box = xdecor.pixelbox(16, cauldron_cbox),
on_rightclick = fill_water_bucket
})
animation = {type="vertical_frames", length=3.0} },
"xdecor_cauldron_sides.png"
},
- collision_box = xdecor.pixelnodebox(16, cauldron_cbox),
+ collision_box = xdecor.pixelbox(16, cauldron_cbox),
on_rightclick = function(pos, node, clicker, itemstack)
local inv = clicker:get_inventory()
local wield_item = clicker:get_wielded_item()
--- /dev/null
+-- Returns the greatest numeric key in a table.
+function xdecor.maxn(T)
+ local n = 0
+ for k in pairs(T) do
+ if k > n then n = k end
+ end
+ return n
+end
+
+-- Returns the length of an hash table.
+function xdecor.tablelen(T)
+ local n = 0
+ for _ in pairs(T) do n = n + 1 end
+ return n
+end
+
+-- Deep copy of a table. Borrowed from mesecons mod (https://github.com/Jeija/minetest-mod-mesecons).
+function xdecor.tablecopy(T)
+ if type(T) ~= "table" then return T end -- No need to copy.
+ local new = {}
+
+ for k, v in pairs(T) do
+ if type(v) == "table" then
+ new[k] = xdecor.tablecopy(v)
+ else
+ new[k] = item
+ end
+ end
+ return new
+end
+
null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } }
}
-xdecor.pixelnodebox = function(size, boxes)
+xdecor.pixelbox = function(size, boxes)
local fixed = {}
for _, box in pairs(boxes) do
- local x, y, z, w, h, l = unpack(box)
+ local x, y, z, w, h, l = unpack(box) -- `unpack` has been changed to `table.unpack` in newest Lua versions.
fixed[#fixed+1] = {
(x / size) - 0.5,
(y / size) - 0.5,
xdecor = {}
local modpath = minetest.get_modpath("xdecor")
+dofile(modpath.."/handlers/helpers.lua")
dofile(modpath.."/handlers/nodeboxes.lua")
dofile(modpath.."/handlers/registration.lua")
dofile(modpath.."/chess.lua")
on_rotate = screwdriver.disallow,
sunlight_propagates = true,
inventory_image = "xdecor_frame.png",
- node_box = {
- type = "fixed",
- fixed = {-0.5, -0.5, 0.4375, 0.5, 0.5, 0.5}
- },
+ node_box = xdecor.nodebox.slab_z(0.9375),
tiles = {
"xdecor_wood.png", "xdecor_wood.png", "xdecor_wood.png",
"xdecor_wood.png", "xdecor_wood.png", "xdecor_frame.png"
on_rotate = screwdriver.rotate_simple,
sounds = default.node_sound_stone_defaults(),
sunlight_propagates = true,
- node_box = xdecor.pixelnodebox(16, {
+ node_box = xdecor.pixelbox(16, {
{8, 0, 8, 6, .5, 6},
{1, 0, 1, 6, .5, 6},
{1, 0, 10, 5, .5, 5},
tiles = {"xdecor_wood.png"},
groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
sounds = default.node_sound_wood_defaults(),
- node_box = xdecor.pixelnodebox(16, {
+ node_box = xdecor.pixelbox(16, {
{0, 14, 0, 16, 2, 16}, {5.5, 0, 5.5, 5, 14, 6}
})
})
sounds = default.node_sound_wood_defaults(),
groups = {choppy=3, oddly_breakable_by_hand=2, flammable=3},
on_rotate = screwdriver.rotate_simple,
- node_box = xdecor.pixelnodebox(16, {
+ node_box = xdecor.pixelbox(16, {
{3, 0, 11, 2, 16, 2},
{11, 0, 11, 2, 16, 2},
{5, 9, 11.5, 6, 6, 1},
local items = minetest.get_all_craft_recipes(item)[recipe_num].items
local width = minetest.get_all_craft_recipes(item)[recipe_num].width
if width == 0 then width = math.min(3, #items) end
- local rows = math.ceil(table.maxn(items) / width)
+ local rows = math.ceil(table.maxn(items) / width) -- Lua 5.3 removed `table.maxn`, use `xdecor.maxn` in case of failure.
local function is_group(item)
if item:find("^group:") then return "G" end
sounds = def.sounds,
tiles = tiles,
groups = groups,
- node_box = xdecor.pixelnodebox(16, {unpack(d, 3)}),
+ node_box = xdecor.pixelbox(16, {unpack(d, 3)}), -- `unpack` has been changed to `table.unpack` in newest Lua versions.
sunlight_propagates = true,
on_place = minetest.rotate_node,
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)