Difference between revisions of "My adventures"

From Kolmafia
Jump to navigation Jump to search
imported>Efilnikufecin
imported>Zarqon
(added further examples and not logged in info)
Line 1: Line 1:
 
[[int]] [[my_adventures()]]
 
[[int]] [[my_adventures()]]
  
This function returns the logged-in character's current number of remaining adventures as an [[int]].  Use of this function is essential in any kind of goal-seeking loop, lest it run on forever trying to adventure with no way to do so. 
+
This function returns the logged-in character's amount of remaining adventures as an [[int]].  Common uses include 1) spending all of your adventures in one place:
 +
 
 +
<code>
 +
  adventure([[my_adventures()]],$[[location]][giant's castle]);
 +
</code>
 +
 
 +
2) Checking to see if you can adventure before doing something:
 +
 
 +
<code>
 +
  if ([[my_adventures()]] == 0) abort("You can't run this script without adventures.");
 +
</code>
 +
 
 +
And 3) making sure you have enough adventures to perform a set of actions:
  
 
An example:
 
An example:
Line 9: Line 21:
 
     adventure(3,$[[location]][Haunted Gallery]);
 
     adventure(3,$[[location]][Haunted Gallery]);
 
     adventure(1,$[[location]][Haunted Ballroom]);
 
     adventure(1,$[[location]][Haunted Ballroom]);
   }
+
   } else break;
 
  }</code>
 
  }</code>
 
[[Category:Your Character | My adventures()]]
 
[[Category:Your Character | My adventures()]]
 
[[Category:Ash Functions |My adventures()]]
 
[[Category:Ash Functions |My adventures()]]
 +
 +
When not logged in, this function returns 0.

Revision as of 04:56, 29 January 2009

int my_adventures()

This function returns the logged-in character's amount of remaining adventures as an int. Common uses include 1) spending all of your adventures in one place:

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

2) Checking to see if you can adventure before doing something:

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

And 3) making sure you have enough adventures to perform a set of actions:

An example:

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

When not logged in, this function returns 0.