Difference between pages "Talk:ASH Errors" and "Sell"
(Difference between pages)
Jump to navigation
Jump to search
imported>PhilmASTErpLus |
imported>Gnocchi masala m (Fix obsolete syntax) |
||
Line 1: | Line 1: | ||
− | + | {{ | |
+ | #vardefine:name|sell}}{{ | ||
+ | #vardefine:return_type|boolean}}{{ | ||
− | : | + | FunctionPage| |
+ | name={{#var:name}}| | ||
− | + | function1={{Function| | |
+ | name={{#var:name}}| | ||
+ | aggregate={{#var:aggregate}}| | ||
+ | return_type=boolean| | ||
+ | return_also={{#var:return_also}}| | ||
+ | parameter1={{Param|coinmaster|master}}| | ||
+ | parameter2={{Param|int|qty}}| | ||
+ | parameter3={{Param|item|it}}| | ||
+ | p1desc={{pspan|master}} is the coinmaster to purchase from| | ||
+ | p2desc={{pspan|qty}} is the number to purchase| | ||
+ | p3desc={{pspan|it}} is the item to purchase| | ||
+ | }}| | ||
− | + | function_description=Attempts to purchase {{pspan|qty}} amount of item {{pspan|it}} from {{pspan|master}}. If {{pspan|qty}} is less than 1, the function will return true without purchasing anything. Otherwise it returns true if the purchase succeeded and false if it did not.| | |
− | + | code1={{CodeSample| | |
+ | title=Code Sample| | ||
+ | description=This expands upon selling to a coinmaster to show many related functions.| | ||
+ | code= | ||
+ | <syntaxhighlight> | ||
+ | boolean sell_coinmaster(int qty, item it) { | ||
+ | coinmaster master = it.buyer; | ||
+ | if(master == $coinmaster[none]) { | ||
+ | print("No coinmaster will purchase that", "red"); | ||
+ | return false; | ||
+ | } | ||
+ | if(!is_accessible(master)) { | ||
+ | print(inaccessible_reason(master), "red"); | ||
+ | return false; | ||
+ | } | ||
+ | int coins = master.available_tokens; | ||
+ | int price = sell_price(master, it); | ||
+ | print("Selling "+it+" to "+master+" for "+price+" "+coins+(qty > 1? " each.": ".")); | ||
+ | return sell(master, qty, it); | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | }}| | ||
− | + | see_also={{SeeAlso|buy|sell_price}}| | |
− | + | }} | |
− | + | [[Category:Item Management]] | |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Latest revision as of 05:54, 18 March 2012
Function Syntax
boolean sell(coinmaster master ,int qty ,item it )
- master is the coinmaster to purchase from
- qty is the number to purchase
- it is the item to purchase
Attempts to purchase qty amount of item it from master. If qty is less than 1, the function will return true without purchasing anything. Otherwise it returns true if the purchase succeeded and false if it did not.
Code Sample
This expands upon selling to a coinmaster to show many related functions.
boolean sell_coinmaster(int qty, item it) {
coinmaster master = it.buyer;
if(master == $coinmaster[none]) {
print("No coinmaster will purchase that", "red");
return false;
}
if(!is_accessible(master)) {
print(inaccessible_reason(master), "red");
return false;
}
int coins = master.available_tokens;
int price = sell_price(master, it);
print("Selling "+it+" to "+master+" for "+price+" "+coins+(qty > 1? " each.": "."));
return sell(master, qty, it);
}