From 755e5ff6b4450f7fa696b1de6ab900b6305b2d0e Mon Sep 17 00:00:00 2001 From: Niklas Kapelle Date: Thu, 2 May 2024 15:02:51 +0200 Subject: [PATCH] added getSlotsByCount --- src/lib/turtle/InvState.hx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/turtle/InvState.hx b/src/lib/turtle/InvState.hx index 8beb6a1..94c3f12 100644 --- a/src/lib/turtle/InvState.hx +++ b/src/lib/turtle/InvState.hx @@ -96,4 +96,16 @@ abstract InvState(Map) { return null; } + + /** + Get all slots with items sorted from low to high. + **/ + public function getSlotsSortedByCount():Array { + var keys = [for (k in this.keys()) k]; + keys.sort((a, b) -> { + return this.get(a).count - this.get(b).count; + }); + + return keys; + } }