diff options
author | Tim <t4im@users.noreply.github.com> | 2015-01-27 05:27:36 +0100 |
---|---|---|
committer | Tim <t4im@users.noreply.github.com> | 2015-01-27 23:41:46 +0100 |
commit | f3b636d63e488ac409e2f0a895c5f00f7955cb44 (patch) | |
tree | 0d3ef50a2d2aa5d8e2cd84048d8ca7780a9b7320 | |
parent | 44bafb844ac2497cab683f8a27c9c673f3a0b437 (diff) | |
download | pipeworks-f3b636d63e488ac409e2f0a895c5f00f7955cb44.tar pipeworks-f3b636d63e488ac409e2f0a895c5f00f7955cb44.tar.gz pipeworks-f3b636d63e488ac409e2f0a895c5f00f7955cb44.tar.bz2 pipeworks-f3b636d63e488ac409e2f0a895c5f00f7955cb44.tar.xz pipeworks-f3b636d63e488ac409e2f0a895c5f00f7955cb44.zip |
let the autocrafter catch up on missed crafts
-rw-r--r-- | autocrafter.lua | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/autocrafter.lua b/autocrafter.lua index 4216517..d8cfc2d 100644 --- a/autocrafter.lua +++ b/autocrafter.lua @@ -1,5 +1,7 @@ local autocrafterCache = {} -- caches some recipe data to avoid to call the slow function minetest.get_craft_result() every second +local craft_time = 1 + local function count_index(invlist) local index = {} for _, stack in pairs(invlist) do @@ -57,14 +59,14 @@ local function on_recipe_change(pos, inventory) local timer = minetest.get_node_timer(pos) if not timer:is_started() then - timer:start(1) + timer:start(craft_time) end end local function on_inventory_change(pos, inventory) local timer = minetest.get_node_timer(pos) if not timer:is_started() then - timer:start(1) + timer:start(craft_time) end end @@ -101,7 +103,12 @@ local function run_autocrafter(pos, elapsed) local meta = minetest.get_meta(pos) local inventory = meta:get_inventory() local craft = get_craft(pos, inventory) - return autocraft(inventory, craft) + + for step = 1, math.floor(elapsed/craft_time) do + local continue = autocraft(inventory, craft) + if not continue then return false end + end + return true end local function update_autocrafter(pos) |