My adventures: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
imported>StDoodle
mNo edit summary
Line 1: Line 1:
{{DISPLAYTITLE:my_adventures()}}
{{#vardefine:name|my_adventures}}
{{function|
{{#vardefine:return_type|int}}
name=my_adventures|
 
returns=int|
{{FunctionPage|
}}
name={{#var:name}}|
function_category=CATEGORY|
 
function1={{Function|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
}}|


This function returns the logged-in character's amount of remaining adventures as an [[int]]. Common uses include:<br />
function_description=Returns the logged-in character's number of adventures remaining.|
1) spending all of your adventures in one place:
<code>
  [[adventure()|adventure]]([[my_adventures()]],$[[location]][giant's castle]);
</code>


2) Checking to see if you can adventure before doing something:
code1={{CodeSample|
<code>
title=Code Samples|
  if ([[my_adventures()]] == 0) [[abort()|abort]]("You can't run this script without adventures.");
description=Using this function to spend all of your adventures farming the Castle:|
</code>
code=
<syntaxhighlight>
adventure(my_adventures() , $location[giant's castle]);
</syntaxhighlight>}}|


And 3) making sure you have enough adventures to perform a set of actions:
code2={{CodeSample|
description=Checking to see if you have adventures left before doing something:|
code=
<syntaxhighlight>
if (my_adventures() == 0) abort("You can't run this script without adventures.");
</syntaxhighlight>}}|


<code>
code3={{CodeSample|
while ([[my_adventures()]] >= 4) {
description=Making sure you have enough adventures to perform a set of actions:|
   if ([[use()|use]](1,$[[item]][dance card])) {
code=
    [[adventure()|adventure]](3,$[[location]][Haunted Gallery]);
<syntaxhighlight>
    [[adventure()|adventure]](1,$[[location]][Haunted Ballroom]);
location farming_location = $location[giant's castle];
while (my_adventures() >= 4) {
   if (use(1 , $item[dance card])) {
      adventure(3 , farming_location);
      adventure(1 , $location[Haunted Ballroom]);
   } else break;
   } else break;
}</code>
}
[[Category:Your Character | My adventures()]]
</syntaxhighlight>}}|
[[Category:Ash Functions |My adventures()]]


When not logged in, this function returns 0.
see_also={{SeeAlso|adventure|use}}|
special=When not logged in, this function returns 0.
}}

Revision as of 19:25, 28 February 2010



Function Syntax

int my_adventures()

Returns the logged-in character's number of adventures remaining.

Code Samples

Using this function to spend all of your adventures farming the Castle:

adventure(my_adventures() , $location[giant's castle]);

Checking to see if you have adventures left before doing something:

if (my_adventures() == 0) abort("You can't run this script without adventures.");

Making sure you have enough adventures to perform a set of actions:

location farming_location = $location[giant's castle];
while (my_adventures() >= 4) {
   if (use(1 , $item[dance card])) {
      adventure(3 , farming_location);
      adventure(1 , $location[Haunted Ballroom]);
   } else break;
}

See Also

adventure() | use()

Special

When not logged in, this function returns 0.