From 08602acbda06166685cf0b5e3ea3067ddcfdbfab Mon Sep 17 00:00:00 2001 From: Alexander Weber Date: Thu, 22 Sep 2016 08:36:06 +0200 Subject: [PATCH] optimize update_needed. Propose nodes first lower and nearly to the chest --- towntest_chest/init.lua | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/towntest_chest/init.lua b/towntest_chest/init.lua index 03233cf..e737c99 100644 --- a/towntest_chest/init.lua +++ b/towntest_chest/init.lua @@ -197,17 +197,34 @@ towntest_chest.update_needed = function(inv,building) inv:set_stack("needed", i, nil) end local materials = {} + + -- sort by y to prefer lower nodes in building order. At the same level prefer nodes nearly the chest + table.sort(building,function(a,b) + if a and b then + return ((a.y