]> git.lizzy.rs Git - xdecor.git/blobdiff - handlers/nodeboxes.lua
Global code style cleaning
[xdecor.git] / handlers / nodeboxes.lua
index 63da57e385433f0d6f4b5f7813f9592be931c36e..4a3d8ca5cac805b38d42f10b701cb44f386fa678 100644 (file)
@@ -1,7 +1,13 @@
 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}
+               return {
+                       -0.5,
+                       -0.5 + (shift or 0),
+                       -0.5,
+                        0.5,
+                       -0.5 + height + (shift or 0),
+                        0.5
+               }
        end,
        slab_z = function(depth)
                return {-0.5, -0.5, -0.5 + depth, 0.5, 0.5, 0.5}
@@ -15,16 +21,18 @@ xdecor.box = {
 }
 
 xdecor.nodebox = {
-       regular = {type="regular"},
-       null = {type="fixed", fixed={0,0,0,0,0,0}}
+       regular = {type = "regular"},
+       null = {
+               type = "fixed", fixed = {0,0,0,0,0,0}
+       }
 }
 
 xdecor.pixelbox = function(size, boxes)
        local fixed = {}
-       for _, box in pairs(boxes) do
+       for _, box in ipairs(boxes) do
                -- `unpack` has been changed to `table.unpack` in newest Lua versions.
                local x, y, z, w, h, l = unpack(box)
-               fixed[#fixed+1] = {
+               fixed[#fixed + 1] = {
                        (x / size) - 0.5,
                        (y / size) - 0.5,
                        (z / size) - 0.5,
@@ -33,26 +41,27 @@ xdecor.pixelbox = function(size, boxes)
                        ((z + l) / size) - 0.5
                }
        end
-       return {type="fixed", fixed=fixed}
+
+       return {type = "fixed", fixed = fixed}
 end
 
 local mt = {}
+
 mt.__index = function(table, key)
        local ref = xdecor.box[key]
        local ref_type = type(ref)
 
        if ref_type == "function" then
                return function(...)
-                       return {type="fixed", fixed=ref(...)}
+                       return {type = "fixed", fixed = ref(...)}
                end
        elseif ref_type == "table" then
-               return {type="fixed", fixed=ref}
+               return {type = "fixed", fixed = ref}
        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
 
-       error("unexpected datatype "..tostring(type(ref)).." while looking for "..key)
+       error("unexpected datatype " .. tostring(type(ref)) .. " while looking for " .. key)
 end
 
 setmetatable(xdecor.nodebox, mt)
-