To element: Difference between revisions

From Kolmafia
Jump to navigation Jump to search
imported>StDoodle
mNo edit summary
imported>Eliteofdelete
No edit summary
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
FunctionPage|
FunctionPage|
name={{#var:name}}|
name={{#var:name}}|
function_category=Datatype Conversions|


function1={{Function|
function1={{Function|
Line 18: Line 17:
function_description=Returns the specified element {{pspan|name}} as an element.|
function_description=Returns the specified element {{pspan|name}} as an element.|


needscode=yes|
code1={{CodeSample|
title=Code Samples|
description=Following example shows basic to_element operations.||
code=
<syntaxhighlight>
foreach it in $strings[hot, colD, slime, SpookY, stench]
  print("The string -"+it+"- gives element: "+to_element(it), "blue");
</syntaxhighlight>|
moreinfo=
It gives the following output.
<pre>
The string -hot- gives element: hot
The string -colD- gives element: none
The string -slime- gives element: slime
The string -SpookY- gives element: none
The string -stench- gives element: stench
</pre>
}}|


special=Note that this function is case-sensitive, as with direct casting. Anything besides the following list will return $element[ none ], including strings with extra or missing characters: cold, hot, sleaze, spooky, stench, slime.|
special=Note that this function is case-sensitive, as with direct casting. Anything besides the following list will return $element[ none ], including strings with extra or missing characters: cold, hot, sleaze, spooky, stench, slime.|
}}
}}
[[Category:Datatype Conversions]]

Latest revision as of 14:44, 26 January 2015

Function Syntax

element to_element(string name )

  • name is the element name to convert

Returns the specified element name as an element.

Code Samples

Following example shows basic to_element operations.

foreach it in $strings[hot, colD, slime, SpookY, stench]
   print("The string -"+it+"- gives element: "+to_element(it), "blue");

It gives the following output.

The string -hot- gives element: hot
The string -colD- gives element: none
The string -slime- gives element: slime
The string -SpookY- gives element: none
The string -stench- gives element: stench

Special

Note that this function is case-sensitive, as with direct casting. Anything besides the following list will return $element[ none ], including strings with extra or missing characters: cold, hot, sleaze, spooky, stench, slime.