To int: Difference between revisions
Jump to navigation
Jump to search
imported>StDoodle mNo edit summary |
imported>Eliteofdelete Still only 5/9 functions shown |
||
(8 intermediate revisions by 4 users not shown) | |||
Line 5: | Line 5: | ||
FunctionPage| | FunctionPage| | ||
name={{#var:name}}| | name={{#var:name}}| | ||
function1={{Function| | function1={{Function| | ||
Line 12: | Line 11: | ||
return_type={{#var:return_type}}| | return_type={{#var:return_type}}| | ||
return_also={{#var:return_also}}| | return_also={{#var:return_also}}| | ||
parameter1= | parameter1={{Param|boolean|convert}}| | ||
p1desc={{Pspan| | }}| | ||
function2={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|float|convert}}| | |||
}}| | |||
function3={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|string|convert}}| | |||
}}| | |||
function4={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|item|convert}}| | |||
}}| | |||
function5={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|class|convert}}| | |||
p1desc={{Pspan|convert}} is the boolean, int, string, item, class, effect, familiar, skill, or thrall to convert| | |||
}}| | |||
function6={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|familiar|convert}}| | |||
}}| | |||
function7={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|effect|convert}}| | |||
}}| | |||
function8={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|skill|convert}}| | |||
}}| | |||
function9={{Function| | |||
name={{#var:name}}| | |||
aggregate={{#var:aggregate}}| | |||
return_type={{#var:return_type}}| | |||
return_also={{#var:return_also}}| | |||
parameter1={{Param|thrall|convert}}| | |||
}}| | }}| | ||
function_description=This function looks for the best integer match to the specified input, which varies by datatype. | function_description=This function looks for the best integer match to the specified input, which varies by datatype. | ||
* boolean values return 0 for false and 1 for true | * boolean values return 0 for false and 1 for true | ||
* float values return the same as they would with [[truncate|truncate()]] | * float values return the same as they would with [[truncate|truncate()]] | ||
Line 23: | Line 88: | ||
** fully numeric strings, optionally with + or - as the first character, return as they would for a float (commas are also ignored) | ** fully numeric strings, optionally with + or - as the first character, return as they would for a float (commas are also ignored) | ||
** all other strings return 0, with a message saying that the string is not a valid integer | ** all other strings return 0, with a message saying that the string is not a valid integer | ||
* special datatypes (class, | * special datatypes (class, skill, thrall etc.) return their ID number as referenced in KoL. | ||
| | Note: All the possible functions are not listed yet.| | ||
code1={{CodeSample| | |||
title=Code Samples| | |||
description=Following example shows basic to_int operations.|| | |||
code= | |||
<syntaxhighlight> | |||
boolean first, second; | |||
float third; | |||
string fourth; | |||
item fifth; | |||
class sixth; | |||
effect seventh; | |||
familiar eighth; | |||
skill ninth; | |||
thrall tenth; | |||
first = true; | |||
second = false; | |||
third = 3.141592; | |||
fourth = "933,029"; | |||
fifth = $item[mae west]; | |||
sixth = $class[disco bandit]; | |||
seventh = $effect[smooth movements]; | |||
eighth = $familiar[hobo monkey]; | |||
ninth = $skill[smooth movement]; | |||
tenth = $thrall[Penne Dreadful]; | |||
print(first+" gives "+to_int(first)+".", "blue"); | |||
print(second+" gives "+to_int(second)+".", "blue"); | |||
print(third+" gives "+to_int(third)+".", "blue"); | |||
print(fourth+" gives "+to_int(fourth)+".", "blue"); | |||
print(fifth+" gives "+to_int(fifth)+".", "blue"); | |||
print(sixth+" gives "+to_int(sixth)+".", "blue"); | |||
print(seventh+" gives "+to_int(seventh)+".", "blue"); | |||
print(eighth+" gives "+to_int(eighth)+".", "blue"); | |||
print(ninth+" gives "+to_int(ninth)+".", "blue"); | |||
print(tenth+" gives "+to_int(tenth)+".", "blue"); | |||
</syntaxhighlight>| | |||
moreinfo= | |||
It gives the following output. | |||
<pre> | |||
true gives 1. | |||
false gives 0. | |||
3.141592 gives 3. | |||
933,029 gives 933029. | |||
Mae West gives 1584. | |||
Disco Bandit gives 5. | |||
Smooth Movements gives 165. | |||
Hobo Monkey gives 89. | |||
Smooth Movement gives 5017. | |||
Penne Dreadful gives 5. | |||
</pre> | |||
}}| | |||
}} | }} | ||
[[Category:Datatype Conversions]] |
Latest revision as of 15:52, 26 January 2015
Function Syntax
- convert is the boolean, int, string, item, class, effect, familiar, skill, or thrall to convert
This function looks for the best integer match to the specified input, which varies by datatype.
- boolean values return 0 for false and 1 for true
- float values return the same as they would with truncate()
- string values are parsed in several ways:
- fully numeric strings, optionally with + or - as the first character, return as they would for a float (commas are also ignored)
- all other strings return 0, with a message saying that the string is not a valid integer
- special datatypes (class, skill, thrall etc.) return their ID number as referenced in KoL.
Note: All the possible functions are not listed yet.
Code Samples
Following example shows basic to_int operations.
boolean first, second;
float third;
string fourth;
item fifth;
class sixth;
effect seventh;
familiar eighth;
skill ninth;
thrall tenth;
first = true;
second = false;
third = 3.141592;
fourth = "933,029";
fifth = $item[mae west];
sixth = $class[disco bandit];
seventh = $effect[smooth movements];
eighth = $familiar[hobo monkey];
ninth = $skill[smooth movement];
tenth = $thrall[Penne Dreadful];
print(first+" gives "+to_int(first)+".", "blue");
print(second+" gives "+to_int(second)+".", "blue");
print(third+" gives "+to_int(third)+".", "blue");
print(fourth+" gives "+to_int(fourth)+".", "blue");
print(fifth+" gives "+to_int(fifth)+".", "blue");
print(sixth+" gives "+to_int(sixth)+".", "blue");
print(seventh+" gives "+to_int(seventh)+".", "blue");
print(eighth+" gives "+to_int(eighth)+".", "blue");
print(ninth+" gives "+to_int(ninth)+".", "blue");
print(tenth+" gives "+to_int(tenth)+".", "blue");
It gives the following output.
true gives 1. false gives 0. 3.141592 gives 3. 933,029 gives 933029. Mae West gives 1584. Disco Bandit gives 5. Smooth Movements gives 165. Hobo Monkey gives 89. Smooth Movement gives 5017. Penne Dreadful gives 5.