aboutsummaryrefslogtreecommitdiff
path: root/circular_saw.lua
diff options
context:
space:
mode:
authorkilbith <jeanpatrick.guerrero@gmail.com>2015-06-06 11:38:26 +0200
committerkilbith <jeanpatrick.guerrero@gmail.com>2015-06-06 11:38:26 +0200
commit7bd98ac02c0dd848e07b4c2202d20c47dc45999b (patch)
treeab3115d60d62ed200deab2ea4092b94467d7d022 /circular_saw.lua
parent6491d0be42e0d98afb1734732c7e2bd101156a8f (diff)
downloadmoreblocks-7bd98ac02c0dd848e07b4c2202d20c47dc45999b.tar.gz
moreblocks-7bd98ac02c0dd848e07b4c2202d20c47dc45999b.tar.bz2
moreblocks-7bd98ac02c0dd848e07b4c2202d20c47dc45999b.zip
Speedup get_output_inv
Diffstat (limited to 'circular_saw.lua')
-rw-r--r--circular_saw.lua7
1 files changed, 5 insertions, 2 deletions
diff --git a/circular_saw.lua b/circular_saw.lua
index 1140920..eeb62b5 100644
--- a/circular_saw.lua
+++ b/circular_saw.lua
@@ -84,6 +84,8 @@ function circular_saw:get_output_inv(modname, material, amount, max)
if (not max or max < 1 or max > 99) then max = 99 end
local list = {}
+ local pos = #list
+
-- If there is nothing inside, display empty inventory:
if amount < 1 then
return list
@@ -91,8 +93,9 @@ function circular_saw:get_output_inv(modname, material, amount, max)
for i, t in ipairs(circular_saw.names) do
local cost = circular_saw.cost_in_microblocks[i]
- table.insert(list, modname .. ":" .. t[1] .. "_" .. material .. t[2]
- .. " " .. math.min(math.floor(amount/cost), max))
+ pos = pos + 1
+ list[pos] = modname .. ":" .. t[1] .. "_" .. material .. t[2]
+ .. " " .. math.min(math.floor(amount/cost), max)
end
return list
end