Difference between pages "Talk:ASH Errors" and "Sell"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>PhilmASTErpLus
 
imported>Gnocchi masala
m (Fix obsolete syntax)
 
Line 1: Line 1:
Is this like were things like <font color="#ff7000">Script parsing error (X.ash, line Y)</font> are listed?--[[User:Icon315|Icon315]] 22:33, 14 April 2010 (UTC)
+
{{
 +
#vardefine:name|sell}}{{
 +
#vardefine:return_type|boolean}}{{
  
:It's where they WILL be listed, once they are listed. --[[User:Bale|Bale]] 22:52, 14 April 2010 (UTC)
+
FunctionPage|
 +
name={{#var:name}}|
  
What Bale said. Also, I changed that to orange; I kept trying to click on it. :( --[[User:StDoodle|StDoodle (#1059825)]] 00:35, 15 April 2010 (UTC)
+
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|
 +
}}|
  
Also, if anyone's feeling particularly ambitious, https://kolmafia.svn.sourceforge.net/svnroot/kolmafia/src/net/sourceforge/kolmafia/textui/Parser.java should help. Just look for all the instances of parseException. (Speaking of which, would it be useful if these were presented in the order that they're checked?) --[[User:Heeheehee|Heeheehee]] 00:17, 17 April 2010 (UTC)
+
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.|
  
I think alphabetical order would be better: this page is going to be excellent for first-time ASH scripters to understand what's wrong with their script. --[[User:Slyz|Slyz]] 10:41, 17 April 2010 (UTC)
+
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>
 +
}}|
  
Should we add the correct examples? Or are the fixes clear enough?
+
see_also={{SeeAlso|buy|sell_price}}|
--[[User:Slyz|Slyz]] 08:36, 18 April 2010 (UTC)
+
}}
  
If anything particularly complicated shows, we can give both. But so far, if you can't follow as written, I'm not sure you ever will. (That's the hypothetical "you," not the specific "hey Slyz what's wrong with you, you"). --[[User:StDoodle|StDoodle (#1059825)]] 23:35, 19 April 2010 (UTC)
+
[[Category:Item Management]]
 
 
 
 
 
 
{{CodeSample|description=The following code results in an error.
 
|code=<syntaxhighlight>
 
void my_function( string myvar = "value" )
 
{
 
  /* Do something */
 
}
 
</syntaxhighlight>}}
 
Error message: <blockquote>Cannot initialize parameter myvar (filename.ash, line X)</blockquote>
 
I'd like to add this to the article myself, but I'm not sure how to explain its exact nature. Would this message appear only in a situation like the above code? --[[User:PhilmASTErpLus|PhilmASTErpLus]] 09:30, 28 July 2010 (UTC)
 

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);
}

See Also

buy() | sell_price()