Difference between pages "Boolean modifier" and "Ceil"

From Kolmafia
(Difference between pages)
Jump to navigation Jump to search
imported>Bale
(I'm a typo disaster some days.)
 
imported>StDoodle
m
 
Line 1: Line 1:
 
{{
 
{{
#vardefine:name|boolean_modifier}}{{
+
#vardefine:name|ceil}}{{
#vardefine:return_type|boolean}}{{
+
#vardefine:return_type|int}}{{
  
 
FunctionPage|
 
FunctionPage|
 
name={{#var:name}}|
 
name={{#var:name}}|
 +
function_category=Item Management|
  
 
function1={{Function|
 
function1={{Function|
Line 11: Line 12:
 
return_type={{#var:return_type}}|
 
return_type={{#var:return_type}}|
 
return_also={{#var:return_also}}|
 
return_also={{#var:return_also}}|
parameter1={{Param|string|str}}|
+
parameter1={{Param|float|i}}|
 
}}|
 
}}|
  
function2={{Function|
+
function_description=This is the ceiling function, which returns the greatest integer less than or equal to i.|
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]].|
 
  
 
code1={{CodeSample|
 
code1={{CodeSample|
title=Simple Examples|
+
title=Code Sample|
description=Tells you if you can adventure underwater or not.|
+
description=Returns what type of slimes you can fight in the Slime Tube, based on current ML.|
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=
 
code=
 
<syntaxhighlight>
 
<syntaxhighlight>
boolean four_songs = boolean_modifier("four songs");
+
float ML_frac = max(0,ceil(monster_level_adjustment()/100));
  # plexiglass pendant and/or brimstone beret grant 4 songs total.
+
string slime="";
boolean extra_song = boolean_modifier("additional song");
+
if(ML_frac<=1) slime = "slime1";
  # La Hebilla del Cinturón de Lopez adds one song
+
else if(ML_frac<=3) slime = "slime2";
int max_songs = 3 + to_int(four_songs) + to_int(extra_song);
+
else if(ML_frac<=6) slime = "slime3";
print("You can currently hold "+ max_songs +" songs in your head at a time.");
+
else if(ML_frac<=10) slime = "slime4";
</syntaxhighlight>}}
+
else slime = "slime5";
 +
print("You will encounter "+slime+" in the Slime Tube.");
 +
</syntaxhighlight>}}|
  
{{SeeAlso|numeric_modifier}}|
+
see_also={{SeeAlso|floor}}|
 
}}
 
}}
 
[[Category:Modifier Functions]]
 

Revision as of 21:39, 8 March 2010

Function Syntax

int ceil(float i )

This is the ceiling function, which returns the greatest integer less than or equal to i.

Code Sample

Returns what type of slimes you can fight in the Slime Tube, based on current ML.

float ML_frac = max(0,ceil(monster_level_adjustment()/100));
string slime="";
if(ML_frac<=1) slime = "slime1";
else if(ML_frac<=3) slime = "slime2";
else if(ML_frac<=6) slime = "slime3";
else if(ML_frac<=10) slime = "slime4";
else slime = "slime5";
print("You will encounter "+slime+" in the Slime Tube.");

See Also

floor()