Difference between pages "Use" and "Boolean modifier"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Bale
m
 
imported>Bale
(I'm a typo disaster some days.)
 
Line 1: Line 1:
 
{{
 
{{
#vardefine:name|use}}{{
+
#vardefine:name|boolean_modifier}}{{
 
#vardefine:return_type|boolean}}{{
 
#vardefine:return_type|boolean}}{{
  
Line 11: Line 11:
 
return_type={{#var:return_type}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
parameter1={{Param|int|qty}}|
+
parameter1={{Param|string|str}}|
parameter2={{Param|item|it}}|
 
p1desc={{pspan|qty}} is the quantity to use|
 
p2desc={{pspan|it}} is the item to use|
 
 
}}|
 
}}|
  
function_description=Attempts to use {{pspan|qty}} amount of item {{pspan|it}}. Returns true if the item is used or false if it fails to do so. Note that food must be "used" via eat() & drinks via drink(); attempting to use this function will result in an error message and a return value of false. Using this function for equipment will function the same as equip() would without the optional slot parameter. If this function is called with a non-usable item, a message saying so will print to the CLI and the function will return true.|
+
function2={{Function|
 +
name={{#var:name}}|
 +
aggregate={{#var:aggregate}}|
 +
return_type=int|
 +
return_also={{#var:return_also}}|
 +
parameter1={{Param|item|it}}|
 +
parameter2={{Param|string|str}}|
 +
p1desc={{pspan|it}} is the (optional) item in question|
 +
p2desc={{pspan|str}} is the modifier name|
 +
}}|
 +
 
 +
function_description=Accesses fields of your current modifiers for all of your current equipment and effects. This is the same mechanism that lets mafia decide whether you can adventure underwater, or how many songs you can keep in your head. <br /><br />
 +
For a list of fields that this function takes, see [[Modifiers]].|
  
needscode=yes|
+
code1={{CodeSample|
 +
title=Simple Examples|
 +
description=Tells you if you can adventure underwater or not.|
 +
code=
 +
<syntaxhighlight>
 +
if(!(boolean_modifier("Adventure Underwater"))||!(boolean_modifier("Underwater Familiar"))) {
 +
  print("You can't adventure underwater.", "red");
 +
  print("Either you won't be able to breathe, or your familiar won't.","red");
 +
  exit;
 +
}
 +
print("You can adventure underwater.")
 +
</syntaxhighlight>}}
 +
{{CodeSample|
 +
description=Informs the player of how many accordion thief songs he can have active at one time.|
 +
code=
 +
<syntaxhighlight>
 +
boolean four_songs = boolean_modifier("four songs");
 +
  # plexiglass pendant and/or brimstone beret grant 4 songs total.
 +
boolean extra_song = boolean_modifier("additional song");
 +
  # La Hebilla del Cinturón de Lopez adds one song
 +
int max_songs = 3 + to_int(four_songs) + to_int(extra_song);
 +
print("You can currently hold "+ max_songs +" songs in your head at a time.");
 +
</syntaxhighlight>}}
  
see_also={{SeeAlso|drink|eat|equip}}|
+
{{SeeAlso|numeric_modifier}}|
cli_equiv=The CLI command "use" functions similarly.|
 
more_info=If {{pspan|qty}} is 0 or negative, no item will be used and the function will return true.|
 
 
}}
 
}}
  
[[Category:Item Management]]
+
[[Category:Modifier Functions]]

Revision as of 03:27, 27 May 2010

Function Syntax

boolean boolean_modifier(string str )

int boolean_modifier(item it ,string str )

  • it is the (optional) item in question
  • str is the modifier name

Accesses fields of your current modifiers for all of your current equipment and effects. This is the same mechanism that lets mafia decide whether you can adventure underwater, or how many songs you can keep in your head.

For a list of fields that this function takes, see Modifiers.

Simple Examples

Tells you if you can adventure underwater or not.

if(!(boolean_modifier("Adventure Underwater"))||!(boolean_modifier("Underwater Familiar"))) {
   print("You can't adventure underwater.", "red");
   print("Either you won't be able to breathe, or your familiar won't.","red");
   exit;
}
print("You can adventure underwater.")

Informs the player of how many accordion thief songs he can have active at one time.

boolean four_songs = boolean_modifier("four songs");
   # plexiglass pendant and/or brimstone beret grant 4 songs total.
boolean extra_song = boolean_modifier("additional song");
   # La Hebilla del Cinturón de Lopez adds one song
int max_songs = 3 + to_int(four_songs) + to_int(extra_song);
print("You can currently hold "+ max_songs +" songs in your head at a time.");


See Also

numeric_modifier()