Feature put_display returns TRUE even when asked to display an item that is not present.

fronobulax

Developer
Staff member
See attempt at discussion here.

Wiki documentation here.

put_display returns TRUE when asked to move something into the display case that is not present in inventory.

The preferred solution, IMO, would be for put_display to return TRUE if, and only if, the requested number of the requested items really were moved from inventory to the display case. An acceptable solution would be to update the wiki to indicate TRUE means the function calls succeeded and does not necessarily mean that the transfer was a success.

Similar behavior may exist with other put_ and various take_ functions.

This script (also attached)
Code:
boolean success;
item it = $item[Bricko egg];
int have = item_amount(it);
print("Have "+have+" of "+it+" in bag");
// Put something I don't have in the DC
success = put_display(1, it);
have = display_amount(it);
print("Success "+success+" and have "+have+" of "+it+" in DC");
generates this output:
Have 0 of BRICKO egg in bag
Updating display case...
Placing items in display case...
Success true and have 1 of BRICKO egg in DC
(Attached script does a little more but...)

Thanks.
 

Attachments

  • WTF.ash
    529 bytes · Views: 32

StDoodle

Minion
IIRC, the return value is based on whether mafia did everything possible or encountered problems along the way. IE if an unexpected page glitch prevented a move, it would return false; otherwise, if it did all that was currently possible (meaning nothing if you try to move something you don't have) it would return true.
 

fronobulax

Developer
Staff member
IIRC, the return value is based on whether mafia did everything possible or encountered problems along the way. IE if an unexpected page glitch prevented a move, it would return false; otherwise, if it did all that was currently possible (meaning nothing if you try to move something you don't have) it would return true.

I figured. If I am going to write code and actually check return values it is helpful to have the return value be more closely aligned with what I was trying to do. On a practical basis, my concern also goes away if the wiki is tweaked. The mafia generated messages
Updating display case...
Placing items in display case...
do suggest it thought something was currently possible.
 
Top