Difference between revisions of "My level"

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
m
imported>StDoodle
m
Line 1: Line 1:
{{DISPLAYTITLE:my_level()}}
+
{{#vardefine:name|my_level}}
{{function|
+
{{#vardefine:return_type|int}}
name=my_level|
+
 
returns=int|
+
{{FunctionPage|
}}
+
name={{#var:name}}|
 +
function_category=Your Character|
 +
 
 +
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 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:
+
function_description=Returns the current logged-in character's level.|
  
<code>
+
code1={{CodeSample|
  [[location]] select_farming_area() {
+
title=Code Sample|
    if ([[my_level()]] >= 10) {
+
description=The following sample will check to see if you can access the Bat Hole Entryway.|
      if ([[item_amount]]($[[item]][S.O.C.K.]) + [[item_amount]]($[[item]][intragalactic rowboat]) > 0) {
+
code=
        return $[[location]][Castle in the Clouds in the Sky];
+
<syntaxhighlight>
      } else {
+
if (my_level() >= 4) {
        return $[[location]][Penultimate Fantasy Airship];
+
  print("You can get to the Bat Hole Entryway (may need to visit Council first).");
      }
+
} else {
    } else if([[my_level()]] >= 8) {
+
  print("You aren't a high enough level to fight bats.");
    ...
+
}
</code>
+
</syntaxhighlight>}}|
[[Category:Your Character | My level()]]
 
  
When not logged in, this function returns 1.
+
special=When not logged in, this function returns 1.
 +
}}

Revision as of 18:59, 28 February 2010



Function Syntax

int my_level()

Returns the current logged-in character's level.

Code Sample

The following sample will check to see if you can access the Bat Hole Entryway.

if (my_level() >= 4) {
   print("You can get to the Bat Hole Entryway (may need to visit Council first).");
} else {
   print("You aren't a high enough level to fight bats.");
}

Special

When not logged in, this function returns 1.