]> git.lizzy.rs Git - xdecor.git/blobdiff - handlers/registration.lua
Global code style cleaning
[xdecor.git] / handlers / registration.lua
index cbeabdb03822c105f22d5c9e3d17abe0343877a0..b16dc4b4f3752bcaf5c22addc62b4d1bd5a6f9b9 100644 (file)
@@ -1,4 +1,4 @@
-xbg = default.gui_bg..default.gui_bg_img..default.gui_slots
+xbg = default.gui_bg .. default.gui_bg_img .. default.gui_slots
 local default_inventory_size = 32
 
 local default_inventory_formspecs = {
@@ -6,30 +6,30 @@ local default_inventory_formspecs = {
                list[context;main;0,0;8,1;]
                list[current_player;main;0,2;8,4;]
                listring[current_player;main]
-               listring[context;main] ]]
-               ..default.get_hotbar_bg(0,2),
+               listring[context;main] ]] ..
+               default.get_hotbar_bg(0,2),
 
        ["16"] = [[ size[8,7]
                list[context;main;0,0;8,2;]
                list[current_player;main;0,3;8,4;]
                listring[current_player;main]
-               listring[context;main] ]]
-               ..default.get_hotbar_bg(0,3),
+               listring[context;main] ]] ..
+               default.get_hotbar_bg(0,3),
 
        ["24"] = [[ size[8,8]
                list[context;main;0,0;8,3;]
                list[current_player;main;0,4;8,4;]
                listring[current_player;main]
-               listring[context;main]" ]]
-               ..default.get_hotbar_bg(0,4),
+               listring[context;main]" ]] ..
+               default.get_hotbar_bg(0,4),
 
        ["32"] = [[ size[8,9]
                list[context;main;0,0.3;8,4;]
                list[current_player;main;0,4.85;8,1;]
                list[current_player;main;0,6.08;8,3;8]
                listring[current_player;main]
-               listring[context;main] ]]
-               ..default.get_hotbar_bg(0,4.85)
+               listring[context;main] ]] ..
+               default.get_hotbar_bg(0,4.85)
 }
 
 local function get_formspec_by_size(size)
@@ -42,13 +42,13 @@ local default_can_dig = function(pos)
        return inv:is_empty("main")
 end
 
-function xdecor.register(name, def)
-       local function xdecor_stairs_alternative(nodename, def)
+local function xdecor_stairs_alternative(nodename, def)
                local mod, name = nodename:match("(.*):(.*)")
+
                for groupname, value in pairs(def.groups) do
                        if groupname ~= "cracky"    and groupname ~= "choppy"  and
                           groupname ~= "flammable" and groupname ~= "crumbly" and
-                          groupname ~= "snappy"    then
+                          groupname ~= "snappy" then
                                def.groups.groupname = nil
                        end
                end
@@ -65,17 +65,18 @@ function xdecor.register(name, def)
                                        sounds = def.sounds,
                                }
                        )
-               elseif minetest.get_modpath("stairs") then      
+               elseif minetest.get_modpath("stairs") then
                        stairs.register_stair_and_slab(name,nodename,
                                def.groups,
                                def.tiles,
                                ("%s Stair"):format(def.description),
                                ("%s Slab"):format(def.description),
                                def.sounds
-                       )       
-               end     
+                       )
+               end
        end
 
+function xdecor.register(name, def)
        def.drawtype = def.drawtype or (def.mesh and "mesh") or (def.node_box and "nodebox")
        def.sounds = def.sounds or default.node_sound_defaults()
 
@@ -108,11 +109,14 @@ function xdecor.register(name, def)
 
                        local size = inventory.size or default_inventory_size
                        local inv = meta:get_inventory()
+
                        inv:set_size("main", size)
-                       meta:set_string("formspec", (inventory.formspec or
-                                       get_formspec_by_size(size))..xbg)
+                       meta:set_string("formspec",
+                               (inventory.formspec or get_formspec_by_size(size)) .. xbg)
                end
+
                def.can_dig = def.can_dig or default_can_dig
+
        elseif infotext and not def.on_construct then
                def.on_construct = function(pos)
                        local meta = minetest.get_meta(pos)
@@ -120,12 +124,12 @@ function xdecor.register(name, def)
                end
        end
 
-       minetest.register_node("xdecor:"..name, def)
+       minetest.register_node("xdecor:" .. name, def)
 
        local workbench = minetest.settings:get_bool("enable_xdecor_workbench")
 
        if workbench == false and
-          (minetest.get_modpath("moreblocks") or minetest.get_modpath("stairs")) then
+         (minetest.get_modpath("moreblocks") or minetest.get_modpath("stairs")) then
                if xdecor.stairs_valid_def(def) then
                        xdecor_stairs_alternative("xdecor:"..name, def)
                end