My level: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Metraxis
m More type links
imported>Bale
mNo edit summary
 
(10 intermediate revisions by 4 users not shown)
Line 1: Line 1:
[[int]] [[my_level()]]
{{
#vardefine:name|my_level}}{{
#vardefine:return_type|int}}{{


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 targetted area being unavailable.  An example:
FunctionPage|
name={{#var:name}}|


<code>
function1={{Function|
[[location]] select_farming_area() {
name={{#var:name}}|
  if([[my_level()]] >= 10) {
aggregate={{#var:aggregate}}|
    if(item_amount($[[item]][S.O.C.K.]) + ...
return_type={{#var:return_type}}|
      item_amount($[[item]][intragalactic rowboat]) > 0) {
return_also={{#var:return_also}}|
      return $[[location]][Castle in the Clouds in the Sky];
}}|
    } else {
 
      return $[[location]][Penultimate Fantasy Airship];
function_description=Returns the current logged-in character's level.|
    }
 
  } else if([[my_level()]] >= 8) {
code1={{CodeSample|
      ...etc...
title=Code Sample|
</code>
description=The following sample will check to see if you can access the Bat Hole Entryway.|
code=
<syntaxhighlight>
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.");
}
</syntaxhighlight>}}|
 
special=When not logged in, this function returns 1.
}}
 
[[Category:Your Character]]

Latest revision as of 21:32, 21 May 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.