Difference between pages "To phylum" and "Take shop"
(Difference between pages)
Jump to navigation
Jump to search
imported>Eliteofdelete (Updated) |
imported>Eliteofdelete (Has formatting issues) |
||
Line 1: | Line 1: | ||
{{ | {{ | ||
− | #vardefine:name| | + | #vardefine:name|take_shop}}{{ |
− | #vardefine:return_type| | + | #vardefine:return_type|boolean}}{{ |
FunctionPage| | FunctionPage| | ||
Line 11: | Line 11: | ||
return_type={{#var:return_type}}| | return_type={{#var:return_type}}| | ||
return_also={{#var:return_also}}| | return_also={{#var:return_also}}| | ||
− | parameter1={{Param| | + | parameter1={{Param|item|it}}| |
− | |||
}}| | }}| | ||
− | + | function2={{Function| | |
+ | name={{#var:name}}| | ||
+ | aggregate={{#var:aggregate}}| | ||
+ | return_type={{#var:return_type}}| | ||
+ | return_also={{#var:return_also}}| | ||
+ | parameter1={{Param|int|qty}}| | ||
+ | parameter2={{Param|item|it}}| | ||
+ | |||
+ | p1desc={{pspan|qty}} an optional parameter for the quantity of items to take from your mall store (defaults to all if not provided)| | ||
+ | p2desc={{pspan|it}} is the item to take from your mall store| | ||
+ | }}| | ||
+ | |||
+ | 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.| | ||
code1={{CodeSample| | code1={{CodeSample| | ||
title=Code Samples| | title=Code Samples| | ||
− | description= | + | description=Empties your entire shop.| |
code= | code= | ||
<syntaxhighlight> | <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>| | ||
+ | }}| | ||
− | + | code2={{CodeSample| | |
− | + | description=<br>The following function will use your shop when acquiring an item however it will not purchase anything. | | |
− | + | code= | |
− | + | <syntaxhighlight> | |
− | print( | + | void get_it (item thing, int amount) { |
− | print( | + | int have = item_amount(thing); |
− | print( | + | int need = max(0, amount-have); |
+ | if (need == 0) { | ||
+ | print("You already have "+amount+" of "+thing+".", "green"); | ||
+ | return; | ||
+ | } | ||
+ | else if (shop_amount(thing) > 0) { | ||
+ | refresh_shop(); | ||
+ | int pull = min(shop_amount(thing), need); | ||
+ | print("Removing "+pull+" "+thing+" from your store.", "blue"); | ||
+ | take_shop(pull, thing); | ||
+ | need = max(0, amount - item_amount(thing)); | ||
+ | } | ||
+ | if (need == 0) | ||
+ | print("You now have "+amount+" "+thing+".", "green"); | ||
+ | else { | ||
+ | print("Need to buy "+amount+" "+thing+".", "blue"); | ||
+ | //cli_execute("find "+amount+" "+thing); | ||
+ | print("This example doesn't buy though!", "red"); | ||
+ | } | ||
+ | } | ||
+ | get_it($item[mae west], 5); | ||
</syntaxhighlight>| | </syntaxhighlight>| | ||
moreinfo= | moreinfo= | ||
− | + | Uncomment the third to last line if you want it to buy. | |
− | |||
− | |||
− | |||
− | |||
− | |||
}}| | }}| | ||
+ | see_also={{SeeAlso|have_shop|put_shop|shop_amount}}| | ||
+ | cli_equiv=The CLI command "shop take " works similarly.| | ||
}} | }} | ||
− | [[Category: | + | [[Category:Item Management]] |
Revision as of 22:54, 21 January 2015
Function Syntax
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");
The following function will use your shop when acquiring an item however it will not purchase anything.
void get_it (item thing, int amount) {
int have = item_amount(thing);
int need = max(0, amount-have);
if (need == 0) {
print("You already have "+amount+" of "+thing+".", "green");
return;
}
else if (shop_amount(thing) > 0) {
refresh_shop();
int pull = min(shop_amount(thing), need);
print("Removing "+pull+" "+thing+" from your store.", "blue");
take_shop(pull, thing);
need = max(0, amount - item_amount(thing));
}
if (need == 0)
print("You now have "+amount+" "+thing+".", "green");
else {
print("Need to buy "+amount+" "+thing+".", "blue");
//cli_execute("find "+amount+" "+thing);
print("This example doesn't buy though!", "red");
}
}
get_it($item[mae west], 5);
Uncomment the third to last line if you want it to buy.
CLI Equivalent
The CLI command "shop take " works similarly.