Minor style cleaning in handlers
This commit is contained in:
parent
d3bdb95ccd
commit
9b95401a36
@ -1,8 +1,16 @@
|
|||||||
xdecor.box = {
|
xdecor.box = {
|
||||||
slab_y = function(height, shift) return { -0.5, -0.5+(shift or 0), -0.5, 0.5, -0.5+height+(shift or 0), 0.5 } end,
|
slab_y = function(height, shift)
|
||||||
slab_z = function(depth) return { -0.5, -0.5, -0.5+depth, 0.5, 0.5, 0.5 } end,
|
return { -0.5, -0.5+(shift or 0), -0.5, 0.5, -0.5+height+(shift or 0), 0.5 }
|
||||||
bar_y = function(radius) return {-radius, -0.5, -radius, radius, 0.5, radius} end,
|
end,
|
||||||
cuboid = function(radius_x, radius_y, radius_z) return {-radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z} end
|
slab_z = function(depth)
|
||||||
|
return { -0.5, -0.5, -0.5+depth, 0.5, 0.5, 0.5 }
|
||||||
|
end,
|
||||||
|
bar_y = function(radius)
|
||||||
|
return { -radius, -0.5, -radius, radius, 0.5, radius }
|
||||||
|
end,
|
||||||
|
cuboid = function(radius_x, radius_y, radius_z)
|
||||||
|
return { -radius_x, -radius_y, -radius_z, radius_x, radius_y, radius_z }
|
||||||
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
xdecor.nodebox = {
|
xdecor.nodebox = {
|
||||||
@ -14,6 +22,7 @@ local mt = {}
|
|||||||
mt.__index = function(table, key)
|
mt.__index = function(table, key)
|
||||||
local ref = xdecor.box[key]
|
local ref = xdecor.box[key]
|
||||||
local ref_type = type(ref)
|
local ref_type = type(ref)
|
||||||
|
|
||||||
if ref_type == "function" then
|
if ref_type == "function" then
|
||||||
return function(...)
|
return function(...)
|
||||||
return { type = "fixed", fixed = ref(...) }
|
return { type = "fixed", fixed = ref(...) }
|
||||||
@ -21,8 +30,11 @@ mt.__index = function(table, key)
|
|||||||
elseif ref_type == "table" then
|
elseif ref_type == "table" then
|
||||||
return { type = "fixed", fixed = ref }
|
return { type = "fixed", fixed = ref }
|
||||||
elseif ref_type == "nil" then
|
elseif ref_type == "nil" then
|
||||||
error(key .. "could not be found among nodebox presets and functions")
|
error(key.."could not be found among nodebox presets and functions")
|
||||||
end
|
end
|
||||||
error("unexpected datatype " .. tostring(type(ref)) .. " while looking for " .. key)
|
|
||||||
|
error("unexpected datatype "..tostring(type(ref)).." while looking for "..key)
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(xdecor.nodebox, mt)
|
setmetatable(xdecor.nodebox, mt)
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ local function get_formspec_by_size(size)
|
|||||||
return formspec or default_inventory_formspecs
|
return formspec or default_inventory_formspecs
|
||||||
end
|
end
|
||||||
|
|
||||||
local function drop_stuff() -- thanks to LNJplus for this function
|
local function drop_stuff()
|
||||||
return function(pos, oldnode, oldmetadata, digger)
|
return function(pos, oldnode, oldmetadata, digger)
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:from_table(oldmetadata)
|
meta:from_table(oldmetadata)
|
||||||
|
Loading…
Reference in New Issue
Block a user