added stack overflow handling

This commit is contained in:
unknown 2015-08-02 09:34:59 -04:00
parent 307f571c7f
commit 6fd6a59abd
2 changed files with 13 additions and 2 deletions

@ -31,7 +31,12 @@ condenser = {
local timesOver = math.floor(emc / target_emc) local timesOver = math.floor(emc / target_emc)
emc = emc - timesOver * target_emc emc = emc - timesOver * target_emc
meta:set_int("emc", emc) meta:set_int("emc", emc)
inventory:add_item("from", {name=target.name, count = timesOver}) for i = 1, timesOver do
inventory:add_item("from", {name = target.name, count = 99})
end
if timesOver % 99 > 0 then
inventory:add_item("from", {name = target.name, count = timesOver % 99})
end
meta:set_string("formspec", condenser.get_formspec(emc, target_emc)) meta:set_string("formspec", condenser.get_formspec(emc, target_emc))
end, end,

@ -25,6 +25,7 @@ collector = {
end end
if emc_transferable_nodes_length == 0 then if emc_transferable_nodes_length == 0 then
local generate_amount = math.floor(emc / 10) local generate_amount = math.floor(emc / 10)
local timesOver = math.floor(generate_amount / 99)
local inventory = meta:get_inventory() local inventory = meta:get_inventory()
local size = inventory:get_size("container") local size = inventory:get_size("container")
if emc >= 10 then if emc >= 10 then
@ -42,7 +43,12 @@ collector = {
"label[4,0;EMC Stored: "..emc - 10*generate_amount.."]".. "label[4,0;EMC Stored: "..emc - 10*generate_amount.."]"..
"list[current_name;container;0,0.5;8,7;]") "list[current_name;container;0,0.5;8,7;]")
end end
inventory:add_item("container",modname.."klein_star "..generate_amount) for i = 1, timesOver do
inventory:add_item("container", {name = modname.."klein_star", count = 99})
end
if timesOver % 99 > 0 then
inventory:add_item("container", {name = modname.."klein_star", count = timesOver % 99})
end
end end
end end
local newemc = (collector.emc_gather(emc, mark, multiplier)) local newemc = (collector.emc_gather(emc, mark, multiplier))