]> git.lizzy.rs Git - xdecor.git/blobdiff - src/mechanisms.lua
Global code style cleaning
[xdecor.git] / src / mechanisms.lua
index b065c90471b7ca8fb26699b155c0e91a712e77bb..e453229099e578902cb3f48978ed290b6465399b 100644 (file)
@@ -12,14 +12,14 @@ local function door_toggle(pos_actuator, pos_door, player)
 
        if actuator.name:sub(-4) == "_off" then
                minetest.set_node(pos_actuator,
-                       {name=actuator.name:gsub("_off", "_on"), param2=actuator.param2})
+                       {name = actuator.name:gsub("_off", "_on"), param2 = actuator.param2})
        end
        door:open(player)
 
        minetest.after(2, function()
                if minetest.get_node(pos_actuator).name:sub(-3) == "_on" then
                        minetest.set_node(pos_actuator,
-                               {name=actuator.name, param2=actuator.param2})
+                               {name = actuator.name, param2 = actuator.param2})
                end
                -- Re-get player object (or nil) because 'player' could
                -- be an invalid object at this time (player left)
@@ -35,25 +35,27 @@ end
 function plate.timer(pos)
        local objs = minetest.get_objects_inside_radius(pos, 0.8)
        if not next(objs) or not doors.get then return true end
-       local minp = {x=pos.x-2, y=pos.y, z=pos.z-2}
-       local maxp = {x=pos.x+2, y=pos.y, z=pos.z+2}
+
+       local minp = {x = pos.x - 2, y = pos.y, z = pos.z - 2}
+       local maxp = {x = pos.x + 2, y = pos.y, z = pos.z + 2}
        local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
 
        for _, player in pairs(objs) do
                if player:is_player() then
-                       for i=1, #doors do
+                       for i = 1, #doors do
                                door_toggle(pos, doors[i], player)
                        end
                        break
                end
        end
+
        return true
 end
 
 function plate.register(material, desc, def)
-       xdecor.register("pressure_"..material.."_off", {
-               description = desc.." Pressure Plate",
-               tiles = {"xdecor_pressure_"..material..".png"},
+       xdecor.register("pressure_" .. material .. "_off", {
+               description = desc .. " Pressure Plate",
+               tiles = {"xdecor_pressure_" .. material .. ".png"},
                drawtype = "nodebox",
                node_box = xdecor.pixelbox(16, {{1, 0, 1, 14, 1, 14}}),
                groups = def.groups,
@@ -63,13 +65,13 @@ function plate.register(material, desc, def)
                on_construct = plate.construct,
                on_timer = plate.timer
        })
-       xdecor.register("pressure_"..material.."_on", {
-               tiles = {"xdecor_pressure_"..material..".png"},
+       xdecor.register("pressure_" .. material .. "_on", {
+               tiles = {"xdecor_pressure_" .. material .. ".png"},
                drawtype = "nodebox",
                node_box = xdecor.pixelbox(16, {{1, 0, 1, 14, 0.4, 14}}),
                groups = def.groups,
                sounds = def.sounds,
-               drop = "xdecor:pressure_"..material.."_off",
+               drop = "xdecor:pressure_" .. material .. "_off",
                sunlight_propagates = true,
                on_rotate = screwdriver.rotate_simple
        })
@@ -77,12 +79,12 @@ end
 
 plate.register("wood", "Wooden", {
        sounds = default.node_sound_wood_defaults(),
-       groups = {choppy=3, oddly_breakable_by_hand=2, flammable=2}
+       groups = {choppy = 3, oddly_breakable_by_hand = 2, flammable = 2}
 })
 
 plate.register("stone", "Stone", {
        sounds = default.node_sound_stone_defaults(),
-       groups = {cracky=3, oddly_breakable_by_hand=2}
+       groups = {cracky = 3, oddly_breakable_by_hand = 2}
 })
 
 xdecor.register("lever_off", {
@@ -90,19 +92,21 @@ xdecor.register("lever_off", {
        tiles = {"xdecor_lever_off.png"},
        drawtype = "nodebox",
        node_box = xdecor.pixelbox(16, {{2, 1, 15, 12, 14, 1}}),
-       groups = {cracky=3, oddly_breakable_by_hand=2},
+       groups = {cracky = 3, oddly_breakable_by_hand = 2},
        sounds = default.node_sound_stone_defaults(),
        sunlight_propagates = true,
        on_rotate = screwdriver.rotate_simple,
+
        on_rightclick = function(pos, node, clicker, itemstack)
                if not doors.get then return itemstack end
-               local minp = {x=pos.x-2, y=pos.y-1, z=pos.z-2}
-               local maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
+               local minp = {x = pos.x - 2, y = pos.y - 1, z = pos.z - 2}
+               local maxp = {x = pos.x + 2, y = pos.y + 1, z = pos.z + 2}
                local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
 
-               for i=1, #doors do
+               for i = 1, #doors do
                        door_toggle(pos, doors[i], clicker)
                end
+
                return itemstack
        end
 })
@@ -111,7 +115,7 @@ xdecor.register("lever_on", {
        tiles = {"xdecor_lever_on.png"},
        drawtype = "nodebox",
        node_box = xdecor.pixelbox(16, {{2, 1, 15, 12, 14, 1}}),
-       groups = {cracky=3, oddly_breakable_by_hand=2, not_in_creative_inventory=1},
+       groups = {cracky = 3, oddly_breakable_by_hand = 2, not_in_creative_inventory = 1},
        sounds = default.node_sound_stone_defaults(),
        sunlight_propagates = true,
        on_rotate = screwdriver.rotate_simple,
@@ -138,4 +142,4 @@ minetest.register_craft({
                {"group:stick"},
                {"group:stone"}
        }
-})
\ No newline at end of file
+})