From a86cb1150194d3eccaea3fd9efc1543394364cfa Mon Sep 17 00:00:00 2001 From: ANAND Date: Wed, 18 Dec 2019 08:21:27 +0530 Subject: [PATCH] tsm_chests: Simplify node lookups a bit by using a table of node-names --- mods/other/tsm_chests/init.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/mods/other/tsm_chests/init.lua b/mods/other/tsm_chests/init.lua index 40e5ced..f4c0c0b 100755 --- a/mods/other/tsm_chests/init.lua +++ b/mods/other/tsm_chests/init.lua @@ -17,6 +17,13 @@ tsm_chests = {} +local non_ground_nodes = { + "air", + "default:water_source", + "default:lava_source", + "default:lava_flowing" +} + local chest_formspec = "size[8,9]" .. default.gui_bg .. @@ -89,7 +96,7 @@ local function findGroundLevel(pos, y_min, y_max) for y = y_max, y_min, -1 do local p = {x=pos.x,y=y,z=pos.z} local name = get_node(p).name - if name == "air" or name == "default:water_source" or name == "default:lava_source" then + if table.indexof(non_ground_nodes, name) ~= -1 then top = y break end @@ -97,7 +104,7 @@ local function findGroundLevel(pos, y_min, y_max) for y=top,y_min,-1 do local p = {x=pos.x,y=y,z=pos.z} local name = get_node(p).name - if name ~= "air" and name ~= "default:water_source" and name ~= "default:lava_source" then + if table.indexof(non_ground_nodes, name) == -1 then ground = y break end