diff --git a/api.lua b/api.lua index b11f5f3..264433b 100644 --- a/api.lua +++ b/api.lua @@ -21,7 +21,11 @@ local internal = dofile(modpath .. "/internal.lua") -- @param node_name string Name of the node, e.g. "default:water_source" -- @return number ID of the liquid function liquid_physics.get_liquid_id(node_name) - return internal.get_liquid_id(node_name) + local id = internal.get_liquid_id(node_name) + if id == 0 then + return nil + end + return id end -- Returns the liquid of the position specified or @@ -30,7 +34,7 @@ end -- @return table Table with liquid_id and liquid_level function liquid_physics.get_liquid_at(pos) local lpn = internal.new_lpn(core.hash_node_position(pos), pos) - if not lpn.liquid_id then + if not lpn.liquid_id or lpn.liquid_id == 0 then return nil end return { liquid_id = lpn.liquid_id, liquid_level = lpn.liquid_level } @@ -43,7 +47,7 @@ end -- @param liquid_level number [0..8] Level of the liquid -- @return bool Success function liquid_physics.set_liquid_at(pos, liquid_id, liquid_level) - if liquid_level > 8 then + if liquid_level < 0 or liquid_level > 8 then return false end local lpn = internal.new_lpn(core.hash_node_position(pos), pos)