Work Table : use pixel nodeboxes

This commit is contained in:
kilbith 2016-01-16 13:21:35 +01:00
parent 8c59b1bf17
commit 77821b235e
2 changed files with 38 additions and 14 deletions

View File

@ -18,6 +18,22 @@ xdecor.nodebox = {
null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } } null = { type = "fixed", fixed = { 0, 0, 0, 0, 0, 0 } }
} }
xdecor.pixelnodebox = function(size, boxes)
local fixed = {}
for _, box in pairs(boxes) do
local x, y, z, w, h, l = unpack(box)
fixed[#fixed+1] = {
(x / size) - 0.5,
(y / size) - 0.5,
(z / size) - 0.5,
(w / size) - 0.5,
(h / size) - 0.5,
(l / size) - 0.5
}
end
return { type = "fixed", fixed = fixed }
end
local mt = {} local mt = {}
mt.__index = function(table, key) mt.__index = function(table, key)
local ref = xdecor.box[key] local ref = xdecor.box[key]

View File

@ -26,19 +26,27 @@ local nodes = { -- Nodes allowed to be cut. Registration format: [mod name] = [[
]], ]],
} }
local defs = { -- Nodebox name, yield, definition. local defs = {
{"nanoslab", 16, {-.5,-.5,-.5,0,-.4375,0}}, -- Name Yield X Y Z W H L
{"micropanel", 16, {-.5,-.5,-.5,.5,-.4375,0}}, {"nanoslab", 16, {{ 0, 0, 0, 8, 1, 8 }}},
{"microslab", 8, {-.5,-.5,-.5,.5,-.4375,.5}}, {"micropanel", 16, {{ 0, 0, 0, 16, 1, 8 }}},
{"thinstair", 8, {{-.5,-.0625,-.5,.5,0,0},{-.5,.4375,0,.5,.5,.5}}}, {"microslab", 8, {{ 0, 0, 0, 16, 1, 16 }}},
{"cube", 4, {-.5,-.5,0,0,0,.5}}, {"thinstair", 8, {{ 0, 7, 0, 16, 8, 8 },{
{"panel", 4, {-.5,-.5,-.5,.5,0,0}}, 0, 15, 8, 16, 16, 16 }}},
{"slab", 2, {-.5,-.5,-.5,.5,0,.5}}, {"cube", 4, {{ 0, 0, 8, 8, 8, 16 }}},
{"doublepanel", 2, {{-.5,-.5,-.5,.5,0,0},{-.5,0,0,.5,.5,.5}}}, {"panel", 4, {{ 0, 0, 0, 16, 8, 8 }}},
{"halfstair", 2, {{-.5,-.5,-.5,0,0,.5},{-.5,0,0,0,.5,.5}}}, {"slab", 2, {{ 0, 0, 0, 16, 8, 16 }}},
{"outerstair", 1, {{-.5,-.5,-.5,.5,0,.5},{-.5,0,0,0,.5,.5}}}, {"doublepanel", 2, {{ 0, 0, 0, 16, 8, 8 },{
{"stair", 1, {{-.5,-.5,-.5,.5,0,.5},{-.5,0,0,.5,.5,.5}}}, 0, 8, 8, 16, 16, 16 }}},
{"innerstair", 1, {{-.5,-.5,-.5,.5,0,.5},{-.5,0,0,.5,.5,.5},{-.5,0,-.5,0,.5,0}}} {"halfstair", 2, {{ 0, 0, 0, 8, 8, 16 },{
0, 8, 8, 8, 16, 16 }}},
{"outerstair", 1, {{ 0, 0, 0, 16, 8, 16 },{
0, 8, 8, 8, 16, 16 }}},
{"stair", 1, {{ 0, 0, 0, 16, 8, 16 },{
0, 8, 8, 16, 16, 16 }}},
{"innerstair", 1, {{ 0, 0, 0, 16, 8, 16 },{
0, 8, 8, 16, 16, 16 },{
0, 8, 0, 8, 16, 8 }}}
} }
function worktable.get_recipe(item) function worktable.get_recipe(item)
@ -415,7 +423,7 @@ for name in n:gmatch("[%w_]+") do
sounds = ndef.sounds, sounds = ndef.sounds,
tiles = tiles, tiles = tiles,
groups = groups, groups = groups,
node_box = {type = "fixed", fixed = d[3]}, node_box = xdecor.pixelnodebox(16, d[3]),
sunlight_propagates = true, sunlight_propagates = true,
on_place = minetest.rotate_node on_place = minetest.rotate_node
}) })