Boolean modifier: Difference between revisions
Jump to navigation
Jump to search
imported>Bale mNo edit summary |
imported>Bale add useful example |
||
Line 29: | Line 29: | ||
code1={{CodeSample| | code1={{CodeSample| | ||
title=Simple | 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 accordian thief songs can you have active at one time.| | |||
code= | |||
<syntaxhighlight> | |||
boolean four_songs = boolean_modifier("four songs"); | |||
# Is there four song gear? | |||
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 +" in your head at a time."); | |||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
Revision as of 21:37, 26 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 accordian thief songs can you have active at one time.
boolean four_songs = boolean_modifier("four songs");
# Is there four song gear?
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 +" in your head at a time.");