Take shop: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Gnocchi masala
m Veracity's revision 12905 implementing changed shop funcionality.
imported>Eliteofdelete
No edit summary
Line 28: Line 28:
function_description=This command will remove {{pspan|it}} from your mall store. The 1-parameter version will remove all of the item. If you want to remove less than the maximum amount, then you will need to use the 2-parameter version with the optional first parameter set to the count you wish to remove.|
function_description=This command will remove {{pspan|it}} from your mall store. The 1-parameter version will remove all of the item. If you want to remove less than the maximum amount, then you will need to use the 2-parameter version with the optional first parameter set to the count you wish to remove.|


needscode=yes|
code1={{CodeSample|
title=Code Samples|
description=Empties your entire shop.|
code=
<syntaxhighlight>
if (user_confirm("Do you want to empty your entire shop?")) {
  print("Emptying your store...", "blue");
  wait(5);
  int[item] shop = get_shop();
  int x = 0;
  batch_open();
  foreach it in shop {
      take_shop(shop[it], it);
      x+=1;
      if (x==75) {
        batch_close();
        x=0;
        batch_open();
      }
  }
  print("Your shop has been emptied!", "green"); 
}
else print("You decided to not empty your store.", "blue");
</syntaxhighlight>|
 
}}|


see_also={{SeeAlso|have_shop|put_shop|shop_amount}}|
see_also={{SeeAlso|have_shop|put_shop|shop_amount}}|

Revision as of 22:53, 21 January 2015

Function Syntax

boolean take_shop(item it )

boolean take_shop(int qty ,item it )

  • qty an optional parameter for the quantity of items to take from your mall store (defaults to all if not provided)
  • it is the item to take from your mall store

This command will remove it from your mall store. The 1-parameter version will remove all of the item. If you want to remove less than the maximum amount, then you will need to use the 2-parameter version with the optional first parameter set to the count you wish to remove.

Code Samples

Empties your entire shop.

if (user_confirm("Do you want to empty your entire shop?")) {
   print("Emptying your store...", "blue");
   wait(5);
   int[item] shop = get_shop();
   int x = 0;
   batch_open();
   foreach it in shop {
      take_shop(shop[it], it);
      x+=1;
      if (x==75) {
         batch_close();
         x=0;
         batch_open();
      }
   }
   print("Your shop has been emptied!", "green");   
}
else print("You decided to not empty your store.", "blue");

CLI Equivalent

The CLI command "shop take " works similarly.

See Also

have_shop() | put_shop() | shop_amount()