From 66c1ce1be51411ebbb7be422ffe500ad5fb8a13c Mon Sep 17 00:00:00 2001 From: NathanSalapat Date: Sun, 1 Sep 2019 19:51:28 -0500 Subject: [PATCH] fixed a bug that would crash the game if player tried to take liquid out of an empty silo or barrel. --- drink_machines.lua | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/drink_machines.lua b/drink_machines.lua index 68b4922..81602e2 100644 --- a/drink_machines.lua +++ b/drink_machines.lua @@ -478,11 +478,17 @@ minetest.register_node('drinks:liquid_barrel', { return 0 end elseif listname == 'dst' then --removing liquid - local inputstack = stack:get_name() - local inputcount = stack:get_count() - local valid = string.sub(inputstack, 1, 7) - if valid == 'vessels' or valid == 'bucket:' then - return inputcount + --make sure there is a liquid to remove + local juice = meta:get_string('fruit') + if juice ~= 'empty' then + local inputstack = stack:get_name() + local inputcount = stack:get_count() + local valid = string.sub(inputstack, 1, 7) + if valid == 'vessels' or valid == 'bucket:' then + return inputcount + else + return 0 + end else return 0 end @@ -589,11 +595,17 @@ minetest.register_node('drinks:liquid_silo', { return 0 end elseif listname == 'dst' then --removing liquid - local inputstack = stack:get_name() - local inputcount = stack:get_count() - local valid = string.sub(inputstack, 1, 7) - if valid == 'vessels' or valid == 'bucket:' then - return inputcount + --make sure there is liquid to take_item + local juice = meta:get_string('fruit') + if juice ~= 'empty' then + local inputstack = stack:get_name() + local inputcount = stack:get_count() + local valid = string.sub(inputstack, 1, 7) + if valid == 'vessels' or valid == 'bucket:' then + return inputcount + else + return 0 + end else return 0 end