Bug take_storage always returns true contrary to documentation

katyarn

New member
Using this example ash return take_storage($item[hand turkey outline],100000); always returns true. Same with reversing the function arguments.

According to the wiki:
Attempts to move qty of it from Hagnk's Ancestral Storage to your main inventory. Returns true if the move succeeds and false if it does not.
Based on that this doesn't appear to be working properly.
Other take_* functions may behave the same way as this one, I'm not sure.
 

fronobulax

Developer
Staff member
After a minute or two of looking at the code, I'm thinking the wiki is wrong. It look like the code returns true if the command succeeds but in this case the command is the request to access the display case and not the actual transfer of the item.

I vaguely remember this being an issue in the distant past and the solution was to check to see if the desired item was in inventory after the transfer and not rely on the return value of the take function.

Feature requests to add or change were not implemented because there is a trivial solution already available and there was a hope that scripters would assemble libraries of functions and share rather than try and shovel everything into mafia.
 

katyarn

New member
In that case true should indicate a server reply? Is that true even if you don't own a displaycase, or if you don't have access to hangk's or closet?
 

fronobulax

Developer
Staff member
In that case true should indicate a server reply? Is that true even if you don't own a displaycase, or if you don't have access to hangk's or closet?

After a superficial inspection, it looks like false indicates that there was a problem but doesn't really attempt to specify the nature of the problem. The gCLI and/or the left panel of the main GUI display should (also) indicate that there was a problem and possibly provide a reason, but this doesn't really help a scripter.

It will be false if the request timed out, or if there was an internal error that created a malformed request or if the KOL html changed or if the response was unexpected. There may be other causes but this is a superficial examination :)

If it is true then the scripter doesn't know whether the operation actually succeeded or not, since there is no guarantee that it will check that the storage is available or that the item is available there in the desired quantity. If it is false there is really no action the scripter can take other than trying to abort and clean up

So my recommendation would be that a script just ignore the return value and instead check for the expected quantity of the item and do something reasonable if the quantity is not what was expected.
 
Top