Boolean modifier: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>Heeheehee
m Removed some cruft by linking to the shiny new Modifiers page!
imported>Fredg1
mNo edit summary
 
(8 intermediate revisions by 4 users not shown)
Line 5: Line 5:
FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Modifier Functions|


function1={{Function|
function1={{Function|
Line 18: Line 17:
name={{#var:name}}|
name={{#var:name}}|
aggregate={{#var:aggregate}}|
aggregate={{#var:aggregate}}|
return_type=int|
return_type={{#var:return_type}}|
return_also={{#var:return_also}}|
return_also={{#var:return_also}}|
parameter1={{Param|item|it}}|
parameter1={{Param|item|it}}|
Line 27: Line 26:


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 />
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]].|
For a list of fields that this function takes, see [[Modifiers#Boolean_Modifiers|Modifiers]].|


code1={{CodeSample|
code1={{CodeSample|
title=Simple Example|
title=Simple Examples|
description=Tells you if you can adventure underwater or not.|
description=Tells you if you can adventure underwater or not.|
code=
code=
<syntaxhighlight>
<syntaxhighlight>
if(!(boolean_modifier("Adventure Underwater"))||!(boolean_modifier("Underwater Familiar"))) {
if(!(boolean_modifier("Adventure Underwater"))||!(boolean_modifier("Underwater Familiar"))) {
   print("You can't adventure underwater. Either you won't be able to breathe, or your familiar won't.","red");
   print("You can't adventure underwater.", "red");
  print("Either you won't be able to breathe, or your familiar won't.","red");
   exit;
   exit;
}
}
print("You can adventure underwater.")
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>}}
</syntaxhighlight>}}


{{SeeAlso|numeric_modifier}}|
{{SeeAlso|effect_modifier|numeric_modifier|string_modifier}}|
}}
}}
[[Category:Modifier Functions]]

Latest revision as of 21:20, 1 July 2020

Function Syntax

boolean boolean_modifier(string str )

boolean 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

effect_modifier() | numeric_modifier() | string_modifier()