biogasmachines: freezer: allow taking items from working tray.
Items can be taken from working tray ('cur' inventory list) when machine is stopped. This functionality is identical to gasifier behaviour. Signed-off-by: Michal Cieslakiewicz <michal.cieslakiewicz@wp.pl>
This commit is contained in:
parent
33c7cbf09e
commit
1c93dd5e73
@ -35,8 +35,9 @@
|
|||||||
* partially frozen items (due to work being interrupted by on/off
|
* partially frozen items (due to work being interrupted by on/off
|
||||||
switch) have to be frozen again from beginning, Biogas used for
|
switch) have to be frozen again from beginning, Biogas used for
|
||||||
such partial freeze is not recoverable
|
such partial freeze is not recoverable
|
||||||
* bucket freezing tray cannot be emptied manually, it becomes empty
|
* bucket freezing tray cannot be emptied manually when machine is
|
||||||
only when device finishes converting water to ice
|
running, stop the device to take water bucket; please note that
|
||||||
|
tray cannot be loaded manually, please use input inventory
|
||||||
* when using pipes, internal water tank is filled completely before
|
* when using pipes, internal water tank is filled completely before
|
||||||
process starts; shutting down water source during freezing does
|
process starts; shutting down water source during freezing does
|
||||||
not stop it
|
not stop it
|
||||||
@ -100,9 +101,6 @@ local function formspec(state, water_pipe, fuel_percent, item_percent, show_icon
|
|||||||
default.gui_slots ..
|
default.gui_slots ..
|
||||||
"list[context;src;0,0;" .. fmxy.inv_in_w .. "," .. fmxy.inv_h .. ";]" ..
|
"list[context;src;0,0;" .. fmxy.inv_in_w .. "," .. fmxy.inv_h .. ";]" ..
|
||||||
(show_icons and "item_image[0,0;1,1;bucket:bucket_water]" or "") ..
|
(show_icons and "item_image[0,0;1,1;bucket:bucket_water]" or "") ..
|
||||||
"box[" .. fmxy.inv_in_w .. ",0;0.82,0.9;" ..
|
|
||||||
((state == tubelib.RUNNING and not water_pipe)
|
|
||||||
and "#2F4FBF]" or "#1F3F9F]") ..
|
|
||||||
"list[context;cur;" .. fmxy.inv_in_w .. ",0;1,1;]" ..
|
"list[context;cur;" .. fmxy.inv_in_w .. ",0;1,1;]" ..
|
||||||
"image[" .. fmxy.mid_x .. ",0;1,1;biogasmachines_freezer_pipe_inv_" ..
|
"image[" .. fmxy.mid_x .. ",0;1,1;biogasmachines_freezer_pipe_inv_" ..
|
||||||
(water_pipe and "fg" or "bg") .. ".png]" ..
|
(water_pipe and "fg" or "bg") .. ".png]" ..
|
||||||
@ -138,6 +136,9 @@ local function formspec(state, water_pipe, fuel_percent, item_percent, show_icon
|
|||||||
"listring[current_player;main]" ..
|
"listring[current_player;main]" ..
|
||||||
"listring[context;fuel]" ..
|
"listring[context;fuel]" ..
|
||||||
"listring[current_player;main]" ..
|
"listring[current_player;main]" ..
|
||||||
|
(state == tubelib.RUNNING and not water_pipe and
|
||||||
|
"box[" .. fmxy.inv_in_w .. ",0;0.82,0.9;#2F4FBF]" or
|
||||||
|
"listring[context;cur]listring[current_player;main]") ..
|
||||||
default.get_hotbar_bg(0, 4)
|
default.get_hotbar_bg(0, 4)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -169,9 +170,7 @@ local function freezer_start(pos)
|
|||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
local fuel = meta:get_int("fuel_ticks")
|
local fuel = meta:get_int("fuel_ticks")
|
||||||
local label = minetest.registered_nodes[node.name].description
|
local label = minetest.registered_nodes[node.name].description
|
||||||
if meta:get_int("source") == SOURCE_PIPE then
|
meta:set_int("source", SOURCE_EMPTY)
|
||||||
meta:set_int("source", SOURCE_EMPTY)
|
|
||||||
end
|
|
||||||
meta:set_int("item_ticks", ICE_TIME_SEC)
|
meta:set_int("item_ticks", ICE_TIME_SEC)
|
||||||
meta:set_int("running", TICKS_TO_SLEEP)
|
meta:set_int("running", TICKS_TO_SLEEP)
|
||||||
meta:set_string("infotext", label .. " " .. number .. ": running")
|
meta:set_string("infotext", label .. " " .. number .. ": running")
|
||||||
@ -189,9 +188,7 @@ local function freezer_stop(pos)
|
|||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
local fuel = meta:get_int("fuel_ticks")
|
local fuel = meta:get_int("fuel_ticks")
|
||||||
local label = minetest.registered_nodes[node.name].description
|
local label = minetest.registered_nodes[node.name].description
|
||||||
if meta:get_int("source") == SOURCE_PIPE then
|
meta:set_int("source", SOURCE_EMPTY)
|
||||||
meta:set_int("source", SOURCE_EMPTY)
|
|
||||||
end
|
|
||||||
meta:set_int("item_ticks", ICE_TIME_SEC)
|
meta:set_int("item_ticks", ICE_TIME_SEC)
|
||||||
meta:set_int("running", tubelib.STATE_STOPPED)
|
meta:set_int("running", tubelib.STATE_STOPPED)
|
||||||
meta:set_string("infotext", label .. " " .. number .. ": stopped")
|
meta:set_string("infotext", label .. " " .. number .. ": stopped")
|
||||||
@ -226,9 +223,7 @@ local function freezer_fault(pos)
|
|||||||
local number = meta:get_string("number")
|
local number = meta:get_string("number")
|
||||||
local fuel = meta:get_int("fuel_ticks")
|
local fuel = meta:get_int("fuel_ticks")
|
||||||
local label = minetest.registered_nodes[node.name].description
|
local label = minetest.registered_nodes[node.name].description
|
||||||
if meta:get_int("source") == SOURCE_PIPE then
|
meta:set_int("source", SOURCE_EMPTY)
|
||||||
meta:set_int("source", SOURCE_EMPTY)
|
|
||||||
end
|
|
||||||
meta:set_int("item_ticks", ICE_TIME_SEC)
|
meta:set_int("item_ticks", ICE_TIME_SEC)
|
||||||
meta:set_int("running", tubelib.STATE_FAULT)
|
meta:set_int("running", tubelib.STATE_FAULT)
|
||||||
meta:set_string("infotext", label .. " " .. number .. ": fault")
|
meta:set_string("infotext", label .. " " .. number .. ": fault")
|
||||||
@ -299,7 +294,10 @@ local function allow_metadata_inventory_take(pos, listname, index, stack, player
|
|||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
if listname == "cur" then
|
if listname == "cur" then
|
||||||
return 0
|
local meta = minetest.get_meta(pos)
|
||||||
|
if meta:get_int("running") > 0 then
|
||||||
|
return 0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
return stack:get_count()
|
return stack:get_count()
|
||||||
end
|
end
|
||||||
@ -366,7 +364,7 @@ local function on_timer(pos, elapsed)
|
|||||||
-- try to start freezing bucket or water from pipe
|
-- try to start freezing bucket or water from pipe
|
||||||
pipe = biogasmachines.is_pipe_with_water(pos, node)
|
pipe = biogasmachines.is_pipe_with_water(pos, node)
|
||||||
local output = { ItemStack("default:ice 1") }
|
local output = { ItemStack("default:ice 1") }
|
||||||
if not inv:is_empty("src") then
|
if not inv:is_empty("cur") or not inv:is_empty("src") then
|
||||||
-- source: water bucket
|
-- source: water bucket
|
||||||
source = SOURCE_BUCKET
|
source = SOURCE_BUCKET
|
||||||
pipe = false
|
pipe = false
|
||||||
@ -389,20 +387,22 @@ local function on_timer(pos, elapsed)
|
|||||||
-- something to do, wake up and re-entry
|
-- something to do, wake up and re-entry
|
||||||
return freezer_start(pos)
|
return freezer_start(pos)
|
||||||
end
|
end
|
||||||
-- check if there is space in output, if not - do nothing
|
if inv:is_empty("cur") then
|
||||||
for _, stack in ipairs(output) do
|
-- check if there is space in output, if not - do nothing
|
||||||
if not inv:room_for_item("dst", stack) then
|
for _, stack in ipairs(output) do
|
||||||
return true
|
if not inv:room_for_item("dst", stack) then
|
||||||
|
return true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
-- process another water unit
|
||||||
-- process another water unit
|
if source == SOURCE_BUCKET then
|
||||||
if source == SOURCE_BUCKET then
|
local inp = get_water_bucket(inv, "src")
|
||||||
local inp = get_water_bucket(inv, "src")
|
if inp:is_empty() then
|
||||||
if inp:is_empty() then
|
-- oops
|
||||||
-- oops
|
return freezer_fault(pos)
|
||||||
return freezer_fault(pos)
|
end
|
||||||
|
inv:add_item("cur", inp)
|
||||||
end
|
end
|
||||||
inv:add_item("cur", inp)
|
|
||||||
end
|
end
|
||||||
meta:set_int("source", source)
|
meta:set_int("source", source)
|
||||||
itemcnt = ICE_TIME_SEC
|
itemcnt = ICE_TIME_SEC
|
||||||
|
Loading…
x
Reference in New Issue
Block a user