added getSlotsByCount

This commit is contained in:
Niklas Kapelle 2024-05-02 15:02:51 +02:00
parent 9353ccba8a
commit 755e5ff6b4
Signed by: niklas
GPG Key ID: 4EB651B36D841D16

View File

@ -96,4 +96,16 @@ abstract InvState(Map<TurtleSlot, {count:Int, name:Item, max:Int}>) {
return null;
}
/**
Get all slots with items sorted from low to high.
**/
public function getSlotsSortedByCount():Array<TurtleSlot> {
var keys = [for (k in this.keys()) k];
keys.sort((a, b) -> {
return this.get(a).count - this.get(b).count;
});
return keys;
}
}