From 54abd7bf55bdb7b730576974f3758421d5839879 Mon Sep 17 00:00:00 2001 From: Michal Cieslakiewicz Date: Thu, 7 Feb 2019 10:51:45 +0100 Subject: [PATCH 1/3] Added new button image for BLOCKED state. Warning image (black exclamation mark on yellow field) added and used for BLOCKED state. Player can now see the difference between BLOCKED and FAULT states while accessing machine panel (formspec). Signed-off-by: Michal Cieslakiewicz --- tubelib/states.lua | 4 ++-- tubelib/textures/tubelib_inv_button_warning.png | Bin 0 -> 361 bytes 2 files changed, 2 insertions(+), 2 deletions(-) create mode 100644 tubelib/textures/tubelib_inv_button_warning.png diff --git a/tubelib/states.lua b/tubelib/states.lua index bae0b9a..1b9ec19 100644 --- a/tubelib/states.lua +++ b/tubelib/states.lua @@ -30,7 +30,7 @@ tubelib.StatesImg = { "tubelib_inv_button_on.png", "tubelib_inv_button_standby.png", "tubelib_inv_button_error.png", - "tubelib_inv_button_error.png", + "tubelib_inv_button_warning.png", "tubelib_inv_button_off.png", } @@ -86,4 +86,4 @@ function tubelib.statestring(running) else return "fault" end -end \ No newline at end of file +end diff --git a/tubelib/textures/tubelib_inv_button_warning.png b/tubelib/textures/tubelib_inv_button_warning.png new file mode 100644 index 0000000000000000000000000000000000000000..33ec686b4c379659ab21a497af1bd215de54e52d GIT binary patch literal 361 zcmV-v0ha!WP)F3V~S1QYlyMszreR)+IMh&s Date: Thu, 7 Feb 2019 12:56:23 +0100 Subject: [PATCH 2/3] fermenter: return items to source inventory when faulted. Items should be moved back to source inventory when machine fails due to incorrect type of items there (game internal error). Unused local variable removed. Signed-off-by: Michal Cieslakiewicz --- tubelib_addons1/fermenter.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tubelib_addons1/fermenter.lua b/tubelib_addons1/fermenter.lua index 0ccfa8d..06d38f6 100644 --- a/tubelib_addons1/fermenter.lua +++ b/tubelib_addons1/fermenter.lua @@ -116,11 +116,13 @@ local function convert_leaves_to_biogas(pos, meta) -- take NUM_LEAVES items local items = {} - local fault = false for i = 1, NUM_LEAVES do items[i] = tubelib.get_num_items(meta, "src", 1) if items[i] then -- input available? if not is_leaves(items[i]:get_name()) then + for j = 1, #items do + inv:add_item("src", items[j]) + end State:fault(pos, meta) return end From b7bdd9783e01941283e820e51f6c8e09b91e34e4 Mon Sep 17 00:00:00 2001 From: Michal Cieslakiewicz Date: Thu, 7 Feb 2019 12:58:51 +0100 Subject: [PATCH 3/3] reformer: fix taking items from source inventory. Ported production function from fermenter code. Take items one by one instead of 4 at once to prevent many stacks of 1-3 Biogas items to be left unprocessed. Signed-off-by: Michal Cieslakiewicz --- tubelib_addons1/reformer.lua | 49 +++++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/tubelib_addons1/reformer.lua b/tubelib_addons1/reformer.lua index 9ebc61d..0f02ab6 100644 --- a/tubelib_addons1/reformer.lua +++ b/tubelib_addons1/reformer.lua @@ -23,6 +23,7 @@ local M = minetest.get_meta local STANDBY_TICKS = 4 local COUNTDOWN_TICKS = 4 local CYCLE_TIME = 2 +local NUM_BIOGAS = 4 -- to produce on biofuel local function formspec(self, pos, meta) return "size[8,8]".. @@ -100,26 +101,40 @@ end local function convert_biogas_to_biofuel(pos, meta) local inv = meta:get_inventory() local biofuel = ItemStack("tubelib_addons1:biofuel") - if inv:room_for_item("dst", biofuel) then -- enough output space? - local items = tubelib.get_num_items(meta, "src", 4) - if items then -- input available? - if items:get_name() == "tubelib_addons1:biogas" then -- valid input? - inv:add_item("dst", biofuel) - State:keep_running(pos, meta, COUNTDOWN_TICKS) - return - else - inv:add_item("src", items) - State:fault(pos, meta) - return - end - else - State:idle(pos, meta) - return - end - else + + -- Not enough output space? + if not inv:room_for_item("dst", biofuel) then State:blocked(pos, meta) return end + + -- take NUM_BIOGAS items + local items = {} + for i = 1, NUM_BIOGAS do + items[i] = tubelib.get_num_items(meta, "src", 1) + if items[i] then -- input available? + if items[i]:get_name() ~= "tubelib_addons1:biogas" then + for j = 1, #items do + inv:add_item("src", items[j]) + end + State:fault(pos, meta) + return + end + end + end + + -- put result into dst inventory + if #items == NUM_BIOGAS then + inv:add_item("dst", biofuel) + State:keep_running(pos, meta, COUNTDOWN_TICKS) + return + end + + -- put biogas back to src inventory + for i = 1, #items do + inv:add_item("src", items[i]) + end + State:idle(pos, meta) end