Skip to content

Commit

Permalink
Conserve left-over microblocks.
Browse files Browse the repository at this point in the history
Any left-over microblocks are destroyed if the input box is emptied or if anything is taken from the output while the input box is empty.

Closes #2
  • Loading branch information
fozolo committed Jan 6, 2018
1 parent f6e0db2 commit b5cd0dc
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions circular_saw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,14 @@ function circular_saw:update_inventory(pos, amount)
return
end

-- Determine the kind of stairs from either the normal block or micro block.
local stack = inv:get_stack("input", 1)
-- At least one "normal" block is necessary to see what kind of stairs are requested.
local node_name = ""
if stack:is_empty() then
-- Any microblocks not taken out yet are now lost.
-- (covers material loss in the machine)
self:reset(pos)
return

node_name = inv:get_stack("micro", 1):get_name():gsub(":micro_", ":") or ""
else
node_name = stack:get_name() or ""
end
local node_name = stack:get_name() or ""
local name_parts = circular_saw.known_nodes[node_name] or ""
local modname = name_parts[1] or ""
local material = name_parts[2] or ""
Expand Down

0 comments on commit b5cd0dc

Please sign in to comment.