summaryrefslogtreecommitdiff
path: root/autocrafter.lua
diff options
context:
space:
mode:
authorTim <t4im@users.noreply.github.com>2015-01-26 18:52:04 +0100
committerTim <t4im@users.noreply.github.com>2015-01-27 23:41:46 +0100
commitd3110a9e20b3889adc54cb2e0aedf45d71cdeae8 (patch)
tree8093888349a4728293efb1c0e7adc7bc5205dcaf /autocrafter.lua
parent7b9571912d53bd4741a2f0b03eda6241b0d3a9f7 (diff)
downloadpipeworks-d3110a9e20b3889adc54cb2e0aedf45d71cdeae8.tar
pipeworks-d3110a9e20b3889adc54cb2e0aedf45d71cdeae8.tar.gz
pipeworks-d3110a9e20b3889adc54cb2e0aedf45d71cdeae8.tar.bz2
pipeworks-d3110a9e20b3889adc54cb2e0aedf45d71cdeae8.tar.xz
pipeworks-d3110a9e20b3889adc54cb2e0aedf45d71cdeae8.zip
rename variables to reflect the official api and making the code more clear
Diffstat (limited to 'autocrafter.lua')
-rw-r--r--autocrafter.lua38
1 files changed, 19 insertions, 19 deletions
diff --git a/autocrafter.lua b/autocrafter.lua
index a981e7e..de8dbae 100644
--- a/autocrafter.lua
+++ b/autocrafter.lua
@@ -17,43 +17,43 @@ local function autocraft(inventory, pos)
if not inventory then return end
local recipe = inventory:get_list("recipe")
if not recipe then return end
- local recipe_last
- local result
- local new
+ local cached_recipe
+ local output
+ local decremented_input
local hash, craft = get_cached_craft(pos)
if craft == nil then
- recipe_last = {}
+ cached_recipe = {}
for i = 1, 9 do
- recipe_last[i] = recipe[i]
+ cached_recipe[i] = recipe[i]
recipe[i] = ItemStack({name = recipe[i]:get_name(), count = 1})
end
- result, new = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
- autocrafterCache[hash] = {["recipe"] = recipe, ["result"] = result, ["new"] = new}
+ output, decremented_input = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
+ autocrafterCache[hash] = {recipe = recipe, output = output, decremented_input = decremented_input}
else
- recipe_last, result, new = craft.recipe, craft.result, craft.new
+ cached_recipe, output, decremented_input = craft.recipe, craft.output, craft.decremented_input
local recipe_changed = false
for i = 1, 9 do
- local recipe_entry, recipe_last_entry = recipe[i], recipe_last[i]
- if recipe_entry:get_name() ~= recipe_last_entry:get_name()
- or recipe_entry:get_count() ~= recipe_last_entry:get_count() then
+ local recipe_entry, cached_recipe_entry = recipe[i], cached_recipe[i]
+ if recipe_entry:get_name() ~= cached_recipe_entry:get_name()
+ or recipe_entry:get_count() ~= cached_recipe_entry:get_count() then
recipe_changed = true
break
end
end
if recipe_changed then
for i = 1, 9 do
- recipe_last[i] = recipe[i]
+ cached_recipe[i] = recipe[i]
recipe[i] = ItemStack({name = recipe[i]:get_name(), count = 1})
end
- result, new = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
- autocrafterCache[hash] = {["recipe"] = recipe, ["result"] = result, ["new"] = new}
+ output, decremented_input = minetest.get_craft_result({method = "normal", width = 3, items = recipe})
+ autocrafterCache[hash] = {recipe = recipe, output = output, decremented_input = decremented_input}
end
end
- if result.item:is_empty() then return end
- result = result.item
- if not inventory:room_for_item("dst", result) then return end
+ if output.item:is_empty() then return end
+ output = output.item
+ if not inventory:room_for_item("dst", output) then return end
local to_use = {}
for _, item in ipairs(recipe) do
if item~= nil and not item:is_empty() then
@@ -74,9 +74,9 @@ local function autocraft(inventory, pos)
inventory:remove_item("src", ItemStack(itemname))
end
end
- inventory:add_item("dst", result)
+ inventory:add_item("dst", output)
for i = 1, 9 do
- inventory:add_item("dst", new.items[i])
+ inventory:add_item("dst", decremented_input.items[i])
end
end