Bug - Not A Bug item.seller should return a string that to_coinmaster can use.

Found in build 10806.
Previously this code used to work:
void tradeFur()
{
int q = 0;
item yf = $item[ yeti fur ];
foreach it in $items[ hippopotamus skin, penguin skin, yak skin ]
{
q = min( 10, item_amount( yf ) + closet_amount( yf ) + stash_amount( yf ) );
if ( q > 0 && item_amount( it ) < 10 )
{
coinmaster master = to_coinmaster(it.seller);
buy(master, q, it);
}
}
return;
}
It now fails with:
Function 'to_coinmaster( coinmaster )' undefined. This script may require a more recent version of KoLmafia and/or its supporting scripts. (dailyStuff.ash, line 663)
Is it to do with the change to Strict Strings? Changing line 663 to "coinmaster master = to_coinmaster( "L33t Tr4pz0r" );" makes it all work again.
Also the to_coinmaster entry in the Item Management page of the wiki has a signature of ( string, item ) rather than ( string ).
 

lostcalpolydude

Developer
Staff member
If you change
Code:
coinmaster master = to_coinmaster(it.seller);
to
Code:
coinmaster master = it.seller;
then it should work, since .seller must already be a coinmaster. On the other hand, you could probably remove that line completely and use
Code:
buy(it.seller, q, it);
in that case.
 

Veracity

Developer
Staff member
lost is correct. Your code was always wrong, but we used to be lenient and implicitly convert a coinmaster to a string so you could convert it back to a coinmaster. That was never necessary, and now it is simply incorrect.

lost told you what to do.
 
You are going to get this reported again because the example code from the to_coinmaster page in the wiki is:
foreach trash in $items[red class ring, blue class ring, white class ring, PADL Phone,
pink clay bead, purple clay bead, green clay bead, communications windchimes]
if(item_amount(trash) > 0)
sell(to_coinmaster(trash.buyer), item_amount(trash), trash);
Which is where I got my syntax from.
 
Last edited:

Theraze

Active member
That's because, originally, the .buyer proxy field was a string. It was changed to be a coinmaster later... so, why not fix the example code? :) It's a wiki... go for it!
 

lostcalpolydude

Developer
Staff member
Someone will have to come up with a code sample that actually has a use for to_coinmaster() to get that page properly updated.
 
No problem there I'll use the actual name as a string. About 75% of the coinmaster pages use the now deprecated use of to_coinmaster in their examples so they'll get changed to directly reference the proxy method.
 
Top