From 6f773427c19a04ae56d811d53efe45d50cc39cfc Mon Sep 17 00:00:00 2001 From: JPG Date: Fri, 30 Dec 2016 15:11:37 +0100 Subject: [PATCH] Mechanisms: Fix empty table checking --- src/cooking.lua | 2 +- src/mechanisms.lua | 12 +++++------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/cooking.lua b/src/cooking.lua index a14e30e..aaeae79 100644 --- a/src/cooking.lua +++ b/src/cooking.lua @@ -88,7 +88,7 @@ end function cauldron.boiling_timer(pos) local node = minetest.get_node(pos) local objs = minetest.get_objects_inside_radius(pos, 0.5) - if objs == {} then return true end + if not next(objs) then return true end local ingredients = {} for _, obj in pairs(objs) do diff --git a/src/mechanisms.lua b/src/mechanisms.lua index 4686302..5ca73a9 100644 --- a/src/mechanisms.lua +++ b/src/mechanisms.lua @@ -32,14 +32,14 @@ end function plate.timer(pos) local objs = minetest.get_objects_inside_radius(pos, 0.8) - if objs == {} or not doors.get then return true end + 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 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 @@ -92,15 +92,13 @@ xdecor.register("lever_off", { sounds = default.node_sound_stone_defaults(), sunlight_propagates = true, on_rotate = screwdriver.rotate_simple, - on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) - if not doors.get then - return itemstack - end + 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 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