Difference between revisions of "My level"

From Kolmafia
Jump to navigation Jump to search
imported>Efilnikufecin
imported>Zarqon
m (added not logged-in info)
Line 1: Line 1:
 
[[int]] [[my_level()]]
 
[[int]] [[my_level()]]
  
This function returns the logged-in character's current level as an [[int]], and is easily used as an initial test to avoid aborts and loops in scripts which attempt to burn adventures in specific areas due to the targeted area being unavailable.  An example:
+
This function returns the logged-in character's current level as an [[int]].  It is easily used as an initial test to avoid aborts and loops in scripts which attempt to burn adventures in specific areas due to the targeted area being unavailable.  For example:
  
 
<code>
 
<code>
 
  [[location]] select_farming_area() {
 
  [[location]] select_farming_area() {
   if([[my_level()]] >= 10) {
+
   if ([[my_level()]] >= 10) {
     if(item_amount($[[item]][S.O.C.K.]) + ...
+
     if (item_amount($[[item]][S.O.C.K.]) + item_amount($[[item]][intragalactic rowboat]) > 0) {
      item_amount($[[item]][intragalactic rowboat]) > 0) {
 
 
       return $[[location]][Castle in the Clouds in the Sky];
 
       return $[[location]][Castle in the Clouds in the Sky];
 
     } else {
 
     } else {
Line 17: Line 16:
 
[[Category:Your Character | My level()]]
 
[[Category:Your Character | My level()]]
 
[[Category:Ash Functions |My level()]]
 
[[Category:Ash Functions |My level()]]
 +
 +
When not logged in, this function returns 1.

Revision as of 04:48, 29 January 2009

int my_level()

This function returns the logged-in character's current level as an int. It is easily used as an initial test to avoid aborts and loops in scripts which attempt to burn adventures in specific areas due to the targeted area being unavailable. For example:

location select_farming_area() {
  if (my_level() >= 10) {
    if (item_amount($item[S.O.C.K.]) + item_amount($item[intragalactic rowboat]) > 0) {
      return $location[Castle in the Clouds in the Sky];
    } else {
      return $location[Penultimate Fantasy Airship];
    }
  } else if(my_level() >= 8) { 
     ...etc...

When not logged in, this function returns 1.