Mechanisms: Fix empty table checking
This commit is contained in:
parent
bcd898146c
commit
6f773427c1
@ -88,7 +88,7 @@ end
|
|||||||
function cauldron.boiling_timer(pos)
|
function cauldron.boiling_timer(pos)
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.5)
|
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 = {}
|
local ingredients = {}
|
||||||
for _, obj in pairs(objs) do
|
for _, obj in pairs(objs) do
|
||||||
|
@ -32,14 +32,14 @@ end
|
|||||||
|
|
||||||
function plate.timer(pos)
|
function plate.timer(pos)
|
||||||
local objs = minetest.get_objects_inside_radius(pos, 0.8)
|
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 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 maxp = {x=pos.x+2, y=pos.y, z=pos.z+2}
|
||||||
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
||||||
|
|
||||||
for _, player in pairs(objs) do
|
for _, player in pairs(objs) do
|
||||||
if player:is_player() then
|
if player:is_player() then
|
||||||
for i = 1, #doors do
|
for i=1, #doors do
|
||||||
door_toggle(pos, doors[i], player)
|
door_toggle(pos, doors[i], player)
|
||||||
end
|
end
|
||||||
break
|
break
|
||||||
@ -92,15 +92,13 @@ xdecor.register("lever_off", {
|
|||||||
sounds = default.node_sound_stone_defaults(),
|
sounds = default.node_sound_stone_defaults(),
|
||||||
sunlight_propagates = true,
|
sunlight_propagates = true,
|
||||||
on_rotate = screwdriver.rotate_simple,
|
on_rotate = screwdriver.rotate_simple,
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing)
|
on_rightclick = function(pos, node, clicker, itemstack)
|
||||||
if not doors.get then
|
if not doors.get then return itemstack end
|
||||||
return itemstack
|
|
||||||
end
|
|
||||||
local minp = {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 maxp = {x=pos.x+2, y=pos.y+1, z=pos.z+2}
|
||||||
local doors = minetest.find_nodes_in_area(minp, maxp, "group:door")
|
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)
|
door_toggle(pos, doors[i], clicker)
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
Loading…
Reference in New Issue
Block a user