Or if you want a list, like get_inventory() returns, looks like get_storage() exists from the code.
int item_count() {
item x = $item[knob goblin firecracker];
int counter = item_amount( x ) + closet_amount( x ) + storage_amount( x );
return counter;
}
Is it possible that mafia thinks you already emptied your hagnks this ascension? Then it wouldn't check storage during session refresh, and storage_amount(x) would == 0 for all x until you force the refresh somehow (does visiting hagnk's work?)
int item_count() {
item x = $item[knob goblin firecracker];
int counter = storage_amount( x );
return counter;
}
{
int[item] inventory = get_storage() ;
item it = $item[2-ball];
if ( inventory[it] > 1 )
print ("You have " + it, "green");
else print ("You don't have " + it);
}
{
int[item] inventory = get_storage() ;
item it = $item[2-ball];
if ( inventory[it] > 1 )
print ("You have " + it, "green");
else print ("You don't have " + it);
}
//have to split these up, or mafia will come up with error. This can be repeated as many times as needed/wanted.
{
int[item] inventory = get_storage() ;
item it = $item[3-ball];
if ( inventory[it] > 1 )
print ("You have " + it, "green");
else print ("You don't have " + it);
}
{
int[item] inventory = get_storage() ;
foreach it in $items[8-ball, 3-ball, 4-ball, talisman of baio]
if ( inventory[it] >= 1 )
print ("You have " + it, "green");
else print ("You don't have " + it, "red');
}
{
int[item] inventory = get_storage() ;
boolean firecracker = false;
item it = $item[knob goblin firecracker];
if ( inventory [it] >= 1)
{ firecracker = true; }
if (firecracker) {print ("You have " + it , "green");}
else {print ("You do not have" + it , "red");}
}
int item_count() {
item x = $item[knob goblin firecracker];
int counter = storage_amount( x );
return counter;
}
So get_storage()[it] returns the correct amount, but storage_amount(it) doesn't? Both work for me (in aftercore, but I haven't "pulled all").
...
Is that all? Are you not *calling* the function you defined? That would explain why nothing is returned ...Code:int item_count() { item x = $item[knob goblin firecracker]; int counter = storage_amount( x ); return counter; }
I'm not sure what you mean about "calling" the function...
int item_count() {
item x = $item[knob goblin firecracker];
int counter = storage_amount( x );
return counter;
}
get_storage()[it] returns a true or false.
Code:edit: or you could add a print(counter); line to your function, and it will print the value each time it is " called ".[/QUOTE] I'm even more confused than before. LOL I guess I should leave this stuff to the experts, and only dabble when I can figure it out! :p
I'm even more confused than before. LOL I guess I should leave this stuff to the experts, and only dabble when I can figure it out!![]()
int item_count() < function will return an integer, function is named 'item_count()'
{
item x = $item[knob goblin firecracker]; < 'x' is the item to count
int counter = storage_amount( x ); < 'counter' is the storage amount of ' x'
< 'counter' now has a value we can do something with
< AFTER 'counter' has a value, and BEFORE we exit the function we can print the value
print("You have "+counter+" of "+x+" in Hagnk's.");
return counter; < exit the function and 'return' to the place in the code that the function was called from
}
< somewhere later in the script,
item_count();
< the function has been called, the code it contains will run. The code contains a 'print()' line. The storage_amount and name of the item will be printed.
Maybe if you describe what you want your code to do, we can help guide you through it, and develop a script to do what you need.
{ int[item] inventory = get_storage() ;
foreach it in $items[8-ball, 3-ball, 4-ball, talisman of baio]
if ( inventory[it] >= 1 )
print ("You have " + it, "green");
else print ("You don't have " + it); }
void main()
{
int item_count(){
item x = $item[knob goblin firecracker];
int counter = storage_amount( x );
print("You have "+counter+" of "+x+" in Hagnk's.");
return counter;
}
item_count();
{
int item_count(){
item x = $item[8-ball];
int counter = storage_amount( x );
print("You have "+counter+" of "+x+" in Hagnk's.");
return counter;
}
item_count();
}}
{ int[item] inventory = get_storage() ;
foreach it in $items[8-ball, 3-ball, 4-ball, talisman of baio]
if ( inventory[it] >= 1 )
print ("You have " + it, "green");
else print ("You don't have " + it); }
int item_count(item it) {
int counter = storage_amount(it);
print("You have "+counter+" of "+it+" in Hagnk's.");
return counter;
}
int item_count(item it) {
int counter = storage_amount(it);
print("You have "+counter+" of "+it+" in Hagnk's.");
return counter;
}
void main() {
int xx = 0;
foreach it in $items[8-ball, 3-ball, 4-ball, talisman of baio] {
xx = xx + item_count(it);
}
print("You have a total of "+xx+"items!");
}
The code you have here:
PHP:{ int[item] inventory = get_storage() ; foreach it in $items[8-ball, 3-ball, 4-ball, talisman of baio] if ( inventory[it] >= 1 ) print ("You have " + it, "green"); else print ("You don't have " + it); }
int[item] inventory = get_storage() ;
...is most of the way there. get_storage() returns a map of ITEM_AMOUNT[item]. You have named that map 'inventory'.
< a foreach loop will go through each key in the map (in this case that map has [item] keys)
foreach i in inventory <i.e. each item in my map (in this case it's actually items in storage, not inventory)
foreach i in inventory
{
print(i + " " + inventory); <--- print the 'key' (an item 'i') and the value associated with that key (in this case the amount of i in storage ) in the form MAP_NAME[key] --- so --- ' inventory ' represents the storage amount for any particular item ' i ' )
}
The above should list everything in Hagnk's along with the amount Hagnk is holding for you.
Keep at it ! It all gels together in the end !
if ((it) > 0)
{
print ("You have " + it + " " + inventory[it], "green");
}
This s great! I didn't realize it would be that easy. Script works great so far!
Next issue:
Code:if ((it) > 0) { print ("You have " + it + " " + inventory[it], "green"); }
How can I make this work? IE If there is 0 in storage, it won't printout anything...
foreach i in inventory
{
print(i + " " + inventory[i]); <--- ' inventory[i] ' represents the storage amount for any particular item ' i '
}
foreach i in inventory
{
if ( inventory[i] > 0 ) <--- ' inventory[i] ' represents the storage amount for any particular item ' i '
{
print(i + " " + inventory[i]);
}
}
if ( available _amount(it) > 0 ) {} <---- Items that are ' available ' to you according to the game state and your autoSatisfy settings.
void main()
{
foreach it in $items[
8-ball,
3-ball,
2-ball,
anticheese,
talisman of baio]
{
if (available_amount(it) >= 1 || storage_amount(it) >=1 )
{
print ("You have " + available_amount(it) + " " +it+ " on hand, and " + storage_amount(it) + " in storage", "green"); }
} }