Difference between revisions of "Get power"

From Kolmafia
Jump to navigation Jump to search
imported>Bale
m
imported>Eliteofdelete
 
Line 17: Line 17:
 
function_description=Returns the power of the item {{pspan|it}} or 0 if the item doesn't have a power|
 
function_description=Returns the power of the item {{pspan|it}} or 0 if the item doesn't have a power|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Code Samples|
 +
description=Lists out the current power of the gear you are wearing.|
 +
code=
 +
<syntaxhighlight>
 +
int total;
 +
item thing;
 +
foreach it in $slots[] {
 +
  thing = equipped_item(it);
 +
  if (thing != $item[none])
 +
      print("The "+thing+" worn in the "+it+" slot has a power rating of "+get_power(thing)+".", "blue");
 +
      total += get_power(thing);
 +
}
 +
print("The total power of your gear is "+total+".", "green");
 +
</syntaxhighlight>|
 +
 
 +
}}|
 
}}
 
}}
  
 
[[Category:Item Management]]
 
[[Category:Item Management]]

Latest revision as of 03:35, 14 January 2015

Function Syntax

int get_power(item it )

  • it is the item to check for.

Returns the power of the item it or 0 if the item doesn't have a power

Code Samples

Lists out the current power of the gear you are wearing.

int total;
item thing;
foreach it in $slots[] {
   thing = equipped_item(it);
   if (thing != $item[none])
      print("The "+thing+" worn in the "+it+" slot has a power rating of "+get_power(thing)+".", "blue");
      total += get_power(thing);
}
print("The total power of your gear is "+total+".", "green");