Bug - Fixed r15441 - available_amount($item[none]) returns non-zero value

Fluxxdog

Active member
Ran this script on 2 different characters:
Code:
print(available_amount( $item[none] ));
print(closet_amount( $item[none] ));
print(creatable_amount( $item[none] ));
print(display_amount( $item[none] ));
print(equipped_amount( $item[none] ));
print(item_amount( $item[none] ));
print(shop_amount( $item[none] ));
print(stash_amount( $item[none] ));
print(storage_amount( $item[none] ));
Received different results for both.
Code:
7
0
0
0
0
0
0
0
0
Code:
1
0
0
0
0
0
0
0
0
 

Bale

Minion
Verified. I can manipulate available amount of item none by emptying and filling my equipment slots. Pretty funny actually.
 

Fluxxdog

Active member
Way more than those numbers. The one with 7 is an Avatar of Boris. I tried it this morning (r15547) on him with a different loadout and got this:
Code:
> ash available_amount($item[none])

Returned: 3

> ash foreach s in $slots[] print(s+"=>"+equipped_item(s))

hat=>bounty-hunting helmet
weapon=>none
off-hand=>none
back=>makeshift cape
shirt=>BGE 'cuddly critter' shirt
pants=>bounty-hunting pants
acc1=>frosty halo
acc2=>astral mask
acc3=>Baron von Ratsworth's monocle
familiar=>none
crown-of-thrones=>none
sticker1=>none
sticker2=>none
sticker3=>none
card-sleeve=>none
folder1=>none
folder2=>none
folder3=>none
folder4=>none
folder5=>none
buddy-bjorn=>none
fakehand=>none
Returned: void
The 3 would link to the no weapon, offhand, and familiar gear. If so, the other slots aren't counted which might be a different issue in its own right. Not one I think that is worrisome anytime soon.
 

Veracity

Developer
Staff member
"available" equipment is in the hat through familiar slots.

The Crown of Thrones and Buddy Bjorn "slots" hold familiars, not items.
You cannot remove stickers or folders from their pseudo-slots.

Yes, I suppose that your chain of fake hands could count - but since the only purpose for those is to put them into such a chain, it seems pointless to count them as "available"; what are you going to do - drop the chain and then rebuild it?

Ditto for the card sleeve; do you want to remove the card into inventory and make it "available" so you can insert it back in?

In any case, you have confirmed my diagnosis.

I suppose the easiest "solution" is to simply return 0 for "none". Although, I do have to wonder how not doing so is affecting your life; how is your script failing because available_amount of "none" is greater than 0?
 

Fluxxdog

Active member
I do have to wonder how not doing so is affecting your life; how is your script failing because available_amount of "none" is greater than 0?
Code:
			if(available_amount(chug)!=0 && available_amount(wine)==0) continue;
Unbeknownst to me, available_amount() was not returning 0 for chug when chug=$item[none], which has to start that way as it is declared outside a loop. The expectation was available_amount($item[none]) would always return 0.

When I got to a scenario where every wine in a list was unavailable, it was supposed to go into purchasing. When the CLI started reporting [¶-1] has no matches, I remembered that meant it was trying to do something with $item[none]. An ASH debug showed me it was trying to drink $item[none] and that's what let me track it back to available_amount().
 

Veracity

Developer
Staff member
OK. So this was affecting you because your script was buggy.
Whatever. It is fixed.
 

Bale

Minion
Unbeknownst to me, available_amount() was not returning 0 for chug when chug=$item[none], which has to start that way as it is declared outside a loop.

That is not a requirement in ash. It is a programming choice.
 

heeheehee

Developer
Staff member
Certainly doesn't help when you simply declare
Code:
item chug;
foreach ...

The defensive programming approach would be to check that item_type(chug) == "booze" (since even chug.inebriety would have some false positives).
 

Fluxxdog

Active member
That's what was confusing. $anything[none] doesn't actually exist. If I tell mafia to equip($slot[weapon].$item[none]), it doesn't actually try equipping anything, right? It just unequips whatever was in that slot. There's no actual $familiar[none], $stat[none], and so on, they're just placeholders.

This leads me to a honest quest, Veracity: Was it actually a bug I reported? I mean, yeah, I get the issues with my line of code and I'm going to take steps to correct that, but that aside, was the available_amount() originally intentional?
Certainly doesn't help when you simply declare
Code:
item chug;
foreach ...

The defensive programming approach would be to check that item_type(chug) == "booze" (since even chug.inebriety would have some false positives).
I have that check. I actually check item_type and item.fullness, item.inebriety, and item.spleen. I don't want drunki-brears when my food part runs plus it's the old standby of "He did it once, what's to keep him from doing it again?"
 
Top