Get storage

From Kolmafia
Revision as of 01:05, 7 November 2018 by imported>SBThief (Created page with "{{ #vardefine:name|get_storage}}{{ #vardefine:aggregate|yes}}{{ #vardefine:return_type|int [item]}}{{ FunctionPage| name={{#var:name}}| function1={{Function| name={{#var:nam...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Syntax

int [item] get_storage()

Returns a map where each key is an item stored in Hangk's, with the integer value its quantity.

Example

This example displays the five most powerful hats in Hangk's that you can equip and use.

code=

int i = 1;
item [int] hats;

batch_open();
// We're using a batch here to minimize server hits.
foreach it in get_storage() {
     if ( !can_equip(it) ) continue;
     if ( !is_unrestricted(it) ) continue;
     if ( to_slot(it) != $slot[hat] ) continue;
     hats[i] = it;
     i += 1;
}
batch_close();

sort hats by -get_power(value);

print("Hats in Hangk's:");
for j from 1 to 5 {
     print(hats[j] + " (" + get_power(hats[j]) + ").");
}

{{{code}}}