<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.kolmafia.us/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fredg1</id>
	<title>Kolmafia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.kolmafia.us/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Fredg1"/>
	<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Special:Contributions/Fredg1"/>
	<updated>2026-04-24T21:14:06Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.44.0</generator>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=VS_Code_Setup&amp;diff=8846</id>
		<title>VS Code Setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=VS_Code_Setup&amp;diff=8846"/>
		<updated>2020-12-22T05:20:55Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: Windows-related schtuff, &amp;amp;&amp;amp; Tasks&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This guide assumes that you have a recent enough version of the Java JDK, ANT, and VS Code.  Completing [[Compiling from Source]] is a requirement for this guide, although experienced developers can skip to whatever step is appropriate.&lt;br /&gt;
&lt;br /&gt;
=== Build and Config Project Setup ===&lt;br /&gt;
# Open the KoLmafia directory in VS Code.&lt;br /&gt;
# Install the Java Extension Pack, Language Support for Java, Project Manager for Java, and Debugger for Java VS Code extensions.&lt;br /&gt;
# Install the following files in .vscode:&lt;br /&gt;
&lt;br /&gt;
===== launch.json: =====&lt;br /&gt;
 {&lt;br /&gt;
     &amp;quot;version&amp;quot;: &amp;quot;0.2.0&amp;quot;,&lt;br /&gt;
     &amp;quot;configurations&amp;quot;: [&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;type&amp;quot;: &amp;quot;java&amp;quot;,&lt;br /&gt;
             &amp;quot;name&amp;quot;: &amp;quot;Debug (Launch)-KoLmafia&amp;lt;kolmafia&amp;gt;&amp;quot;,&lt;br /&gt;
             &amp;quot;request&amp;quot;: &amp;quot;launch&amp;quot;,&lt;br /&gt;
             &amp;quot;mainClass&amp;quot;: &amp;quot;net.sourceforge.kolmafia.KoLmafia&amp;quot;,&lt;br /&gt;
             &amp;quot;projectName&amp;quot;: &amp;quot;kolmafia&amp;quot;,&lt;br /&gt;
             &amp;quot;windows&amp;quot;: {&lt;br /&gt;
                 &amp;quot;cwd&amp;quot;: &amp;quot;${workspaceFolder}/dist&amp;quot;,&lt;br /&gt;
                 &amp;quot;sourcePaths&amp;quot;: [&amp;quot;${workspaceFolder}&amp;quot;]&lt;br /&gt;
             },&lt;br /&gt;
             &amp;quot;args&amp;quot;: &amp;quot;--CLI&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
     ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
===== settings.json: =====&lt;br /&gt;
 {&lt;br /&gt;
     &amp;quot;files.exclude&amp;quot;: {&lt;br /&gt;
         &amp;quot;**/.classpath&amp;quot;: true,&lt;br /&gt;
         &amp;quot;**/.factorypath&amp;quot;: true,&lt;br /&gt;
         &amp;quot;**/.project&amp;quot;: true,&lt;br /&gt;
         &amp;quot;**/.settings&amp;quot;: true,&lt;br /&gt;
         &amp;quot;**/*.class&amp;quot;: true&lt;br /&gt;
     },&lt;br /&gt;
     &amp;quot;java.project.referencedLibraries&amp;quot;: [&lt;br /&gt;
         &amp;quot;lib/**/*.jar&amp;quot;,&lt;br /&gt;
         &amp;quot;src/**/*.jar&amp;quot;&lt;br /&gt;
     ]&lt;br /&gt;
 }&lt;br /&gt;
Test by pressing F5 to run KoLmafia.&lt;br /&gt;
=== Optional Steps ===&lt;br /&gt;
===== Style definitions =====&lt;br /&gt;
*For easier coding, download the [[:File:KoLMafia Style.xml|KoLMafia Style Definitions]] and figure out how to install them in VS Code.&lt;br /&gt;
&lt;br /&gt;
===== Making Tasks =====&lt;br /&gt;
*Tasks are individual commands that can be used at will. There are two general situations in which they currently come in handy.&lt;br /&gt;
*To use them, add the following file in .vscode:&lt;br /&gt;
&#039;&#039;&#039;tasks.json:&#039;&#039;&#039;&lt;br /&gt;
 {&lt;br /&gt;
     &amp;quot;version&amp;quot;: &amp;quot;2.0.0&amp;quot;,&lt;br /&gt;
     &amp;quot;problemMatcher&amp;quot;: &amp;quot;$eslint-compact&amp;quot;,&lt;br /&gt;
     &amp;quot;type&amp;quot;: &amp;quot;shell&amp;quot;,&lt;br /&gt;
     &amp;quot;tasks&amp;quot;: [&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;label&amp;quot;: &amp;quot;build .jar&amp;quot;,&lt;br /&gt;
             &amp;quot;command&amp;quot;: &amp;quot;ant.bat daily&amp;lt;nul&amp;quot;,&lt;br /&gt;
             &amp;quot;windows&amp;quot;: {&lt;br /&gt;
                 &amp;quot;command&amp;quot;: &amp;quot;&amp;amp; ((get-command $env:ANT_HOME/bin/ant.bat).Source) daily&amp;lt;nul -lib ${workspaceFolder} -buildfile ${workspaceFolder}/build.xml&amp;quot;&lt;br /&gt;
             },&lt;br /&gt;
             &amp;quot;group&amp;quot;: {&lt;br /&gt;
                 &amp;quot;kind&amp;quot;: &amp;quot;build&amp;quot;,&lt;br /&gt;
                 &amp;quot;isDefault&amp;quot;: true&lt;br /&gt;
             }&lt;br /&gt;
         },&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;label&amp;quot;: &amp;quot;reset constants for patchmaking&amp;quot;,&lt;br /&gt;
             &amp;quot;command&amp;quot;: &amp;quot;ant.bat unset.properties&amp;lt;nul&amp;quot;,&lt;br /&gt;
             &amp;quot;windows&amp;quot;: {&lt;br /&gt;
                 &amp;quot;command&amp;quot;: &amp;quot;&amp;amp; ((get-command $env:ANT_HOME/bin/ant.bat).Source) unset.properties&amp;lt;nul -lib ${workspaceFolder} -buildfile ${workspaceFolder}/build.xml&amp;quot;&lt;br /&gt;
             }&lt;br /&gt;
         },&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;label&amp;quot;: &amp;quot;ant.bat set.version&amp;quot;,&lt;br /&gt;
             &amp;quot;command&amp;quot;: &amp;quot;ant.bat set.version&amp;lt;nul&amp;quot;,&lt;br /&gt;
             &amp;quot;windows&amp;quot;: {&lt;br /&gt;
                 &amp;quot;command&amp;quot;: &amp;quot;&amp;amp; ((get-command $env:ANT_HOME/bin/ant.bat).Source) set.version&amp;lt;nul -lib ${workspaceFolder} -buildfile ${workspaceFolder}/build.xml&amp;quot;&lt;br /&gt;
             }&lt;br /&gt;
         },&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;label&amp;quot;: &amp;quot;ant.bat set.released.false&amp;quot;,&lt;br /&gt;
             &amp;quot;command&amp;quot;: &amp;quot;ant.bat set.released.false&amp;lt;nul&amp;quot;,&lt;br /&gt;
             &amp;quot;windows&amp;quot;: {&lt;br /&gt;
                 &amp;quot;command&amp;quot;: &amp;quot;&amp;amp; ((get-command $env:ANT_HOME/bin/ant.bat).Source) set.released.false&amp;lt;nul -lib ${workspaceFolder} -buildfile ${workspaceFolder}/build.xml&amp;quot;&lt;br /&gt;
             }&lt;br /&gt;
         },&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;label&amp;quot;: &amp;quot;set constants for code running&amp;quot;,&lt;br /&gt;
             &amp;quot;dependsOrder&amp;quot;: &amp;quot;sequence&amp;quot;,&lt;br /&gt;
             &amp;quot;dependsOn&amp;quot;: [&lt;br /&gt;
                 &amp;quot;reset constants for patchmaking&amp;quot;,&lt;br /&gt;
                 &amp;quot;ant.bat set.version&amp;quot;,&lt;br /&gt;
                 &amp;quot;ant.bat set.released.false&amp;quot;&lt;br /&gt;
             ]&lt;br /&gt;
         }&lt;br /&gt;
     ]&lt;br /&gt;
 }&lt;br /&gt;
&lt;br /&gt;
*Here are the two uses for them:&lt;br /&gt;
====== Automate version-setting when debugging ======&lt;br /&gt;
*In its current state, if you were to start debugging, it would work. However, KoLmafia would think that your revision is 0. This would cause any script beginning with a &#039;&#039;since&#039;&#039; statement to abort immediately.&lt;br /&gt;
*To counter this without having to manually change KoLConstants.java, add these two lines to &amp;lt;code&amp;gt;launch.json&amp;lt;/code&amp;gt;:&lt;br /&gt;
 {&lt;br /&gt;
     &amp;quot;version&amp;quot;: &amp;quot;0.2.0&amp;quot;,&lt;br /&gt;
     &amp;quot;configurations&amp;quot;: [&lt;br /&gt;
         {&lt;br /&gt;
             &amp;quot;type&amp;quot;: &amp;quot;java&amp;quot;,&lt;br /&gt;
             &amp;quot;name&amp;quot;: &amp;quot;Debug (Launch)-KoLmafia&amp;lt;kolmafia&amp;gt;&amp;quot;,&lt;br /&gt;
             &amp;quot;request&amp;quot;: &amp;quot;launch&amp;quot;,&lt;br /&gt;
             &amp;quot;mainClass&amp;quot;: &amp;quot;net.sourceforge.kolmafia.KoLmafia&amp;quot;,&lt;br /&gt;
             &amp;quot;projectName&amp;quot;: &amp;quot;kolmafia&amp;quot;,&lt;br /&gt;
             &amp;quot;windows&amp;quot;: {&lt;br /&gt;
                 &amp;quot;cwd&amp;quot;: &amp;quot;${workspaceFolder}/dist&amp;quot;,&lt;br /&gt;
                 &amp;quot;sourcePaths&amp;quot;: [&amp;quot;${workspaceFolder}&amp;quot;]&lt;br /&gt;
             },&lt;br /&gt;
             &amp;lt;u&amp;gt;&#039;&#039;&#039;&amp;quot;preLaunchTask&amp;quot;: &amp;quot;set constants for code running&amp;quot;,&#039;&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
             &amp;lt;u&amp;gt;&#039;&#039;&#039;&amp;quot;postDebugTask&amp;quot;: &amp;quot;reset constants for patchmaking&amp;quot;,&#039;&#039;&#039;&amp;lt;/u&amp;gt;&lt;br /&gt;
             &amp;quot;args&amp;quot;: &amp;quot;--CLI&amp;quot;&lt;br /&gt;
         }&lt;br /&gt;
     ]&lt;br /&gt;
 }&lt;br /&gt;
====== Building the .jar ======&lt;br /&gt;
&lt;br /&gt;
* If you are not on Windows and already made your own Wrapper file, this is most likely not that much of an improvement, but these tasks allow you to build the .jar file in only two clicks (if you ever need to).&lt;br /&gt;
&lt;br /&gt;
[[File:Build Task.png|alt=Terminal =&amp;gt; Run Build Task...|left|frameless]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=File:Build_Task.png&amp;diff=8845</id>
		<title>File:Build Task.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=File:Build_Task.png&amp;diff=8845"/>
		<updated>2020-12-22T05:17:23Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Terminal =&amp;gt; Run Build Task...&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=File:Save_Workspace.png&amp;diff=8844</id>
		<title>File:Save Workspace.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=File:Save_Workspace.png&amp;diff=8844"/>
		<updated>2020-12-21T23:54:22Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;You may make it anywhere you want with any name you want, but you may NOT move it once created.&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=File:Open_folder_in_VScode.png&amp;diff=8843</id>
		<title>File:Open folder in VScode.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=File:Open_folder_in_VScode.png&amp;diff=8843"/>
		<updated>2020-12-21T23:15:15Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Select &amp;quot;New Window&amp;quot; first if you were using the current one previously.&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Data_Types&amp;diff=6827</id>
		<title>Data Types</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Data_Types&amp;diff=6827"/>
		<updated>2020-11-05T00:07:53Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: mutability&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Primitive Datatypes==&lt;br /&gt;
&lt;br /&gt;
===void===&lt;br /&gt;
Can be thought of better as the absence of a datatype. No value can be assigned to &#039;&#039;&#039;void&#039;&#039;&#039; nor can a value be returned from a function of datatype &#039;&#039;&#039;void&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===boolean===&lt;br /&gt;
A boolean value is either &#039;&#039;&#039;true&#039;&#039;&#039; or &#039;&#039;&#039;false&#039;&#039;&#039;. By default, a boolean variable is set to false.&lt;br /&gt;
&lt;br /&gt;
===int===&lt;br /&gt;
&lt;br /&gt;
A whole number (short for &amp;quot;integer&amp;quot;), either positive or negative (or 0).  The int used by KoLmafia is a 32-bit signed int, meaning it has a maximum value of 2,147,483,647 and a minimum value of -2,147,483,648. The default value of a integer variable is 0.&lt;br /&gt;
&lt;br /&gt;
Be careful when doing math with integers! As with some other strongly-typed languages, numbers are converted to integers at every step of the operation when only integer types are used. For example:&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int a = 1;&lt;br /&gt;
int b = 2;&lt;br /&gt;
print( a / b * 2 );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Will give the output &amp;quot;0,&amp;quot; not &amp;quot;1&amp;quot; as you may expect. Changing either variable to a float type will &amp;quot;correct&amp;quot; this.&lt;br /&gt;
&lt;br /&gt;
===float===&lt;br /&gt;
&lt;br /&gt;
The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in [http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 section 4.2.3 of the Java Language Specification], and a tool to help understand / quickly see how/where imprecisions happen can be found [https://www.h-schmidt.net/FloatConverter/IEEE754.html here].&lt;br /&gt;
&lt;br /&gt;
When assigning to a variable of type float, one should be careful to always enter numbers in decimal form, as unwanted behavior can result from supplying a value that KoLmafia may interpret as an int type without the decimal point.&lt;br /&gt;
&lt;br /&gt;
Note that float is not infinitely precise; it intrinsically rounds off after a certain point. This loss of accuracy is for the sake of storage, but beware of the possibility of small errors compounding from multiple float types.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=For instance, try the following code as an example of how rather long post-decimal portions are handled:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float f;&lt;br /&gt;
f = 4.9999999;&lt;br /&gt;
print( f );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The default value of a &amp;lt;code&amp;gt;float&amp;lt;/code&amp;gt; variable is 0.0.&lt;br /&gt;
&lt;br /&gt;
===string===&lt;br /&gt;
&lt;br /&gt;
A group of characters including, but not limited to: lowercase letters, uppercase characters, numbers, and various control characters. When assigning a value to a string, enclose the desired value in either single quotes (&amp;lt;code&amp;gt;&#039;&amp;lt;/code&amp;gt;), double quotes (&amp;lt;code&amp;gt;&amp;quot;&amp;lt;/code&amp;gt;) or backticks (&amp;lt;code&amp;gt;`&amp;lt;/code&amp;gt;) (note you must use the same quote type on both ends of the string assignment). If you need to include the same character inside of the string itself, you will need to escape it first with a backslash.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample&lt;br /&gt;
|description=For example:&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;string s = &amp;quot;This is my \&amp;quot;friend\&amp;quot; Pete.&amp;quot;;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
|moreinfo=Will result in the following being stored to s:&amp;lt;pre&amp;gt;This is my &amp;quot;friend&amp;quot; Pete&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The default value of a string is an empty string, or literally &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
When using backticks, you can concatenate expressions into your string using curly braces.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample&lt;br /&gt;
|description=For example:&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;string s = `Hello {my_name()}, you have {$item[lime].item_amount()} lime(s)!`;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
===buffer===&lt;br /&gt;
&lt;br /&gt;
Similar to a string, but more efficient in certain operations, including concatenation and passing as function arguments. For the most part, you can interchange references to strings and buffers. However, you should test all such actions first, as a few functions require a specific datatype to be supplied as a parameter. (Most notably, those listed under [[String Handling Routines#Regular Expressions|Regular Expressions]].)&lt;br /&gt;
&lt;br /&gt;
==Special Datatypes==&lt;br /&gt;
&lt;br /&gt;
Several datatypes are included in KoLmafia to represent common categories within the KoL universe.&lt;br /&gt;
&lt;br /&gt;
Note that while variables of these types are declared in the same way as for Primitive Datatypes; assigning and referencing them is done differently.&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=For example, to declare an item datatype and assign it a value, you would use the following line of code:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item it = $item[ broken skull ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The default values of any variable of one of the following types is &amp;lt;code&amp;gt;$&#039;&#039;type&#039;&#039;[ none ]&amp;lt;/code&amp;gt;. For example, the default value of a &amp;lt;code&amp;gt;item&amp;lt;/code&amp;gt; variable is &amp;lt;code&amp;gt;$item[ none ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===bounty===&lt;br /&gt;
&lt;br /&gt;
([[Bounty#Related Functions|Related Functions]])  ([[Bounty#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
These are the non-items that the bounty hunter asks you to retrieve from monsters around the kingdom. There are quite a lot of them (42 in total) so I won&#039;t list them all here. You can find more about bounties at the {{kolwiki|The Bounty Hunter Hunter&#039;s Shack}}.&lt;br /&gt;
&lt;br /&gt;
===class===&lt;br /&gt;
&lt;br /&gt;
([[Class#Related Functions|Related Functions]])  ([[Class#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Besides $class[ none ], there are six possible values for this datatype:&lt;br /&gt;
&lt;br /&gt;
* Seal Clubber&lt;br /&gt;
* Turtle Tamer&lt;br /&gt;
* Pastamancer&lt;br /&gt;
* Sauceror&lt;br /&gt;
* Disco Bandit&lt;br /&gt;
* Accordion Thief&lt;br /&gt;
&lt;br /&gt;
===coinmaster===&lt;br /&gt;
&lt;br /&gt;
([[Coinmaster#Related Functions|Related Functions]])  ([[Coinmaster#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
All shops that deal with currency other than meat. Known values include:&lt;br /&gt;
&lt;br /&gt;
* {{kolwiki|The Bounty Hunter Hunter&#039;s Shack|Bounty Hunter Hunter}}&lt;br /&gt;
* {{kolwiki|Mr. Store}}&lt;br /&gt;
* {{kolwiki|Hermit}}&lt;br /&gt;
* {{kolwiki|The Shore, Inc. Gift Shop}}&lt;br /&gt;
* {{kolwiki|The Trapper&#039;s Cabin|The Trapper}}&lt;br /&gt;
* {{kolwiki|A Vending Machine|Vending Machine}}&lt;br /&gt;
* {{kolwiki|The Swagger Shop}}&lt;br /&gt;
* {{kolwiki|The Hippy Camp (Wartime)|Dimemaster}}&lt;br /&gt;
* {{kolwiki|The Orcish Frat House|Quartersmaster}}&lt;br /&gt;
* {{kolwiki|BURT|Bugbear Token}}&lt;br /&gt;
* {{kolwiki|Freshwater Fishbonery}}&lt;br /&gt;
* {{kolwiki|Big Brother}}&lt;br /&gt;
* {{kolwiki|The Terrified Eagle Inn}}&lt;br /&gt;
* {{kolwiki|Ticket Redemption Counter|Arcade Ticket Counter}}&lt;br /&gt;
* {{kolwiki|Cashier|Game Shoppe}}&lt;br /&gt;
* {{kolwiki|Cashier|Game Shoppe Snacks}}&lt;br /&gt;
* {{kolwiki|The Isotope Smithery|Isotope Smithery}}&lt;br /&gt;
* {{kolwiki|Dollhawker&#039;s Emporium}}&lt;br /&gt;
* {{kolwiki|The Lunar Lunch-o-Mat|Lunar Lunch-o-Mat}}&lt;br /&gt;
* {{kolwiki|Paul&#039;s Boutique}}&lt;br /&gt;
* {{kolwiki|The Frozen Brogurt Stand}}&lt;br /&gt;
* {{kolwiki|Buff Jimmy&#039;s Souvenir Shop}}&lt;br /&gt;
* {{kolwiki|Taco Dan&#039;s Taco Stand}}&lt;br /&gt;
* {{kolwiki|You&#039;re the Fudge Wizard Now, Dog|Fudge Wand}}&lt;br /&gt;
* {{kolwiki|The Neandermall}}&lt;br /&gt;
* {{kolwiki|Legitimate Shoe Repair, Inc.}}&lt;br /&gt;
* {{kolwiki|warbear black box|Warbear Black Box}}&lt;br /&gt;
* {{kolwiki|The Dinsey Company Store}}&lt;br /&gt;
* {{kolwiki|Internet Meme Shop}}&lt;br /&gt;
&lt;br /&gt;
===effect===&lt;br /&gt;
&lt;br /&gt;
([[Effect#Related Functions|Related Functions]])  ([[Effect#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any effect you can be under in KoL, whether from items, skills, or what-have-you, is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $effect[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Effects}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===element===&lt;br /&gt;
&lt;br /&gt;
([[Element#Related Functions|Related Functions]])  ([[Element#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Besides $element[ none ], there are seven possible values for this datatype. (Note that &amp;quot;Bad Spelling&amp;quot; is not considered a true element.)&lt;br /&gt;
Also note that these names are case-sensitive (referencing $element[ Spooky ] will generate an error).&lt;br /&gt;
&lt;br /&gt;
* cold&lt;br /&gt;
* hot&lt;br /&gt;
* sleaze&lt;br /&gt;
* spooky&lt;br /&gt;
* stench&lt;br /&gt;
* slime&lt;br /&gt;
* supercold&lt;br /&gt;
&lt;br /&gt;
===familiar===&lt;br /&gt;
&lt;br /&gt;
([[Familiar#Related Functions|Related Functions]])  ([[Familiar#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any familiar available in KoL is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $familiar[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Familiars}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===item===&lt;br /&gt;
&lt;br /&gt;
([[Item#Related Functions|Related Functions]])  ([[Item#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any item in all of KoL is valid for this datatype. Note that unlike most special datatypes, item references can make use of the item ID number.&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=For example, you could assign the item plexiglass pants as follows:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item it = $item[ 1234 ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The full range, besides $item[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Items}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===location===&lt;br /&gt;
&lt;br /&gt;
([[Location#Related Functions|Related Functions]])  ([[Location#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any location one can adventure at in KoL is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $location[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Locations}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===monster===&lt;br /&gt;
&lt;br /&gt;
([[Monster#Related Functions|Related Functions]])  ([[Monster#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any monster you can encounter in KoL is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $monster[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Monster Compendium}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===phylum===&lt;br /&gt;
&lt;br /&gt;
([[Phylum#Related Functions|Related Functions]])  ([[Phylum#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Each monster has a {{kolwiki|Phylum}}. Besides $phylum[none], the possible values for this datatype are:&lt;br /&gt;
&lt;br /&gt;
* beast&lt;br /&gt;
* bug&lt;br /&gt;
* constellation&lt;br /&gt;
* construct&lt;br /&gt;
* demon&lt;br /&gt;
* dude&lt;br /&gt;
* elemental&lt;br /&gt;
* elf&lt;br /&gt;
* fish&lt;br /&gt;
* goblin&lt;br /&gt;
* hippy&lt;br /&gt;
* hobo&lt;br /&gt;
* humanoid&lt;br /&gt;
* horror&lt;br /&gt;
* mer-kin&lt;br /&gt;
* orc&lt;br /&gt;
* penguin&lt;br /&gt;
* pirate&lt;br /&gt;
* plant&lt;br /&gt;
* slime&lt;br /&gt;
* undead&lt;br /&gt;
* weird&lt;br /&gt;
&lt;br /&gt;
===servant===&lt;br /&gt;
&lt;br /&gt;
([[Servant#Related Functions|Related Functions]])  ([[Servant#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Servants are unique to the {{kolwiki|Actually Ed the Undying}} path and located {{kolwiki|The Servants&#039; Quarters}}, replacing familiars.&lt;br /&gt;
&lt;br /&gt;
* Assassin&lt;br /&gt;
* Belly-Dancer&lt;br /&gt;
* Bodyguard&lt;br /&gt;
* Cat&lt;br /&gt;
* Maid&lt;br /&gt;
* Priest&lt;br /&gt;
* Scribe&lt;br /&gt;
&lt;br /&gt;
===skill===&lt;br /&gt;
&lt;br /&gt;
([[Skill#Related Functions|Related Functions]])  ([[Skill#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any skill you can have in KoL, whether permable or not, granted by items, &#039;&#039;etc&#039;&#039;., is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $skill[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Skills}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===slot===&lt;br /&gt;
&lt;br /&gt;
([[Slot#Related Functions|Related Functions]])  (slot has no proxy record fields)&lt;br /&gt;
&lt;br /&gt;
Besides $slot[ none ], there are 16 possible values for this datatype.&lt;br /&gt;
&lt;br /&gt;
* hat&lt;br /&gt;
* back&lt;br /&gt;
* weapon&lt;br /&gt;
* off-hand&lt;br /&gt;
* shirt&lt;br /&gt;
* pants&lt;br /&gt;
* acc1&lt;br /&gt;
* acc2&lt;br /&gt;
* acc3&lt;br /&gt;
* familiar&lt;br /&gt;
* sticker1&lt;br /&gt;
* sticker2&lt;br /&gt;
* sticker3&lt;br /&gt;
* fakehand&lt;br /&gt;
* bootspur&lt;br /&gt;
* bootskin&lt;br /&gt;
&lt;br /&gt;
===stat===&lt;br /&gt;
&lt;br /&gt;
([[Stat#Related Functions|Related Functions]])  (stat has no proxy record fields)&lt;br /&gt;
&lt;br /&gt;
Besides $stat[ none ], there are six possible values for this datatype (the last three are for referencing sub-stats).&lt;br /&gt;
&lt;br /&gt;
* muscle&lt;br /&gt;
* mysticality&lt;br /&gt;
* moxie&lt;br /&gt;
* submuscle&lt;br /&gt;
* submysticality&lt;br /&gt;
* submoxie&lt;br /&gt;
&lt;br /&gt;
===thrall===&lt;br /&gt;
&lt;br /&gt;
([[Thrall#Related Functions|Related Functions]])  ([[Thrall#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Pastamancers have the ability to summon {{kolwiki|Pasta Thralls}}. &lt;br /&gt;
&lt;br /&gt;
* Angel Hair Wisp&lt;br /&gt;
* Elbow Macaroni&lt;br /&gt;
* Lasagmbie&lt;br /&gt;
* Penne Dreadful&lt;br /&gt;
* Spaghetti Elemental&lt;br /&gt;
* Spice Ghost&lt;br /&gt;
* Vampieroghi&lt;br /&gt;
* Vermincelli&lt;br /&gt;
&lt;br /&gt;
==aggregate==&lt;br /&gt;
&lt;br /&gt;
An aggregate is a complex datatype composed of two or more primitive or special datatypes. For more information, see [[Data Structures]].&lt;br /&gt;
&lt;br /&gt;
==record==&lt;br /&gt;
&lt;br /&gt;
Records are user-defined datatypes that hold as many sub-datatypes as desired. For more information, see the page for [[Data Structures]].&lt;br /&gt;
&lt;br /&gt;
==Plural Typed Constants==&lt;br /&gt;
&lt;br /&gt;
(see http://kolmafia.us/showthread.php?p=15592, from which this section is reproduced)&lt;br /&gt;
&lt;br /&gt;
Plural typed constants allow you to easily do something with a list of specified objects, without having to replicate code or laboriously build up an array of the objects so that you can iterate over it. Here&#039;s a quick example:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach weapon in $items[star sword, star staff, star crossbow] {&lt;br /&gt;
   if (available_amount(weapon) &amp;gt; 0) {&lt;br /&gt;
      equip(weapon);&lt;br /&gt;
      break;&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The syntax is basically the same as the existing typed constant feature, but with an &amp;quot;s&amp;quot; or &amp;quot;es&amp;quot; after the type name. (The &amp;quot;es&amp;quot; case is there so that you can properly pluralize &amp;quot;class&amp;quot;.) The text between the square brackets is interpreted as a comma-separated list of elements, each of which is converted to the specified type as if it were an individual constant. More details:&lt;br /&gt;
* The list can span multiple lines.&lt;br /&gt;
* Whitespace before or after elements is ignored.&lt;br /&gt;
* Completely empty elements are ignored (so that you can leave a comma at the end of the list).&lt;br /&gt;
* You can include a comma or closing square bracket in an element by writing it as &amp;quot;\,&amp;quot; or &amp;quot;\]&amp;quot;.&lt;br /&gt;
* All the other escape sequences allowed in strings are possible, such as &amp;quot;\n&amp;quot; (newline), &amp;quot;\t&amp;quot; (tab), and &amp;quot;\uXXXX&amp;quot; (Unicode character value). To put an actual backslash in an element, you have to write it as &amp;quot;\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The value generated by a plural constant is of type boolean[type], with the keys being the specified elements, and the boolean value always being true - although you won&#039;t normally do anything with the boolean, you&#039;d use a foreach loop to iterate over the keys. You can assign a plural constant to a variable declared as that type, but note that the value differs from a normal map in three important respects:&lt;br /&gt;
* Since the expression that generates it is syntactically a constant, the value has to be immutable. If you were allowed to change it in any way, those changes would appear in every future use of the same constant.&lt;br /&gt;
* There can be multiple instances of the same key - $ints[1,1,2,3,5,8] is perfectly valid, and will result in the value 1 appearing twice in a foreach loop.&lt;br /&gt;
* The keys will appear in the order you wrote them, rather than being sorted alphanumerically as maps usually do.&lt;br /&gt;
&lt;br /&gt;
In addition to being used in a foreach loop, plural constants also efficiently support membership testing via the &#039;contains&#039; operator. Here&#039;s another example:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
for hour from 1 to 12 {&lt;br /&gt;
   print(&amp;quot;It&#039;s &amp;quot; + hour + &amp;quot; o&#039;clock.&amp;quot;);&lt;br /&gt;
   if ($ints[10, 2, 4] contains hour) {&lt;br /&gt;
      print(&amp;quot;Time to drink a Dr Pepper!&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
(Yes, that example could just as easily have been done with a switch statement.)&lt;br /&gt;
&lt;br /&gt;
Iterating over an empty list is rather pointless, so plural constants with no elements are given a different meaning: they represent every value of the specified type, where this is practical. (The &#039;none&#039; value, if defined for a given type, is omitted.) The biggest benefit here is $items[], which lets you loop over every defined item, more efficiently than you could otherwise write in a script (since the list is generated once per session and then cached), and without having to hard-code a maximum item ID number in your script. Example:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach it in $items[] {&lt;br /&gt;
   if (autosell_price(it) == 42) print(it);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Enumeration of all possible values works with the following types:&lt;br /&gt;
* $booleans[] - false and true.&lt;br /&gt;
* $items[]&lt;br /&gt;
* $locations[]&lt;br /&gt;
* $classes[]&lt;br /&gt;
* $stats[] - Muscle, Mysticality, Moxie: the substat values are omitted.&lt;br /&gt;
* $skills[]&lt;br /&gt;
* $effects[]&lt;br /&gt;
* $familiars[]&lt;br /&gt;
* $slots[] - includes sticker slots and fake hands, which you might not want to consider as normal slots.&lt;br /&gt;
* $monsters[]&lt;br /&gt;
* $elements[] - includes slime now, and possibly other not-quite-elements like cute in the future.&lt;br /&gt;
&lt;br /&gt;
The remaining types that can be used in plural constants require an explicit list of elements, since there are too many possible values:&lt;br /&gt;
* $ints[] - you don&#039;t have enough RAM to store a list with 4 billion elements.&lt;br /&gt;
* $floats[] - ditto.&lt;br /&gt;
* $strings[] - nobody has that much RAM.&lt;br /&gt;
&lt;br /&gt;
==Custom==&lt;br /&gt;
&lt;br /&gt;
===matcher===&lt;br /&gt;
&lt;br /&gt;
A matcher isn&#039;t really a datatype so much as it&#039;s a class, but it is included here for reference, as it is used much as datatypes are in ASH. It can only be declared through the function {{f|create_matcher}}, using two strings. One is the string to find matches in, the other a regular expression to test against. For more information on using a matcher, see [[Regular Expressions]].&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
&lt;br /&gt;
Buffers, aggregates, records and matchers are [https://developer.mozilla.org/en-US/docs/Glossary/Mutable mutable]. All other datatypes are immutable.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Operators&amp;diff=1892</id>
		<title>Operators</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Operators&amp;diff=1892"/>
		<updated>2020-10-23T11:18:39Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Boolean Operators */ Short-circuit_evaluation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Mathematical Operators==&lt;br /&gt;
&lt;br /&gt;
The following mathematical operators are used in KoLmafia:&lt;br /&gt;
{{&lt;br /&gt;
eztable|&lt;br /&gt;
{{eztr|{{eztd| + |Addition|Performs addition and string concatenation}}}}&lt;br /&gt;
{{eztr|{{eztd| - |Subtraction|Performs subtraction}}}}&lt;br /&gt;
{{eztr|{{eztd| * |Multiplication|Performs multiplication}}}}&lt;br /&gt;
{{eztr|{{eztd| / |Division|Performs division}}}}&lt;br /&gt;
{{eztr|{{eztd| % |Modulo|Returns the remainder after division}}}}&lt;br /&gt;
{{eztr|{{eztd| ** |Exponent|Performs exponentiation}}}}&lt;br /&gt;
}}&lt;br /&gt;
Note that, with the exception of using &amp;lt;nowiki&amp;gt;&amp;quot;+&amp;quot;&amp;lt;/nowiki&amp;gt; for string concatenation, these operators can only be used on int or float datatypes.&lt;br /&gt;
&lt;br /&gt;
==Bitwise Operators==&lt;br /&gt;
&lt;br /&gt;
The following mathematical operators are used for operating on the bits of integers. The logical operators (&amp;amp;, |, ^) work either with booleans or integers while the others operate upon integers only. If the operands are booleans, then result will also be a boolean. &lt;br /&gt;
{{&lt;br /&gt;
eztable|&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt; |and|a &amp;amp; b}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt; |or|a &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt; b}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;^&amp;lt;/nowiki&amp;gt; |XOR|a &amp;lt;nowiki&amp;gt;^&amp;lt;/nowiki&amp;gt; b}}}}&lt;br /&gt;
{{eztr|{{eztd| ~ |not|~a}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;&amp;lt; |left shift|a &amp;lt;&amp;lt; b}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;gt;&amp;gt; |right shift|a &amp;gt;&amp;gt; b}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;amp;=&amp;lt;/nowiki&amp;gt; |and|&amp;lt;nowiki&amp;gt;a &amp;amp;= b --&amp;gt; a = a &amp;amp; b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;|=&amp;lt;/nowiki&amp;gt; |or|&amp;lt;nowiki&amp;gt;a |= b --&amp;gt; a = a | b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;gt;&amp;gt;&amp;gt; |unsigned right shift|a &amp;gt;&amp;gt;&amp;gt; b}}}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Assignment Operators==&lt;br /&gt;
The following assignment operators are used in KoLmafia (let a = left operand, b = right operand):&lt;br /&gt;
{{&lt;br /&gt;
eztable|&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;+=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a + b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;-=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a - b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;*=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a * b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;/=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a / b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;%=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a % b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;**=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a ** b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;^=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a ^ b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;gt;&amp;gt;=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a &amp;gt;&amp;gt; b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;gt;&amp;gt;&amp;gt;=&amp;lt;/nowiki&amp;gt; |&amp;lt;nowiki&amp;gt;a = a &amp;gt;&amp;gt;&amp;gt; b&amp;lt;/nowiki&amp;gt;}}}}&lt;br /&gt;
}}&lt;br /&gt;
Of these, only += and = are usable for strings.  See [[Operators#Mathematical Operators|Mathematical Operators]] for information regarding the basic Mathematical Operators.&lt;br /&gt;
&lt;br /&gt;
==Relational Operators==&lt;br /&gt;
&lt;br /&gt;
To follow these examples, a basic understanding of the concepts found on [[Control Structures]] would be helpful.&lt;br /&gt;
&lt;br /&gt;
In order to create more complex if statements, we need to understand the basic relational operators:&lt;br /&gt;
{{&lt;br /&gt;
eztable|&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;==&amp;lt;/nowiki&amp;gt; |equal to}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;!=&amp;lt;/nowiki&amp;gt; |not equal to}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt;/nowiki&amp;gt; |less than}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;gt;&amp;lt;/nowiki&amp;gt; |greater than}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;lt;=&amp;lt;/nowiki&amp;gt; |less than or equal to}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;gt;=&amp;lt;/nowiki&amp;gt; |greater than or equal to}}}}&lt;br /&gt;
}}&lt;br /&gt;
Note that you cannot mix most datatypes within a comparison or KoLmafia will abort with an error, with the exception of mixing types int and float, where KoLmafia will do a transparent type conversion behind-the-scenes. If you need to compare different datatypes, use one or more of the [[Datatype Conversions|Datatype Conversion]] functions. Also, == is case-insensitive with respect to strings.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( true == true )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( true == false )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line does NOT get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( 1 == 1.0 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( 1 == 2 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line does NOT get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( &amp;quot;Hello&amp;quot; == &amp;quot;hello&amp;quot; )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Another exception is with strings. If the &#039;&#039;&#039;first&#039;&#039;&#039; datatype is a string, and the second isn&#039;t, the latter will be silently converted into a string. Remember that strings are compared alphabetically (with the alphabet here being the characters&#039; [https://www.asciitable.com/ ASCII value]), just like in a dictionary, in which &amp;quot;smaller&amp;quot; means &amp;quot;would come before&amp;quot;.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( &amp;quot;a&amp;quot; &amp;lt; &amp;quot;b&amp;quot; )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( &amp;quot;apple&amp;quot; &amp;lt; &amp;quot;b&amp;quot; )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( &amp;quot;1&amp;quot; &amp;lt; 2 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( &amp;quot;1487&amp;quot; &amp;lt; 2 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( &amp;quot;a&amp;quot; &amp;lt; 2 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line does NOT get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ( &amp;quot;3&amp;quot; == 3 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( &amp;quot;3.0&amp;quot; == 3 )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line does NOT get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( 3 == &amp;quot;3&amp;quot; )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This GENERATES AN ERROR!&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
if ( &amp;quot;true&amp;quot; == true )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=Take the habit of always converting your datatypes to avoid unexpected problems.}}&lt;br /&gt;
&lt;br /&gt;
==Boolean Operators==&lt;br /&gt;
{{&lt;br /&gt;
eztable|&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;&amp;amp;&amp;amp;&amp;lt;/nowiki&amp;gt; |and}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;||&amp;lt;/nowiki&amp;gt; |or}}}}&lt;br /&gt;
{{eztr|{{eztd| &amp;lt;nowiki&amp;gt;!&amp;lt;/nowiki&amp;gt; |not}}}}&lt;br /&gt;
}}&lt;br /&gt;
Note that the above operators only work with boolean values &amp;amp; datatypes. To make use of them with other datatypes, you will either need to first perform a [[Datatype Conversions|Datatype Conversion]], or you will need to nest your operations such that a boolean value is used with the boolean operators.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( true &amp;amp;&amp;amp; true )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed (both possibilities proved true).&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( true &amp;amp;&amp;amp; false )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line does NOT get printed (only one possibility proved true).&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( true || false )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed (since at least one of the possibilities proved true).&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
if ( ! false )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed (since the not operator converted false to true).&amp;quot; );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
====Notes====&lt;br /&gt;
ASH uses [https://en.wikipedia.org/wiki/Short-circuit_evaluation Short-circuit_evaluation].&amp;lt;br&amp;gt;&lt;br /&gt;
What this means is that in both of these examples, expensive_function() is not evaluated (i.e. is skipped):&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( false &amp;amp;&amp;amp; expensive_function() ) {&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( true || expensive_function() ) {&lt;br /&gt;
   ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==Operator Precedence==&lt;br /&gt;
&lt;br /&gt;
KoLmafia follows [http://download.oracle.com/javase/tutorial/java/nutsandbolts/operators.html Java&#039;s Operator Precedence rules] with a few exceptions.&lt;br /&gt;
&lt;br /&gt;
(The exceptions being operators that exist in only one or the other; operators that exist in both have the same precedence in both.)&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
eztable|&lt;br /&gt;
{{eztr|{{eztd|14| &amp;lt;nowiki&amp;gt;(reserved for postfix ++ and --)&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|13| &amp;lt;nowiki&amp;gt;! ~ contains remove (reserved for prefix ++ and --)&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|12| &amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|11| &amp;lt;nowiki&amp;gt;* / %&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|10| &amp;lt;nowiki&amp;gt;+ -&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd| 9| &amp;lt;nowiki&amp;gt;&amp;lt;&amp;lt; &amp;gt;&amp;gt; &amp;gt;&amp;gt;&amp;gt;&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|8| &amp;lt;nowiki&amp;gt;&amp;lt; &amp;gt; &amp;lt;= &amp;gt;=&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|7| &amp;lt;nowiki&amp;gt;== !=&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|6| &amp;lt;nowiki&amp;gt;&amp;amp;&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|5| &amp;lt;nowiki&amp;gt;^&amp;lt;/nowiki&amp;gt; (xor) }}}}&lt;br /&gt;
{{eztr|{{eztd|5| &amp;lt;nowiki&amp;gt;|&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|3| &amp;lt;nowiki&amp;gt;&amp;amp;&amp;amp;&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|2| &amp;lt;nowiki&amp;gt;||&amp;lt;/nowiki&amp;gt; }}}}&lt;br /&gt;
{{eztr|{{eztd|1|(reserved for &amp;lt;nowiki&amp;gt;?:&amp;lt;/nowiki&amp;gt;(ternary conditional))}}}}&lt;br /&gt;
{{eztr|{{eztd|0| (reserved for assignments)}}}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Statements inside a () pair are always evaluated first, then in order of precedence as listed above (highest number precedence first), then left-to-right.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( true || true &amp;amp;&amp;amp; false )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
   // &amp;amp;&amp;amp; has highest precedence&lt;br /&gt;
   // true or (true &amp;amp;&amp;amp; false) returns true&lt;br /&gt;
}&lt;br /&gt;
if ( ( true &amp;amp;&amp;amp; false ) &amp;amp;&amp;amp; true )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line does NOT get printed.&amp;quot; );&lt;br /&gt;
   // ( true &amp;amp;&amp;amp; false ) is evaluated first since it is inside of parentheses&lt;br /&gt;
   // so we end up evaluating ( false &amp;amp;&amp;amp; true ) which returns false&lt;br /&gt;
}&lt;br /&gt;
if ( true &amp;amp;&amp;amp; ! ( true &amp;amp;&amp;amp; false ) )&lt;br /&gt;
{&lt;br /&gt;
   print( &amp;quot;This line DOES get printed.&amp;quot; );&lt;br /&gt;
   // ( true &amp;amp;&amp;amp; false ) is evaluated first since it is inside of parentheses&lt;br /&gt;
   // the ! operator converts the false from ( true &amp;amp;&amp;amp; false ) to true&lt;br /&gt;
   // ( true &amp;amp;&amp;amp; true ) returns true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=User_confirm&amp;diff=2816</id>
		<title>User confirm</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=User_confirm&amp;diff=2816"/>
		<updated>2020-10-23T11:12:05Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|user_confirm}}{{&lt;br /&gt;
#vardefine:return_type|boolean}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|message}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|message}}|&lt;br /&gt;
parameter2={{Param|int|timeOutMillis}}|&lt;br /&gt;
parameter3={{Param|boolean|defaultValue}}|&lt;br /&gt;
p1desc={{pspan|message}} is the text to display in the confirmation pop-up|&lt;br /&gt;
p2desc={{pspan|timeOutMillis}} the length of time to display the dialog, in milliseconds|&lt;br /&gt;
p3desc={{pspan|defaultValue}} the value to return if the user does not choose an input before &amp;lt;b&amp;gt;timeOutMillis&amp;lt;/b&amp;gt; ms|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Presents the user with a pop-up dialog box with the text in {{pspan|message}} (can use escaped characters, such as &amp;quot;&amp;lt;nowiki&amp;gt;\n&amp;lt;/nowiki&amp;gt;&amp;quot; for a newline); returns true if the user selects &amp;quot;Yes&amp;quot; and false if the user selects &amp;quot;No.&amp;quot;&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If you wish for the dialog to &amp;quot;time out&amp;quot; and return a default value if the user does not select an option, use the three-parameter version.&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;Please use these sparingly, as it can defeat the purpose of scripting if the user must constantly provide information during execution.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=A check to see if the user truly wants to execute a script.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if (!user_confirm(&amp;quot;Are you sure you want to proceed with executing this script?&amp;quot;) )&lt;br /&gt;
{&lt;br /&gt;
   abort(&amp;quot;Script execution canceled by user.&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
code2={{CodeSample|&lt;br /&gt;
title=Conditional pop-ups|&lt;br /&gt;
description=By taking in consideration that ASH has lazy booleans, it is possible to make confirmation messages that will only appear if the user doesn&#039;t satisfy a condition without having to isolate the user_confirm() call.&amp;lt;br&amp;gt;In this example, the user is asked to input the amount of adventures to spend. If they have at least that much, the script simply executes, without a pop-up appearing. Otherwise, a pop-up appears, and the script only executes if the user answers yes.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
void main( int adventures_to_spend )&lt;br /&gt;
{&lt;br /&gt;
   if (my_adventures() &amp;lt; adventures_to_spend &amp;amp;&amp;amp; !user_confirm(&amp;quot;You don&#039;t have that many adventures. Use as many as possible instead?&amp;quot;))&lt;br /&gt;
   {&lt;br /&gt;
      abort(&amp;quot;Script execution canceled by user.&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   // Rest of the script&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=See [[Operators#Boolean_Operators]] for how/why this works.}}|&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Miscellaneous Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Print&amp;diff=2736</id>
		<title>Print</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Print&amp;diff=2736"/>
		<updated>2020-09-20T23:20:49Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|print}}{{&lt;br /&gt;
#vardefine:return_type|void}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|message}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|message}}|&lt;br /&gt;
parameter2={{Param|string|color}}|&lt;br /&gt;
p1desc={{Pspan|message}} is the text to print|&lt;br /&gt;
p2desc={{Pspan|color}} is an html color name or code|&lt;br /&gt;
}}|&lt;br /&gt;
function_description=Print the specified text {{pspan|message}} to the CLI. If the optional {{pspan|color}} parameter is specified and a valid html color code or entity, it will print in that color. See the [http://www.w3.org/TR/CSS21/syndata.html#color-units CSS 2.1 color specification] for a description of valid color syntax and keywords.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Prints stuff in color and black. Note that it prints black twice: first and last.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
print(&amp;quot;This is black.&amp;quot;);&lt;br /&gt;
foreach color in $strings[blue, green, olive, darkorange, magenta, black]&lt;br /&gt;
   print(&amp;quot;This is &amp;quot;+color+&amp;quot;.&amp;quot;, color);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|dump|logprint|print_html|chat_notify}}|&lt;br /&gt;
cli_equiv=The CLI commands &amp;quot;fprint,&amp;quot; &amp;quot;echo&amp;quot; and &amp;quot;fecho&amp;quot; have similar functionality, minus the color option. However, &amp;quot;cecho&amp;quot; (also &amp;quot;colorecho&amp;quot;) does have this option for color.|&lt;br /&gt;
special=A list of common color commands that can be used: olive, yellow, orange, gray, fuchsia, red, white, silver, teal, navy, blue, maroon, purple. &amp;lt;br&amp;gt; More advance colors can be used by entering their Hexadecimal code as the string. &amp;lt;br&amp;gt;Using an invalid color name or code can cause odd colors to be chosen; see the [[Talk:Print|Talk Page]] for details.&lt;br /&gt;
&amp;lt;br /&amp;gt;As of r8638, attempting to print a string beginning with a slash(/) will cause KoLmafia to print a blank line instead. To avoid this behavior, you must specify the second argument for the text color. Any color will do, and even a blank string (&amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;) will work.&lt;br /&gt;
|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Miscellaneous Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Dump&amp;diff=8553</id>
		<title>Dump</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Dump&amp;diff=8553"/>
		<updated>2020-09-20T23:19:58Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: create dump()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|dump}}{{&lt;br /&gt;
#vardefine:return_type|void}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
parameter1={{Param|any|composite}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
parameter1={{Param|any|composite}}|&lt;br /&gt;
parameter2={{Param|string|color}}|&lt;br /&gt;
p1desc={{Pspan|composite}} is the variable to dump. Can be any data type (besides &#039;&#039;void&#039;&#039;), but the intended use is with [[Data_Types#aggregate|an aggregate]] or [[Data_Types#record|a record]].|&lt;br /&gt;
p2desc={{Pspan|color}} is an html color name or code. See [[print]] for more information.|&lt;br /&gt;
}}|&lt;br /&gt;
function_description=&amp;quot;Dumps&amp;quot; (i.e. &amp;quot;unfolds&amp;quot;, showing every key/field of the variable, and their value) {{pspan|composite}} to the CLI (in &amp;lt;color&amp;gt;, if specified and valid) and to the session logs.&amp;lt;br&amp;gt;&lt;br /&gt;
If {{pspan|composite}} isn&#039;t a composite value (record or aggregate), functions similarly to print().|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=This example starts with [https://kolmafia.us/showthread.php?280-Records-in-ASH Veracity&#039;s introductory example on records].|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
/* definition */&lt;br /&gt;
record my_type {&lt;br /&gt;
    int ifield;&lt;br /&gt;
    string sfield;&lt;br /&gt;
    record {&lt;br /&gt;
        int first;&lt;br /&gt;
        int second;&lt;br /&gt;
    } rfield;&lt;br /&gt;
    int [int, int] mfield;&lt;br /&gt;
};&lt;br /&gt;
&lt;br /&gt;
my_type rvar;&lt;br /&gt;
my_type [int] mrvar;&lt;br /&gt;
&lt;br /&gt;
/* population/assignments */&lt;br /&gt;
rvar.ifield = 10;&lt;br /&gt;
rvar.sfield = &amp;quot;secret&amp;quot;;&lt;br /&gt;
rvar.rfield.first = 1000;&lt;br /&gt;
rvar.rfield.second = 2000;&lt;br /&gt;
rvar.mfield[ 2, 3 ] = 12;&lt;br /&gt;
&lt;br /&gt;
mrvar[ 1 ] = rvar;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
code2={{CodeSample|&lt;br /&gt;
description=Then, instead of using &#039;&#039;foreach&#039;&#039; loops, simply does:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
dump(mrvar);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=which will print in the CLI:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
aggregate my_type [int]&lt;br /&gt;
1 =&amp;gt; record my_type&lt;br /&gt;
  ifield =&amp;gt; 10&lt;br /&gt;
  sfield =&amp;gt; secret&lt;br /&gt;
  rfield =&amp;gt; record (anonymous record 7dbf2293)&lt;br /&gt;
    first =&amp;gt; 1000&lt;br /&gt;
    second =&amp;gt; 2000&lt;br /&gt;
  mfield =&amp;gt; aggregate int [int, int]&lt;br /&gt;
    2 =&amp;gt; aggregate int [int]&lt;br /&gt;
      3 =&amp;gt; 12&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
cli_equiv=This is the equivalent of returning/ending with a variable with the CLI command &amp;quot;ash&amp;quot;, minus the color option.|&lt;br /&gt;
see_also={{SeeAlso|print|logprint}}|&lt;br /&gt;
special=[https://kolmafia.us/showthread.php?25398-print()&amp;amp;p=158966&amp;amp;viewfull=1#post158966 Take note that the behaviour of this function with non-composite values is NOT the exact same as print().]&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Miscellaneous Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Appearance_rates&amp;diff=4754</id>
		<title>Appearance rates</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Appearance_rates&amp;diff=4754"/>
		<updated>2020-08-31T10:28:52Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: code snippet is now obsolete&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|appearance_rates}}{{&lt;br /&gt;
#vardefine:return_type|float [monster]}}{{&lt;br /&gt;
#vardefine:aggregate|yes}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|location|place}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|location|place}}|&lt;br /&gt;
parameter2={{Param|boolean|queue}}|&lt;br /&gt;
p1desc={{Pspan|place}} is the adventuring location to parse|&lt;br /&gt;
p2desc=The optional parameter {{Pspan|queue}} is false if not included.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Account for combat rate modifiers, olfaction, etc. (as best as it can).&amp;lt;br&amp;gt; Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0.&amp;lt;br&amp;gt; Ultra-Rare monsters have a value of -1.0.&amp;lt;br&amp;gt; Impossible monsters (mostly just monsters that only appear on odd/even ascensions) have a value of -2.0.&amp;lt;br&amp;gt; (Properly, as in not-also-olfacted) Banished monsters have a value of -3.0.&amp;lt;br&amp;gt; Monsters banished by in-game mechanics (such as pygmy janitors in the hidden city) have a value of -4.0 (is often mixed up with 0.0 values). &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If there is a chance of non-combat encounters, that will be listed as the chance of encountering $monster[none].&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If {{Pspan|queue}} is true, then the monsters currently in the adventuring queue will be considered when determining the likelihood of future encounters. This is better for a real prediction of what monster will actually occur next while not considering the queue is better for modeling theoretical situations.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Simple Example|&lt;br /&gt;
description=Prints the encounters in a zone and their rates of appearing.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach mob, freq in appearance_rates($location[Dungeon of Doom])&lt;br /&gt;
   switch {&lt;br /&gt;
   case mob == $monster[none]:&lt;br /&gt;
      if(freq &amp;gt; 0) print(&amp;quot;Frequency of non-combats: &amp;quot;+ freq + &amp;quot;%&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case freq &amp;gt; 0:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: &amp;quot; + freq + &amp;quot;%&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case freq == 0:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: Boss (one time encounter) or semirare encounter.&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case freq &amp;lt; 0:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: Ultra-rare!&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   default:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: Unknown&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
see_also={{SeeAlso|get_monsters|last_monster}}|&lt;br /&gt;
special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia&#039;s data files.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Adventuring]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Appearance_rates&amp;diff=4753</id>
		<title>Appearance rates</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Appearance_rates&amp;diff=4753"/>
		<updated>2020-08-31T10:27:12Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|appearance_rates}}{{&lt;br /&gt;
#vardefine:return_type|float [monster]}}{{&lt;br /&gt;
#vardefine:aggregate|yes}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|location|place}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|location|place}}|&lt;br /&gt;
parameter2={{Param|boolean|queue}}|&lt;br /&gt;
p1desc={{Pspan|place}} is the adventuring location to parse|&lt;br /&gt;
p2desc=The optional parameter {{Pspan|queue}} is false if not included.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns a map, keyed by monster, with the appearance rate percentages as decimal values (ie a 30% rate monster has a value of 30.0). Account for combat rate modifiers, olfaction, etc. (as best as it can).&amp;lt;br&amp;gt; Bosses, semirare encounters, and other one-time-only monsters have a value of 0.0.&amp;lt;br&amp;gt; Ultra-Rare monsters have a value of -1.0.&amp;lt;br&amp;gt; Impossible monsters (e.g. encountering a clingy pirate corresponding to your gender) have a value of -2.0.&amp;lt;br&amp;gt; (Properly, as in not-also-olfacted) Banished monsters have a value of -3.0.&amp;lt;br&amp;gt; Monsters banished by in-game mechanics (such as pygmy janitors in the hidden city) have a value of -4.0 (is often mixed up with 0.0 values). &amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If there is a chance of non-combat encounters, that will be listed as the chance of encountering $monster[none].&amp;lt;/p&amp;gt;&lt;br /&gt;
&amp;lt;p&amp;gt;If {{Pspan|queue}} is true, then the monsters currently in the adventuring queue will be considered when determining the likelihood of future encounters. This is better for a real prediction of what monster will actually occur next while not considering the queue is better for modeling theoretical situations.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Simple Example|&lt;br /&gt;
description=Prints the encounters in a zone and their rates of appearing.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach mob, freq in appearance_rates($location[Dungeon of Doom])&lt;br /&gt;
   switch {&lt;br /&gt;
   case mob == $monster[none]:&lt;br /&gt;
      if(freq &amp;gt; 0) print(&amp;quot;Frequency of non-combats: &amp;quot;+ freq + &amp;quot;%&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case freq &amp;gt; 0:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: &amp;quot; + freq + &amp;quot;%&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case freq == 0:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: Boss (one time encounter) or semirare encounter.&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case freq &amp;lt; 0:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: Ultra-rare!&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   default:&lt;br /&gt;
      print(&amp;quot;Frequency of &amp;quot; + mob + &amp;quot;: Unknown&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   }&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
see_also={{SeeAlso|get_monsters|last_monster}}|&lt;br /&gt;
special=When not logged in, this function still returns the same data, as it is pulled from KoLmafia&#039;s data files.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Adventuring]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3212</id>
		<title>Data Structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3212"/>
		<updated>2020-08-29T23:46:58Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Aggregate literals */ not providing keys with a map keyed by integers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
KoLmafia supports complex data structures such as maps and records made from simple [[Data Types|data types]].&lt;br /&gt;
&lt;br /&gt;
== Maps ==&lt;br /&gt;
If you are new to programming or find the information below confusing, you may want to read [[Map_Guide | A Noob&#039;s Guide to Maps]] first. &lt;br /&gt;
&lt;br /&gt;
Most of this information was copied directly from ASH Maps Tutorial, by Veracity (http://kolmafia.sourceforge.net/advanced.html#maps)&lt;br /&gt;
&lt;br /&gt;
A map is indexed by one data type (the key) and associates that key with another (or the same) data type (the value). The key can be any ASH simple data type: boolean, int, float, string, item, location, class, stat, skill, effect, familiar, slot, or monster. The value can be any ASH data type at all: a simple type, a record, or can be another map. This effectively allows multi-dimensional maps and. In fact, that&#039;s how the syntax we provide for multi-dimensional maps actually operate: maps of maps of maps ...&lt;br /&gt;
&lt;br /&gt;
You can declare a map any time you can declare a variable: as a top level (global) variable, as a function parameter, or as a local variable in any scope.&lt;br /&gt;
&lt;br /&gt;
You can fetch data from a map any time you can provide a data value: in an expression, as a function parameter, on the right side of an assignment statement, from a &amp;quot;return&amp;quot; statement, as so on. You can pass around entire maps, individual elements, or intermediate maps: &amp;quot;slices&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Declarations ===&lt;br /&gt;
&lt;br /&gt;
The syntax for declaring the data type of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;data type&amp;gt; [ &amp;lt;key type&amp;gt;, ... ] &amp;lt;aggregate_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [item] map1;&lt;br /&gt;
float [class, string, int] another_map;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Assignments ===&lt;br /&gt;
&lt;br /&gt;
==== Assigning individual values ====&lt;br /&gt;
&lt;br /&gt;
If you specify a map and a complete set of indices (of the correct types) on the left side of an assignment statement, you set a single element.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] my_pricelist;&lt;br /&gt;
my_pricelist[ $item[ pail ] ] = 1000;&lt;br /&gt;
my_pricelist[ $item[ bum cheek ] ] = 404;&lt;br /&gt;
my_pricelist[ $item[ red button ] ] = 100;&lt;br /&gt;
my_pricelist[ $item[ red balloon ] ] = 100000;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Aggregate literals ====&lt;br /&gt;
You can declare ready to use, anonymous (single use) maps on the fly, called &#039;&#039;aggregate literals&#039;&#039;, at any time you can provide a data value. They follow the syntax:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{ &amp;lt;key&amp;gt;: &amp;lt;value&amp;gt;, &amp;lt;key&amp;gt;: &amp;lt;value&amp;gt;, &amp;lt;key&amp;gt;: &amp;lt;value&amp;gt; ... }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An &#039;&#039;aggregate literal&#039;&#039; can be used to initialize an entire aggregate at once.  For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] my_pricelist = {&lt;br /&gt;
  $item[pail]: 1000,&lt;br /&gt;
  $item[bum cheek]: 404,&lt;br /&gt;
  $item[red button]: 100,&lt;br /&gt;
  $item[red balloon]: 100000&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
which achieves the same as what was done in the &#039;Assigning individual values&#039; example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: when using an aggregate literal for anything else than assignment (e.g. as a return statement, in an expression, or as a function parameter), you need to supply the data types of the aggregate in front of the aggregate literal, even when the expected data types are already known. Example:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item [int] my_function () {&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  return item [int] {&amp;lt;int&amp;gt;: &amp;lt;item&amp;gt;, &amp;lt;int&amp;gt;: &amp;lt;item&amp;gt;, &amp;lt;int&amp;gt;: &amp;lt;item&amp;gt; ...};&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note bis: if the key of your map is integers, providing the keys is not mandatory; the keys will be automatically supplied in order, so:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [int] {&amp;quot;this&amp;quot;,&amp;quot;is&amp;quot;,&amp;quot;called&amp;quot;,&amp;quot;a&amp;quot;,&amp;quot;list&amp;quot;};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Creates a map that contains:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
0 =&amp;gt; this&lt;br /&gt;
1 =&amp;gt; is&lt;br /&gt;
2 =&amp;gt; called&lt;br /&gt;
3 =&amp;gt; a&lt;br /&gt;
4 =&amp;gt; list&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to make an aggregate literal of a multi-dimensional map. Since multi-dimensional maps are effectively maps of maps (of maps) &#039;&#039;(of maps)&#039;&#039; &#039;&#039;(...)&#039;&#039;, their aggregate literal would be an aggregate literal, inside an aggregate literal &#039;&#039;(inside an aggregate literal)&#039;&#039; (...). Nested aggregate literals.&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item[class, slot] basic_equipments = {&lt;br /&gt;
  $class[Seal Clubber]: {&lt;br /&gt;
    $slot[hat]: $item[seal-skull helmet],&lt;br /&gt;
    $slot[weapon]: $item[seal-clubbing club],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Turtle Tamer]: {&lt;br /&gt;
    $slot[hat]: $item[helmet turtle],&lt;br /&gt;
    $slot[weapon]: $item[turtle totem],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Pastamancer]: {&lt;br /&gt;
    $slot[hat]: $item[ravioli hat],&lt;br /&gt;
    $slot[weapon]: $item[pasta spoon],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Sauceror]: {&lt;br /&gt;
    $slot[hat]: $item[Hollandaise helmet],&lt;br /&gt;
    $slot[weapon]: $item[saucepan],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Disco Bandit]: {&lt;br /&gt;
    $slot[hat]: $item[disco mask],&lt;br /&gt;
    $slot[weapon]: $item[disco ball],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Accordion Thief]: {&lt;br /&gt;
    $slot[hat]: $item[mariachi hat],&lt;br /&gt;
    $slot[weapon]: $item[stolen accordion],&lt;br /&gt;
    $slot[pants]: $item[mariachi pants]&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Map-map assignments ====&lt;br /&gt;
If you use a map on the left side of an assignment, you set the whole map at once to the new value.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] my_pricelist;&lt;br /&gt;
int [item] new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Some code that updates my_pricelist with new_pricelist */&lt;br /&gt;
&lt;br /&gt;
my_pricelist = new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Now my_pricelist and new_pricelist point to the same aggregate; &lt;br /&gt;
   changes to an element of one of them will be visible in the other */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Slices ====&lt;br /&gt;
If you specify a map and a prefix of indices (of the correct type), you directly set one of the intermediate maps, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float [string, int, string] my_map;&lt;br /&gt;
float [int, string] slice1;&lt;br /&gt;
&lt;br /&gt;
/* Some code that fills my_map[ &amp;quot;slice1&amp;quot; ] with slice1 */&lt;br /&gt;
my_map[ &amp;quot;slice1&amp;quot; ] = slice1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
The syntax for referencing an element (or slice) of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate name&amp;gt;[ &amp;lt;key expression&amp;gt;, ... ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All the key expressions will be evaluated at run time. If you specify all the keys the map expects, you fetch data of the type specified by the map. If you specify fewer keys than the map expects, you get an intermediate map, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
As an example:&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean [string, string] props; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
might be used to hold &amp;quot;properties&amp;quot; associated with names.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;pet&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;mammal&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;pet&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;mammal&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;pet&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;fun&amp;quot; ] = true; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
references:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot;] =&amp;gt; true&lt;br /&gt;
boolean [string] animal = props[ &amp;quot;turtle&amp;quot; ];&lt;br /&gt;
animal[ &amp;quot;fun&amp;quot; ] =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Contains ===&lt;br /&gt;
&lt;br /&gt;
You can test the presence of a key in a map using the &amp;quot;contains&amp;quot; operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate reference expression&amp;gt; contains &amp;lt;key expression&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;aggregate reference expression&amp;gt; must evaluate at run time to a map or slice, and must evaluate at run time to a key of the appropriate type. (Note that that is enforced at parse time; ASH can tell the datatype any expression will produce).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props contains &amp;quot;dog&amp;quot; =&amp;gt; true&lt;br /&gt;
props contains &amp;quot;elephant&amp;quot; =&amp;gt; false&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot; ] contains &amp;quot;fun&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;pet&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;favorite food&amp;quot; =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that only the current slice&#039;s keys are evaluated. This means that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
boolean [ boolean ] [ boolean ] [ boolean ] [ boolean ] [ boolean ] much_truthness;&lt;br /&gt;
much_truthness [ true ] [ true ] [ false ] [ true ] [ true ] = true;&lt;br /&gt;
&lt;br /&gt;
return much_truthness [ true ] [ true ] contains true;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Returned: false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remove ===&lt;br /&gt;
&lt;br /&gt;
You can remove a key-value association from a map using the &amp;quot;remove&amp;quot; unary operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
remove &amp;lt;aggregate reference&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarification, an aggregate reference is &amp;quot;&amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n&amp;gt; ]&amp;quot; where &amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n-1&amp;gt; ] specifies the &amp;quot;slice&amp;quot; and &amp;lt;index n&amp;gt; specifies the &amp;quot;key&amp;quot;. Which is just what you expect, if you fully specify the indices; for a single dimensional map, &amp;quot;map[10]&amp;quot; -&amp;gt; &amp;quot;map&amp;quot; is the slice and 10 is the key. The &amp;quot;remove&amp;quot; operator removes the &amp;quot;key&amp;quot; from the &amp;quot;slice&amp;quot;. For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [int] map1;&lt;br /&gt;
map1[5] = &amp;quot;foo&amp;quot;;&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot; + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot;  + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
int [string, string] map2;&lt;br /&gt;
map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] = 17;&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1 true foo&lt;br /&gt;
remove: foo&lt;br /&gt;
0 false&lt;br /&gt;
remove:&lt;br /&gt;
1 true 17&lt;br /&gt;
remove: 17&lt;br /&gt;
0 false 0&lt;br /&gt;
remove: 0&lt;br /&gt;
1 aggregate int [string]&lt;br /&gt;
remove: aggregate int [string]&lt;br /&gt;
0 aggregate int [string]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Clear ===&lt;br /&gt;
&lt;br /&gt;
You can remove all &amp;lt;code&amp;gt;key =&amp;gt; value&amp;lt;/code&amp;gt; entries from a map using the {{f|clear}} function:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;clear( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Count ===&lt;br /&gt;
&lt;br /&gt;
The {{f|count}} function returns the number of defined keys for the specified aggregate.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;int size = count( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sort ===&lt;br /&gt;
&lt;br /&gt;
From http://kolmafia.us/showthread.php?t=1738 and http://kolmafia.us/showthread.php?10729&lt;br /&gt;
&lt;br /&gt;
The syntax is:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;sort aggregate by keyExpr;&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;aggregate&amp;lt;/code&amp;gt; is a reference to the object to be sorted - arrays are probably the most useful things to sort, but any mapping type can be used.  But please note that when you sort a map, you change the values that correspond to the index. To sort on a map, you would want to use a multidimensional maps, but note that you can only sort along a single dimension at a time when doing this. Simply put... &amp;quot;sort&amp;quot; is only useful in cases where your data exists entirely in the values of the map; the keys can have no meaning beyond simply being distinct.&lt;br /&gt;
&lt;br /&gt;
The reference must not be enclosed in parentheses, as that would look like a call to a function named &amp;lt;code&amp;gt;sort()&amp;lt;/code&amp;gt; - which is still perfectly valid, &amp;quot;sort&amp;quot; has not become a [[Reserved Words|reserved word]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is an arbitrary expression that defines how the items should be ordered. It is evaluated once for every entry in the aggregate, in a scope with two additional variables implicitly defined: &#039;&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;&#039; and &#039;&amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;&#039;, holding the details of that entry. The value of the &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is used as the sort key; typically it would be an &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;, but can be any ASH type that can be compared via &amp;quot;&amp;lt;&amp;quot; and the other relational operators.&lt;br /&gt;
&lt;br /&gt;
The most basic form of sorting would therefore be &amp;quot;&amp;lt;code&amp;gt;sort ... by value&amp;lt;/code&amp;gt;&amp;quot;, but many useful things can be done with the use of a more complex &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; - the only real restriction is that the expression should not modify the object you&#039;re sorting. For example, if you had an array of items, you could sort it &amp;quot;&amp;lt;code&amp;gt;by autosell_price(value)&amp;lt;/code&amp;gt;&amp;quot;. An array of weapon items could be sorted &amp;quot;&amp;lt;code&amp;gt;by -get_power(value)&amp;lt;/code&amp;gt;&amp;quot; to put it in decreasing order of power. If the elements of your aggregate are records, you&#039;d need to use something like &amp;quot;&amp;lt;code&amp;gt;by value.fieldName&amp;lt;/code&amp;gt;&amp;quot;, since the records themselves can&#039;t be meaningfully compared.&lt;br /&gt;
&lt;br /&gt;
After the sort statement, the aggregate will have exactly the same sets of keys and values as before (even if the keys weren&#039;t consecutive), and the iteration order of the keys will be the same, but the values will likely be associated with different keys. The sort is stable - in other words, elements with sort keys that compare as equal will remain in the same order. This means that you can sort on multiple criteria by simply performing separate sorts for each of the criteria, in increasing order of significance.&lt;br /&gt;
&lt;br /&gt;
To find out how many things you have, you might do:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item [int] whatGot;&lt;br /&gt;
int ctr =0;&lt;br /&gt;
&lt;br /&gt;
foreach it in get_inventory() {&lt;br /&gt;
   whatGot[ctr] = it;&lt;br /&gt;
   ctr+=1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sort whatGot by item_amount(value);&lt;br /&gt;
&lt;br /&gt;
foreach x, it in whatGot&lt;br /&gt;
   print(item_amount(it) + &#039; of &#039; + it);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Note that this use of an optional feature of foreach. The second variable in the foreach is the value of whatGot[x].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A few more examples of things you can do:&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -value&amp;lt;/code&amp;gt;&amp;quot; sorts integers in decreasing order (there&#039;s no similar trick for &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; values).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -index&amp;lt;/code&amp;gt;&amp;quot; reverses the existing order of an array (or map with integer keys).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by random(1000000)&amp;lt;/code&amp;gt;&amp;quot; shuffles into a random order.&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by otherArray[index]&amp;lt;/code&amp;gt;&amp;quot; uses values from a parallel array as the sort keys (you&#039;d then need to do &amp;quot;&amp;lt;code&amp;gt;sort otherArray by value;&amp;lt;/code&amp;gt;&amp;quot; if you wanted the two arrays to remain in sync).&lt;br /&gt;
&lt;br /&gt;
===Iteration===&lt;br /&gt;
To iterate through a map, use the &#039;&#039;&#039;foreach&#039;&#039;&#039; operator. For instance, if you wanted to print out how many of each item you had, you could do something like the following:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] map = get_inventory();&lt;br /&gt;
foreach key in map {&lt;br /&gt;
    print(key + &amp;quot; (&amp;quot; + map[key] + &amp;quot;)&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Multidimensional maps are implemented as maps that map keys to maps. &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is really a mapping of items to int[string] maps. Iteration, therefore, is as follows:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
file_to_map(&amp;quot;somefile.txt&amp;quot;, map);&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    print(k1 + &amp;quot;: &amp;quot;);&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        print(&amp;quot;\t&amp;quot; + k2 + &amp;quot;: &amp;quot; + map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Two things to note: First, &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;int[item, string]map&#039;&#039;&#039;. This really comes down to author preference, although the second form is generally more common. Second, the two following foreach loops are equivalent:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        func(map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
foreach k1, k2 in map {&lt;br /&gt;
    func(map[k1][k2]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Of course, the latter does not lend itself to, say, only printing the first key once, whereas the former can be used that way (see the preceding example).&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
Maps in ASH are implemented internally as TreeMaps [http://download.oracle.com/javase/1.5.0/docs/api/java/util/TreeMap.html]. See below for some implications.&lt;br /&gt;
&lt;br /&gt;
== Arrays ==&lt;br /&gt;
These look and behave like mappings of integers to values, where the keys only take values from 0 to n, but these are implemented as Java Arrays.&lt;br /&gt;
&lt;br /&gt;
===Differences between arrays and maps===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [12] array;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use keys 0 - 11. You get a runtime error if you use any other key. It always uses memory to hold 12 items, even if you only use a couple of them. But it&#039;s a constant time - O(1) - to access any element.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [int] map;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use any int as a key. It has constant memory for the Java map, and additional memory for each element in the map, but is O( log n) to access any particular element.&lt;br /&gt;
&lt;br /&gt;
If you are able to use (a fairly densely packed set of) integers as keys, your program will be faster and use (potentially) slightly more memory.&lt;br /&gt;
&lt;br /&gt;
If you have a sparse set of integers, you can still use an array and get fast access, but you will waste a lot of memory.&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t use integers as keys or don&#039;t want to waste memory on a sparse array, you can have a slower but less memory consuming map.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48703&amp;amp;viewfull=1#post48703]&lt;br /&gt;
&lt;br /&gt;
====Time considerations====&lt;br /&gt;
* Given &#039;&#039;&#039;if (a == item1 || a == item2 || a == item3)&#039;&#039;&#039; and &#039;&#039;&#039;if ($items[item1, item2, item3] contains a)&#039;&#039;&#039;, which is faster?&lt;br /&gt;
&lt;br /&gt;
This is going to depend on the number of items in the list, and which one happens to match; if &#039;a&#039; is almost always item1, then the first form is likely to win on practical grounds, even though it&#039;s theoretically slower (O(n) vs. O(log n)).&lt;br /&gt;
&lt;br /&gt;
The second form is a definite win assuming no such coincidences of the item chosen, a somewhat larger set of items, and that the code is executed more than once per run of the script. The first lookup in a plural constant actually builds an internal map that allows such queries to be efficiently done; this is deferred because typical use of a plural constant involves only iteration, not lookups.&lt;br /&gt;
&lt;br /&gt;
There&#039;s always the &amp;quot;profile&amp;quot; command, if you really need to know which is more efficient in a given situation - although it&#039;s unlikely that either would have a noticeable effect on your script&#039;s performance.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48728&amp;amp;viewfull=1#post48728]&lt;br /&gt;
&lt;br /&gt;
== Records ==&lt;br /&gt;
&lt;br /&gt;
(Link to Veracity&#039;s post introducing the record [http://kolmafia.us/showthread.php?t=280])&lt;br /&gt;
&lt;br /&gt;
Records are custom-made data types, that act like compartmentalized boxes [https://i.imgur.com/rgxLKRC.jpg].&lt;br /&gt;
&lt;br /&gt;
They are &amp;quot;variable packages&amp;quot;, that allow you to group together data of any type, including other records, in them.&lt;br /&gt;
&lt;br /&gt;
Records have &amp;quot;models&amp;quot; (the custom data type of the record itself), and names representing them (though not all of them are creative, such as &#039;&#039;&amp;quot;the_black_one_that_I_bought_a_year_ago&amp;quot;&#039;&#039;, or &#039;&#039;&amp;quot;the_one_that_is_over_there_by_the_door&amp;quot;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Each &amp;quot;compartment&amp;quot; (field) also has a name, as well as an expected data type. &#039;&#039;(Stop trying to put screws &amp;quot;there&amp;quot;; that&#039;s my god damn lunchbox, and this is &amp;quot;the spot in which you put the guacamole&amp;quot;!)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a &amp;quot;box&#039;s model&amp;quot; (record&#039;s data type) is declared, it can be used (almost) anywhere that can use a built-in type name (as long as you don&#039;t leave the scope in which the record was declared), such as in functions and other records.&lt;br /&gt;
&lt;br /&gt;
===Declarations===&lt;br /&gt;
The syntax for declaring a new record:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
record &amp;lt;&amp;quot;model&amp;quot; name&amp;gt; { &amp;lt;data type 1&amp;gt; &amp;lt;field name 1&amp;gt;; &amp;lt;data type 2&amp;gt; &amp;lt;field name 2&amp;gt;; ... }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This declared a new data &#039;&#039;&#039;&#039;&#039;type&#039;&#039;&#039;&#039;&#039;, a &#039;&#039;mold&#039;&#039;, a &#039;&#039;blueprint&#039;&#039;... No variable was created here.&lt;br /&gt;
&lt;br /&gt;
To actually &#039;&#039;create&#039;&#039; a variable that &#039;&#039;uses&#039;&#039; this &amp;quot;model&amp;quot;, you would &#039;&#039;&#039;then&#039;&#039;&#039; do:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
human that_guy;&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
You now have 3 &amp;quot;human&amp;quot;s, each with a name, date of birth, location of birth, and clothes (though none of them has had those assigned, yet).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to declare a record and create a variable of that type at the same time. The following is equivalent to the two previous code samples combined:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
} that_guy;&lt;br /&gt;
&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===Accessing the fields===&lt;br /&gt;
Once a variable of a recorded data type was created, you may access its fields with &amp;lt;variable name&amp;gt;.&amp;lt;field name&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
that_guy.name = &amp;quot;Andrew&amp;quot;;&lt;br /&gt;
that_guy.date_of_birth = 08212006;&lt;br /&gt;
that_guy.location_of_birth = $location[Noob Cave];&lt;br /&gt;
&lt;br /&gt;
that_other_guy.name = &amp;quot;Bob&amp;quot;;&lt;br /&gt;
that_other_guy.location_of_birth = $location[South of the Border];&lt;br /&gt;
&lt;br /&gt;
if ( that_other_guy.clothes [ $slot[pants] ] == $item[none] )&lt;br /&gt;
    print( &amp;quot;Put some pants on, &amp;quot; + that_other_guy.name + &amp;quot;!&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Omitting the &amp;quot;model&amp;quot; name===&lt;br /&gt;
When declaring a record, supplying the &amp;quot;model&amp;quot; name (what goes between &amp;quot;record&amp;quot; and the left curly bracket) is not mandatory. If you don&#039;t, the record will be &amp;quot;anonymous&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
An &amp;quot;anonymous&amp;quot; record is like a makeshift bindle; you made it on a whim, it&#039;s unique, it&#039;s yours, you couldn&#039;t replicate it even if you tried, and nobody else wants it.&lt;br /&gt;
&lt;br /&gt;
If you omit data type&#039;s name, you&#039;ll definitely want to supply a variable name after the curly braces, or it will have been a pure waste of time:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record {&lt;br /&gt;
  	int days_spent_travelling;&lt;br /&gt;
	item [int] content;&lt;br /&gt;
} mah_bindle;&lt;br /&gt;
&lt;br /&gt;
mah_bindle.content [0] = $item[ big rock ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===[[New]]===&lt;br /&gt;
[[New]] can be used to assign a whole record at once.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Split_string&amp;diff=5596</id>
		<title>Split string</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Split_string&amp;diff=5596"/>
		<updated>2020-08-21T00:41:43Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|split_string}}{{&lt;br /&gt;
#vardefine:return_type|string [int]}}{{&lt;br /&gt;
#vardefine:aggregate|yes}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|source}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|source}}|&lt;br /&gt;
parameter2={{Param|string|delimiter}}|&lt;br /&gt;
p1desc={{Pspan|source}} is the string to split|&lt;br /&gt;
p2desc={{Pspan|delimiter}} is the (optional) [[Regular Expressions|regular expression]] to split with|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns an array of your {{pspan|source}}, split by either {{pspan|delimiter}} or by line-breaks if not supplied.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=The following example shows how split string can easily convert comma separated strings into useful data.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string items, numbers, total_string;&lt;br /&gt;
int total;&lt;br /&gt;
item thing;&lt;br /&gt;
string[int] split_map;&lt;br /&gt;
numbers = &amp;quot;1, 203, 20002, 450, 194, 92992, 9000, 1&amp;quot;;&lt;br /&gt;
items = &amp;quot;mae west, asshat, hell ramen, bird, batblade&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
split_map = split_string(numbers, &amp;quot;,&amp;quot;);&lt;br /&gt;
print(&amp;quot;You have a total of &amp;quot;+count(split_map)+&amp;quot; numbers.&amp;quot;, &amp;quot;blue&amp;quot;);&lt;br /&gt;
print(&amp;quot;They are the following:&amp;quot;, &amp;quot;blue&amp;quot;);&lt;br /&gt;
foreach it in split_map {&lt;br /&gt;
   print(split_map[it]);&lt;br /&gt;
   total+=to_int(split_map[it]);&lt;br /&gt;
}&lt;br /&gt;
total_string = to_string(total, &amp;quot;%,d&amp;quot;);&lt;br /&gt;
print(&amp;quot;Their total is: &amp;quot;+total_string+&amp;quot;.&amp;quot;, &amp;quot;blue&amp;quot;);&lt;br /&gt;
print(&amp;quot;&amp;quot;);&lt;br /&gt;
//Items&lt;br /&gt;
clear(split_map);&lt;br /&gt;
split_map = split_string(items, &amp;quot;,&amp;quot;);&lt;br /&gt;
print(&amp;quot;You have a total of &amp;quot;+count(split_map)+&amp;quot; items.&amp;quot;, &amp;quot;blue&amp;quot;);&lt;br /&gt;
print(&amp;quot;They are the following:&amp;quot;, &amp;quot;blue&amp;quot;);&lt;br /&gt;
foreach it in split_map {&lt;br /&gt;
   thing = to_item(split_map[it]);&lt;br /&gt;
   if (thing == $item[none])&lt;br /&gt;
      print(split_map[it]+&amp;quot; is not a valid item&amp;quot;, &amp;quot;red&amp;quot;);&lt;br /&gt;
   else&lt;br /&gt;
      print(thing);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=The following example uses KoLMafia&#039;s proxy record of an consumable to return the min-max values of the consumable&#039;s moxie/muscle/mysticality/adventure gains. Using split string, it finds the average of each gain and returns it in a record. |&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record item_range {&lt;br /&gt;
   float mox;&lt;br /&gt;
   float mus;&lt;br /&gt;
   float mys;&lt;br /&gt;
   float adv;&lt;br /&gt;
   item thing;&lt;br /&gt;
};&lt;br /&gt;
item_range stats;&lt;br /&gt;
&lt;br /&gt;
item_range item_avg(item consumable) { //Input food/drink/spleen               &lt;br /&gt;
   item_range attributes;&lt;br /&gt;
   string[int] avgmap;       &lt;br /&gt;
   float realavg;&lt;br /&gt;
   string range_string;&lt;br /&gt;
   attributes.thing = consumable;&lt;br /&gt;
   if (consumable.fullness == 0 &amp;amp;&amp;amp; consumable.inebriety == 0 &amp;amp;&amp;amp; consumable.spleen == 0){&lt;br /&gt;
      print(consumable+&amp;quot; is not a valid consumable.&amp;quot;, &amp;quot;red&amp;quot;);&lt;br /&gt;
      return attributes;&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   //Moxie&lt;br /&gt;
   range_string = consumable.moxie;&lt;br /&gt;
   avgmap = split_string(range_string, &amp;quot;-&amp;quot;);&lt;br /&gt;
   if (count(avgmap) == 1)&lt;br /&gt;
      attributes.mox = to_int(range_string);&lt;br /&gt;
   else {&lt;br /&gt;
      foreach it in avgmap&lt;br /&gt;
         realavg += to_int(avgmap[it]);&lt;br /&gt;
      attributes.mox = (realavg/2);&lt;br /&gt;
   }&lt;br /&gt;
   realavg = 0;&lt;br /&gt;
   clear(avgmap);&lt;br /&gt;
   &lt;br /&gt;
   //Muscle&lt;br /&gt;
   range_string = consumable.muscle;&lt;br /&gt;
   avgmap = split_string(range_string, &amp;quot;-&amp;quot;);&lt;br /&gt;
   if (count(avgmap) == 1)&lt;br /&gt;
      attributes.mus = to_int(range_string);&lt;br /&gt;
   else {&lt;br /&gt;
      foreach it in avgmap&lt;br /&gt;
         realavg += to_int(avgmap[it]);&lt;br /&gt;
      attributes.mus = (realavg/2);&lt;br /&gt;
   }&lt;br /&gt;
   realavg = 0;&lt;br /&gt;
   clear(avgmap);&lt;br /&gt;
   &lt;br /&gt;
   //Mysticality&lt;br /&gt;
   range_string = consumable.mysticality;&lt;br /&gt;
   avgmap = split_string(range_string, &amp;quot;-&amp;quot;);&lt;br /&gt;
   if (count(avgmap) == 1)&lt;br /&gt;
      attributes.mys = to_int(range_string);&lt;br /&gt;
   else {&lt;br /&gt;
      foreach it in avgmap&lt;br /&gt;
         realavg += to_int(avgmap[it]);&lt;br /&gt;
      attributes.mys = (realavg/2);&lt;br /&gt;
   }&lt;br /&gt;
   realavg = 0;&lt;br /&gt;
   clear(avgmap);&lt;br /&gt;
   &lt;br /&gt;
   //Adventures&lt;br /&gt;
   range_string = consumable.adventures;&lt;br /&gt;
   avgmap = split_string(range_string, &amp;quot;-&amp;quot;);&lt;br /&gt;
   if (count(avgmap) == 1)&lt;br /&gt;
      attributes.adv = to_int(range_string);&lt;br /&gt;
   else {&lt;br /&gt;
      foreach it in avgmap&lt;br /&gt;
         realavg += to_int(avgmap[it]);&lt;br /&gt;
      attributes.adv = (realavg/2);&lt;br /&gt;
   }&lt;br /&gt;
   realavg = 0;&lt;br /&gt;
   clear(avgmap);&lt;br /&gt;
return attributes;   &lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
stats = item_avg($item[mae west]);&lt;br /&gt;
print(&amp;quot;Item &amp;quot;+stats.thing+&amp;quot; is a &amp;quot;+item_type(stats.thing)+&amp;quot; which gives the following averages:&amp;quot;, &amp;quot;green&amp;quot;);&lt;br /&gt;
print(&amp;quot;Moxie--&amp;quot;+stats.mox+&amp;quot;, Muscle--&amp;quot;+stats.mus+&amp;quot;, Mysticality--&amp;quot;+stats.mys+&amp;quot;, and Adventures--&amp;quot;+stats.adv+&amp;quot;.&amp;quot;, &amp;quot;blue&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
special=This function technically returns an array, not a map. The information in both is accessed in the same way. However, you cannot add new key-value pairs to an array (its length is static once set).&amp;lt;br&amp;gt;&amp;lt;/p&amp;gt;&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=This also means that the array will always contain at least 1 key (0), even if it was supplied an empty string. As such, using [[count]] on the result is not a fully reliable way to know how many items were in a list.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
print( split_string(&amp;quot;&amp;quot;, &amp;quot;,&amp;quot;).count() );&lt;br /&gt;
print( split_string(&amp;quot;a&amp;quot;, &amp;quot;,&amp;quot;).count() );&lt;br /&gt;
print( split_string(&amp;quot;a,b&amp;quot;, &amp;quot;,&amp;quot;).count() );&lt;br /&gt;
print( split_string(&amp;quot;a,b,c&amp;quot;, &amp;quot;,&amp;quot;).count() );&lt;br /&gt;
print( split_string(&amp;quot;a,b,c,d,e,f,g&amp;quot;, &amp;quot;,&amp;quot;).count() );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=Will return: 1, 1, 2, 3, 7&lt;br /&gt;
}}&amp;lt;p&amp;gt;&lt;br /&gt;
|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:String Handling Routines]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Remove_property&amp;diff=8499</id>
		<title>Remove property</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Remove_property&amp;diff=8499"/>
		<updated>2020-08-20T00:25:22Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: return value&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|remove_property}}{{&lt;br /&gt;
#vardefine:return_type|string}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|prop}}|&lt;br /&gt;
p1desc={{Pspan|prop}} is the property to remove.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|prop}}|&lt;br /&gt;
parameter2={{Param|boolean|global}}|&lt;br /&gt;
p1desc={{Pspan|prop}} is the property to remove.|&lt;br /&gt;
p2desc={{Pspan|global}} if true, look for the property specifically in the global map. If false or not included will look at the user map.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=If {{Pspan|prop}} is a built-in property, resets to default. Otherwise, removes from the user map, or global if {{Pspan|global}} is true.&lt;br /&gt;
&lt;br /&gt;
The return value is the value the property had prior to being reset.|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|Miscellaneous_Functions#Property_Functions}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Miscellaneous Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Miscellaneous_Functions&amp;diff=1197</id>
		<title>Miscellaneous Functions</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Miscellaneous_Functions&amp;diff=1197"/>
		<updated>2020-08-20T00:20:18Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Property Functions */ remove_property return strings&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
== Chat Functions ==&lt;br /&gt;
{{Flink|void|chat_clan|string}}&lt;br /&gt;
{{Flink|void|chat_clan|string|string|desc=Sends a message to clan chat.}}&lt;br /&gt;
{{Flink|void|chat_macro|string|desc=Submits a chat macro to KoL.}}&lt;br /&gt;
{{Flink|void|chat_notify|string|string|desc=Sends a notification to the player&#039;s own chat.}}&lt;br /&gt;
{{Flink|void|chat_private|string|string|desc=Sends a private message to another player.}}&lt;br /&gt;
{{Flink|boolean|is_online|string|desc=Check to see if a player is online.}}&lt;br /&gt;
{{Flink|boolean [string]|who_clan|desc=Returns a list of whom is in your clan and if they are in chat.}}&lt;br /&gt;
{{Flink|boolean|can_faxbot|monster|desc=Check to see if a monster can be faxed.}}&lt;br /&gt;
{{Flink|boolean|faxbot|monster|desc=Attempts to receive a fax of a given monster.}}&lt;br /&gt;
&lt;br /&gt;
== Debugging Functions == &lt;br /&gt;
{{Flink|void|disable|string|desc=Disables the specified function.}}&lt;br /&gt;
{{Flink|void|enable|string|desc=Enables the specified function.}}&lt;br /&gt;
{{Flink|buffer|load_html|string|desc=Works like visit_url(), but for debugging.}}&lt;br /&gt;
{{Flink|string|make_url|string|boolean|boolean|desc=Crafts the URL to visit.}}&lt;br /&gt;
&lt;br /&gt;
== Map Management Functions ==&lt;br /&gt;
&#039;&#039;Note: Information about maps (including creating, assigning, and removing keys, can be found at [[Data Structures#Maps|Map Data Structures]].&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
{{Flink|boolean|file_to_map|string|aggregate|desc=Loads a map from a tab-delimited text file.}}&lt;br /&gt;
{{Flink|boolean|map_to_file|aggregate|string|desc=Saves a map to a tab-delimited text file.}}&lt;br /&gt;
{{Flink|int|count|aggregate|desc=Returns the number of defined keys for the specified aggregate.}}&lt;br /&gt;
{{Flink|void|clear|aggregate|desc=Removes all keys from the specified aggregate.}}&lt;br /&gt;
&lt;br /&gt;
== Time Functions ==&lt;br /&gt;
{{Flink|string|format_date_time|string|string|string|desc=Reformats dates.}}&lt;br /&gt;
{{Flink|int|gameday_to_int|desc=Returns the current KoL date as an integer.}}&lt;br /&gt;
{{Flink|string|gameday_to_string|desc=Returns the current KoL date as a string.}}&lt;br /&gt;
{{Flink|int|gametime_to_int|desc=Returns the current KoL time in ms as an integer.}}&lt;br /&gt;
{{Flink|string|now_to_string|string|desc=Returns current local time/date in SimpleDateFormat format.}}&lt;br /&gt;
{{Flink|string|time_to_string|desc=Returns the current local time in HH:mm:ss z format.}}&lt;br /&gt;
{{Flink|string|today_to_string|desc=Returns the current local day in ISO format.}}&lt;br /&gt;
&lt;br /&gt;
== SVN Functions ==&lt;br /&gt;
&#039;&#039;There is much additional information in the [[SVN Primer]]&#039;&#039;.&lt;br /&gt;
{{Flink|boolean|svn_exists|string|desc=Returns true if a valid working copy named projectname exists in the svn/ folder.}}&lt;br /&gt;
{{Flink|boolean|svn_at_head|string|desc=Returns true if projectname exists, is a valid working copy, and is currently at the same revision number as the repository.}}&lt;br /&gt;
{{Flink|record|svn_info|string|desc=Returns a record containing additional information about the given projectname: svnurl, last author, last revision, last change date.}}&lt;br /&gt;
&lt;br /&gt;
== User Interaction ==&lt;br /&gt;
{{Flink|void|print|string|{{opt|string}}|desc=Prints to CLI and status line of Adventuring window, optionally in a specified color.}}&lt;br /&gt;
{{Flink|void|print_html|string|desc=Prints to CLI, parsing any included html.}}&lt;br /&gt;
{{Flink|void|logprint|string|desc=Prints to the session log.}}&lt;br /&gt;
{{Flink|void|wait|int}}&lt;br /&gt;
{{Flink|void|waitq|int|desc=Sleeps for the specified number of seconds.}}&lt;br /&gt;
{{Flink|boolean|user_confirm|string|desc=Allows user input in Y/N format.}}&lt;br /&gt;
&lt;br /&gt;
== Property Functions ==&lt;br /&gt;
&lt;br /&gt;
{{Flink|boolean [string]|get_all_properties|string|boolean|desc=Returns a map of all user or global properties.}}&lt;br /&gt;
{{Flink|boolean|property_exists|string}}&lt;br /&gt;
{{Flink|boolean|property_exists|string|boolean|desc=Returns true if the named property exists.}}&lt;br /&gt;
{{Flink|boolean|property_has_default|string name|desc=Returns true if the named property in has a default value.}}&lt;br /&gt;
{{Flink|string|property_default_value|string name|desc=Returns the default value for a built-in property.}}&lt;br /&gt;
{{Flink|string|get_property|string}}&lt;br /&gt;
{{Flink|string|get_property|string|boolean|desc=Gets a global or user preference as appropriate.}}&lt;br /&gt;
{{Flink|void|set_property|string|string|desc=Sets a global or user preference as appropriate.}}&lt;br /&gt;
{{Flink|string|remove_property|string}}&lt;br /&gt;
{{Flink|string|remove_property|string|boolean|desc=Removes property or resets it to default.}}&lt;br /&gt;
{{Flink|boolean|rename_property|string|string|desc=Changes name of a property.}}&lt;br /&gt;
&lt;br /&gt;
== Other Functions ==&lt;br /&gt;
{{Flink|void|abort|{{opt|string}}|desc=Aborts the current script with an optional message.}}&lt;br /&gt;
{{Flink|boolean|cli_execute|string|desc=Executes the given command as if it were entered into the CLI.}}&lt;br /&gt;
{{Flink|void|batch_open|desc=Used to mark the beginning of a block of functions to operate in batch mode (see page for {{f|batch_close}} for details).}}&lt;br /&gt;
{{Flink|boolean|batch_close|desc=Used to mark the end of a block of functions to operate in batch mode (see page for details).}}&lt;br /&gt;
{{Flink|int|get_revision|desc=Returns the current KoLmafia revision number.}}&lt;br /&gt;
{{Flink|string|get_version|desc=Returns the most recent KoLmafia version.}}&lt;br /&gt;
{{Flink|string|get_player_id|string|desc=Returns the user id number of a given player.}}&lt;br /&gt;
{{Flink|string|to_json|aggregate|desc=Converts a simple aggregate into JSON.}}&lt;br /&gt;
&lt;br /&gt;
Additional functions that are considered not really to be ash functions are available in [[Miscellaneous ASH Features#Special Syntax Functions|Misc ASH Features]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Insert&amp;diff=6294</id>
		<title>Insert</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Insert&amp;diff=6294"/>
		<updated>2020-08-19T06:37:19Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|insert}}{{&lt;br /&gt;
#vardefine:return_type|buffer}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|buffer|original}}|&lt;br /&gt;
parameter2={{Param|int|strStart}}|&lt;br /&gt;
parameter3={{Param|string|stuff}}|&lt;br /&gt;
p1desc={{Pspan|original}} is the buffer to modify|&lt;br /&gt;
p2desc={{Pspan|strStart}} marks where to insert the string|&lt;br /&gt;
p3desc={{Pspan|stuff}} is the string to insert|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the buffer {{pspan|original}} with the string {{pspan|stuff}} inserted at {{pspan|strStart}}.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Inserts a &amp;quot;Refresh page&amp;quot; link to the Pyramid inside KoL&#039;s default border.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
buffer results;&lt;br /&gt;
results.append(visit_url());&lt;br /&gt;
&lt;br /&gt;
int strEnd = results.index_of(&amp;quot;height=137 border=0&amp;gt;&amp;quot;);&lt;br /&gt;
if(strEnd &amp;gt; 0) {&lt;br /&gt;
   results.insert(strEnd + 20,&amp;quot;&amp;lt;br /&amp;gt;&amp;lt;div align=&#039;center&#039; class=&#039;tiny&#039;&amp;gt;&amp;lt;a href=&#039;pyramid.php&#039;&amp;gt;Refresh page&amp;lt;/a&amp;gt;&amp;lt;/div&amp;gt;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
results.write();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|delete|append|set_length}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:String Handling Routines]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Delete&amp;diff=6287</id>
		<title>Delete</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Delete&amp;diff=6287"/>
		<updated>2020-08-19T06:37:03Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|delete}}{{&lt;br /&gt;
#vardefine:return_type|buffer}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|buffer|original}}|&lt;br /&gt;
parameter2={{Param|int|strStart}}|&lt;br /&gt;
parameter3={{Param|int|strEnd}}|&lt;br /&gt;
p1desc={{Pspan|original}} is the buffer to modify|&lt;br /&gt;
p2desc={{Pspan|strStart}} marks where to start deleting|&lt;br /&gt;
p3desc={{Pspan|strEnd}} marks where to end deleting|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the buffer {{pspan|original}} with the substring from {{pspan|strStart}} to {{pspan|strEnd}} removed.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Removes the border that KoL uses to frame some tables.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
buffer results;&lt;br /&gt;
results.append(visit_url());&lt;br /&gt;
&lt;br /&gt;
string del = &amp;quot; style=\&amp;quot;padding: 5px; border: 1px solid blue;\&amp;quot;&amp;quot;;&lt;br /&gt;
int st = results.index_of(del);&lt;br /&gt;
if ( st &amp;gt; -1 ) results.delete(st, st+length(del));&lt;br /&gt;
else print(&amp;quot;string &#039;&amp;quot;+del+ &amp;quot;&#039; not found&amp;quot;); &lt;br /&gt;
results.write();&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|insert|append|set_length}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:String Handling Routines]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Append&amp;diff=4760</id>
		<title>Append</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Append&amp;diff=4760"/>
		<updated>2020-08-19T06:36:16Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|append}}{{&lt;br /&gt;
#vardefine:return_type|buffer}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|buffer|original}}|&lt;br /&gt;
parameter2={{Param|string|add}}|&lt;br /&gt;
p1desc={{Pspan|original}} is the buffer to add to|&lt;br /&gt;
p2desc={{Pspan|add}} is a string to add on|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns a buffer containing {{pspan|original}} with {{pspan|add}} tacked on to the end.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Print a list of all items currently equipped.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
buffer gear;&lt;br /&gt;
&lt;br /&gt;
foreach slot in $slots[]&lt;br /&gt;
   if(equipped_item(slot) != $item[none]) {&lt;br /&gt;
      if(length(gear) != 0)&lt;br /&gt;
         gear = append(gear, &amp;quot;, &amp;quot;);&lt;br /&gt;
      gear = append(gear, to_string(equipped_item(slot)));&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
print(&amp;quot;I am wearing: &amp;quot;+ gear);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|append_tail|set_length|delete|insert}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:String Handling Routines]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3211</id>
		<title>Data Structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3211"/>
		<updated>2020-08-19T00:02:51Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Assignments */ map-map assignments still needs work&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
KoLmafia supports complex data structures such as maps and records made from simple [[Data Types|data types]].&lt;br /&gt;
&lt;br /&gt;
== Maps ==&lt;br /&gt;
If you are new to programming or find the information below confusing, you may want to read [[Map_Guide | A Noob&#039;s Guide to Maps]] first. &lt;br /&gt;
&lt;br /&gt;
Most of this information was copied directly from ASH Maps Tutorial, by Veracity (http://kolmafia.sourceforge.net/advanced.html#maps)&lt;br /&gt;
&lt;br /&gt;
A map is indexed by one data type (the key) and associates that key with another (or the same) data type (the value). The key can be any ASH simple data type: boolean, int, float, string, item, location, class, stat, skill, effect, familiar, slot, or monster. The value can be any ASH data type at all: a simple type, a record, or can be another map. This effectively allows multi-dimensional maps and. In fact, that&#039;s how the syntax we provide for multi-dimensional maps actually operate: maps of maps of maps ...&lt;br /&gt;
&lt;br /&gt;
You can declare a map any time you can declare a variable: as a top level (global) variable, as a function parameter, or as a local variable in any scope.&lt;br /&gt;
&lt;br /&gt;
You can fetch data from a map any time you can provide a data value: in an expression, as a function parameter, on the right side of an assignment statement, from a &amp;quot;return&amp;quot; statement, as so on. You can pass around entire maps, individual elements, or intermediate maps: &amp;quot;slices&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Declarations ===&lt;br /&gt;
&lt;br /&gt;
The syntax for declaring the data type of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;data type&amp;gt; [ &amp;lt;key type&amp;gt;, ... ] &amp;lt;aggregate_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [item] map1;&lt;br /&gt;
float [class, string, int] another_map;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Assignments ===&lt;br /&gt;
&lt;br /&gt;
==== Assigning individual values ====&lt;br /&gt;
&lt;br /&gt;
If you specify a map and a complete set of indices (of the correct types) on the left side of an assignment statement, you set a single element.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] my_pricelist;&lt;br /&gt;
my_pricelist[ $item[ pail ] ] = 1000;&lt;br /&gt;
my_pricelist[ $item[ bum cheek ] ] = 404;&lt;br /&gt;
my_pricelist[ $item[ red button ] ] = 100;&lt;br /&gt;
my_pricelist[ $item[ red balloon ] ] = 100000;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Aggregate literals ====&lt;br /&gt;
You can declare ready to use, anonymous (single use) maps on the fly, called &#039;&#039;aggregate literals&#039;&#039;, at any time you can provide a data value. They follow the syntax:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{ &amp;lt;key&amp;gt;: &amp;lt;value&amp;gt;, &amp;lt;key&amp;gt;: &amp;lt;value&amp;gt;, &amp;lt;key&amp;gt;: &amp;lt;value&amp;gt; ... }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
An &#039;&#039;aggregate literal&#039;&#039; can be used to initialize an entire aggregate at once.  For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] my_pricelist = {&lt;br /&gt;
  $item[pail]: 1000,&lt;br /&gt;
  $item[bum cheek]: 404,&lt;br /&gt;
  $item[red button]: 100,&lt;br /&gt;
  $item[red balloon]: 100000&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
which achieves the same as what was done in the &#039;Assigning individual values&#039; example.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: when using an aggregate literal for anything else than assignment (e.g. as a return statement, in an expression, or as a function parameter), you need to supply the data types of the aggregate in front of the aggregate literal, even when the expected data types are already known. Example:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item [int] my_function () {&lt;br /&gt;
&lt;br /&gt;
  ...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
  return item [int] {&amp;lt;int&amp;gt;: &amp;lt;item&amp;gt;, &amp;lt;int&amp;gt;: &amp;lt;item&amp;gt;, &amp;lt;int&amp;gt;: &amp;lt;item&amp;gt; ...};&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to make an aggregate literal of a multi-dimensional map. Since multi-dimensional maps are effectively maps of maps (of maps) &#039;&#039;(of maps)&#039;&#039; &#039;&#039;(...)&#039;&#039;, their aggregate literal would be an aggregate literal, inside an aggregate literal &#039;&#039;(inside an aggregate literal)&#039;&#039; (...). Nested aggregate literals.&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item[class, slot] basic_equipments = {&lt;br /&gt;
  $class[Seal Clubber]: {&lt;br /&gt;
    $slot[hat]: $item[seal-skull helmet],&lt;br /&gt;
    $slot[weapon]: $item[seal-clubbing club],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Turtle Tamer]: {&lt;br /&gt;
    $slot[hat]: $item[helmet turtle],&lt;br /&gt;
    $slot[weapon]: $item[turtle totem],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Pastamancer]: {&lt;br /&gt;
    $slot[hat]: $item[ravioli hat],&lt;br /&gt;
    $slot[weapon]: $item[pasta spoon],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Sauceror]: {&lt;br /&gt;
    $slot[hat]: $item[Hollandaise helmet],&lt;br /&gt;
    $slot[weapon]: $item[saucepan],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Disco Bandit]: {&lt;br /&gt;
    $slot[hat]: $item[disco mask],&lt;br /&gt;
    $slot[weapon]: $item[disco ball],&lt;br /&gt;
    $slot[pants]: $item[old sweatpants]&lt;br /&gt;
  },&lt;br /&gt;
  $class[Accordion Thief]: {&lt;br /&gt;
    $slot[hat]: $item[mariachi hat],&lt;br /&gt;
    $slot[weapon]: $item[stolen accordion],&lt;br /&gt;
    $slot[pants]: $item[mariachi pants]&lt;br /&gt;
  }&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Map-map assignments ====&lt;br /&gt;
If you use a map on the left side of an assignment, you set the whole map at once to the new value.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] my_pricelist;&lt;br /&gt;
int [item] new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Some code that updates my_pricelist with new_pricelist */&lt;br /&gt;
&lt;br /&gt;
my_pricelist = new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Now my_pricelist and new_pricelist point to the same aggregate; &lt;br /&gt;
   changes to an element of one of them will be visible in the other */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Slices ====&lt;br /&gt;
If you specify a map and a prefix of indices (of the correct type), you directly set one of the intermediate maps, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float [string, int, string] my_map;&lt;br /&gt;
float [int, string] slice1;&lt;br /&gt;
&lt;br /&gt;
/* Some code that fills my_map[ &amp;quot;slice1&amp;quot; ] with slice1 */&lt;br /&gt;
my_map[ &amp;quot;slice1&amp;quot; ] = slice1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
The syntax for referencing an element (or slice) of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate name&amp;gt;[ &amp;lt;key expression&amp;gt;, ... ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All the key expressions will be evaluated at run time. If you specify all the keys the map expects, you fetch data of the type specified by the map. If you specify fewer keys than the map expects, you get an intermediate map, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
As an example:&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean [string, string] props; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
might be used to hold &amp;quot;properties&amp;quot; associated with names.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;pet&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;mammal&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;pet&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;mammal&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;pet&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;fun&amp;quot; ] = true; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
references:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot;] =&amp;gt; true&lt;br /&gt;
boolean [string] animal = props[ &amp;quot;turtle&amp;quot; ];&lt;br /&gt;
animal[ &amp;quot;fun&amp;quot; ] =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Contains ===&lt;br /&gt;
&lt;br /&gt;
You can test the presence of a key in a map using the &amp;quot;contains&amp;quot; operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate reference expression&amp;gt; contains &amp;lt;key expression&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;aggregate reference expression&amp;gt; must evaluate at run time to a map or slice, and must evaluate at run time to a key of the appropriate type. (Note that that is enforced at parse time; ASH can tell the datatype any expression will produce).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props contains &amp;quot;dog&amp;quot; =&amp;gt; true&lt;br /&gt;
props contains &amp;quot;elephant&amp;quot; =&amp;gt; false&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot; ] contains &amp;quot;fun&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;pet&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;favorite food&amp;quot; =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that only the current slice&#039;s keys are evaluated. This means that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
boolean [ boolean ] [ boolean ] [ boolean ] [ boolean ] [ boolean ] much_truthness;&lt;br /&gt;
much_truthness [ true ] [ true ] [ false ] [ true ] [ true ] = true;&lt;br /&gt;
&lt;br /&gt;
return much_truthness [ true ] [ true ] contains true;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Returned: false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remove ===&lt;br /&gt;
&lt;br /&gt;
You can remove a key-value association from a map using the &amp;quot;remove&amp;quot; unary operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
remove &amp;lt;aggregate reference&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarification, an aggregate reference is &amp;quot;&amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n&amp;gt; ]&amp;quot; where &amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n-1&amp;gt; ] specifies the &amp;quot;slice&amp;quot; and &amp;lt;index n&amp;gt; specifies the &amp;quot;key&amp;quot;. Which is just what you expect, if you fully specify the indices; for a single dimensional map, &amp;quot;map[10]&amp;quot; -&amp;gt; &amp;quot;map&amp;quot; is the slice and 10 is the key. The &amp;quot;remove&amp;quot; operator removes the &amp;quot;key&amp;quot; from the &amp;quot;slice&amp;quot;. For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [int] map1;&lt;br /&gt;
map1[5] = &amp;quot;foo&amp;quot;;&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot; + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot;  + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
int [string, string] map2;&lt;br /&gt;
map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] = 17;&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1 true foo&lt;br /&gt;
remove: foo&lt;br /&gt;
0 false&lt;br /&gt;
remove:&lt;br /&gt;
1 true 17&lt;br /&gt;
remove: 17&lt;br /&gt;
0 false 0&lt;br /&gt;
remove: 0&lt;br /&gt;
1 aggregate int [string]&lt;br /&gt;
remove: aggregate int [string]&lt;br /&gt;
0 aggregate int [string]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Clear ===&lt;br /&gt;
&lt;br /&gt;
You can remove all &amp;lt;code&amp;gt;key =&amp;gt; value&amp;lt;/code&amp;gt; entries from a map using the {{f|clear}} function:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;clear( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Count ===&lt;br /&gt;
&lt;br /&gt;
The {{f|count}} function returns the number of defined keys for the specified aggregate.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;int size = count( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sort ===&lt;br /&gt;
&lt;br /&gt;
From http://kolmafia.us/showthread.php?t=1738 and http://kolmafia.us/showthread.php?10729&lt;br /&gt;
&lt;br /&gt;
The syntax is:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;sort aggregate by keyExpr;&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;aggregate&amp;lt;/code&amp;gt; is a reference to the object to be sorted - arrays are probably the most useful things to sort, but any mapping type can be used.  But please note that when you sort a map, you change the values that correspond to the index. To sort on a map, you would want to use a multidimensional maps, but note that you can only sort along a single dimension at a time when doing this. Simply put... &amp;quot;sort&amp;quot; is only useful in cases where your data exists entirely in the values of the map; the keys can have no meaning beyond simply being distinct.&lt;br /&gt;
&lt;br /&gt;
The reference must not be enclosed in parentheses, as that would look like a call to a function named &amp;lt;code&amp;gt;sort()&amp;lt;/code&amp;gt; - which is still perfectly valid, &amp;quot;sort&amp;quot; has not become a [[Reserved Words|reserved word]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is an arbitrary expression that defines how the items should be ordered. It is evaluated once for every entry in the aggregate, in a scope with two additional variables implicitly defined: &#039;&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;&#039; and &#039;&amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;&#039;, holding the details of that entry. The value of the &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is used as the sort key; typically it would be an &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;, but can be any ASH type that can be compared via &amp;quot;&amp;lt;&amp;quot; and the other relational operators.&lt;br /&gt;
&lt;br /&gt;
The most basic form of sorting would therefore be &amp;quot;&amp;lt;code&amp;gt;sort ... by value&amp;lt;/code&amp;gt;&amp;quot;, but many useful things can be done with the use of a more complex &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; - the only real restriction is that the expression should not modify the object you&#039;re sorting. For example, if you had an array of items, you could sort it &amp;quot;&amp;lt;code&amp;gt;by autosell_price(value)&amp;lt;/code&amp;gt;&amp;quot;. An array of weapon items could be sorted &amp;quot;&amp;lt;code&amp;gt;by -get_power(value)&amp;lt;/code&amp;gt;&amp;quot; to put it in decreasing order of power. If the elements of your aggregate are records, you&#039;d need to use something like &amp;quot;&amp;lt;code&amp;gt;by value.fieldName&amp;lt;/code&amp;gt;&amp;quot;, since the records themselves can&#039;t be meaningfully compared.&lt;br /&gt;
&lt;br /&gt;
After the sort statement, the aggregate will have exactly the same sets of keys and values as before (even if the keys weren&#039;t consecutive), and the iteration order of the keys will be the same, but the values will likely be associated with different keys. The sort is stable - in other words, elements with sort keys that compare as equal will remain in the same order. This means that you can sort on multiple criteria by simply performing separate sorts for each of the criteria, in increasing order of significance.&lt;br /&gt;
&lt;br /&gt;
To find out how many things you have, you might do:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item [int] whatGot;&lt;br /&gt;
int ctr =0;&lt;br /&gt;
&lt;br /&gt;
foreach it in get_inventory() {&lt;br /&gt;
   whatGot[ctr] = it;&lt;br /&gt;
   ctr+=1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sort whatGot by item_amount(value);&lt;br /&gt;
&lt;br /&gt;
foreach x, it in whatGot&lt;br /&gt;
   print(item_amount(it) + &#039; of &#039; + it);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Note that this use of an optional feature of foreach. The second variable in the foreach is the value of whatGot[x].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A few more examples of things you can do:&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -value&amp;lt;/code&amp;gt;&amp;quot; sorts integers in decreasing order (there&#039;s no similar trick for &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; values).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -index&amp;lt;/code&amp;gt;&amp;quot; reverses the existing order of an array (or map with integer keys).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by random(1000000)&amp;lt;/code&amp;gt;&amp;quot; shuffles into a random order.&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by otherArray[index]&amp;lt;/code&amp;gt;&amp;quot; uses values from a parallel array as the sort keys (you&#039;d then need to do &amp;quot;&amp;lt;code&amp;gt;sort otherArray by value;&amp;lt;/code&amp;gt;&amp;quot; if you wanted the two arrays to remain in sync).&lt;br /&gt;
&lt;br /&gt;
===Iteration===&lt;br /&gt;
To iterate through a map, use the &#039;&#039;&#039;foreach&#039;&#039;&#039; operator. For instance, if you wanted to print out how many of each item you had, you could do something like the following:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] map = get_inventory();&lt;br /&gt;
foreach key in map {&lt;br /&gt;
    print(key + &amp;quot; (&amp;quot; + map[key] + &amp;quot;)&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Multidimensional maps are implemented as maps that map keys to maps. &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is really a mapping of items to int[string] maps. Iteration, therefore, is as follows:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
file_to_map(&amp;quot;somefile.txt&amp;quot;, map);&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    print(k1 + &amp;quot;: &amp;quot;);&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        print(&amp;quot;\t&amp;quot; + k2 + &amp;quot;: &amp;quot; + map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Two things to note: First, &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;int[item, string]map&#039;&#039;&#039;. This really comes down to author preference, although the second form is generally more common. Second, the two following foreach loops are equivalent:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        func(map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
foreach k1, k2 in map {&lt;br /&gt;
    func(map[k1][k2]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Of course, the latter does not lend itself to, say, only printing the first key once, whereas the former can be used that way (see the preceding example).&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
Maps in ASH are implemented internally as TreeMaps [http://download.oracle.com/javase/1.5.0/docs/api/java/util/TreeMap.html]. See below for some implications.&lt;br /&gt;
&lt;br /&gt;
== Arrays ==&lt;br /&gt;
These look and behave like mappings of integers to values, where the keys only take values from 0 to n, but these are implemented as Java Arrays.&lt;br /&gt;
&lt;br /&gt;
===Differences between arrays and maps===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [12] array;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use keys 0 - 11. You get a runtime error if you use any other key. It always uses memory to hold 12 items, even if you only use a couple of them. But it&#039;s a constant time - O(1) - to access any element.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [int] map;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use any int as a key. It has constant memory for the Java map, and additional memory for each element in the map, but is O( log n) to access any particular element.&lt;br /&gt;
&lt;br /&gt;
If you are able to use (a fairly densely packed set of) integers as keys, your program will be faster and use (potentially) slightly more memory.&lt;br /&gt;
&lt;br /&gt;
If you have a sparse set of integers, you can still use an array and get fast access, but you will waste a lot of memory.&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t use integers as keys or don&#039;t want to waste memory on a sparse array, you can have a slower but less memory consuming map.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48703&amp;amp;viewfull=1#post48703]&lt;br /&gt;
&lt;br /&gt;
====Time considerations====&lt;br /&gt;
* Given &#039;&#039;&#039;if (a == item1 || a == item2 || a == item3)&#039;&#039;&#039; and &#039;&#039;&#039;if ($items[item1, item2, item3] contains a)&#039;&#039;&#039;, which is faster?&lt;br /&gt;
&lt;br /&gt;
This is going to depend on the number of items in the list, and which one happens to match; if &#039;a&#039; is almost always item1, then the first form is likely to win on practical grounds, even though it&#039;s theoretically slower (O(n) vs. O(log n)).&lt;br /&gt;
&lt;br /&gt;
The second form is a definite win assuming no such coincidences of the item chosen, a somewhat larger set of items, and that the code is executed more than once per run of the script. The first lookup in a plural constant actually builds an internal map that allows such queries to be efficiently done; this is deferred because typical use of a plural constant involves only iteration, not lookups.&lt;br /&gt;
&lt;br /&gt;
There&#039;s always the &amp;quot;profile&amp;quot; command, if you really need to know which is more efficient in a given situation - although it&#039;s unlikely that either would have a noticeable effect on your script&#039;s performance.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48728&amp;amp;viewfull=1#post48728]&lt;br /&gt;
&lt;br /&gt;
== Records ==&lt;br /&gt;
&lt;br /&gt;
(Link to Veracity&#039;s post introducing the record [http://kolmafia.us/showthread.php?t=280])&lt;br /&gt;
&lt;br /&gt;
Records are custom-made data types, that act like compartmentalized boxes [https://i.imgur.com/rgxLKRC.jpg].&lt;br /&gt;
&lt;br /&gt;
They are &amp;quot;variable packages&amp;quot;, that allow you to group together data of any type, including other records, in them.&lt;br /&gt;
&lt;br /&gt;
Records have &amp;quot;models&amp;quot; (the custom data type of the record itself), and names representing them (though not all of them are creative, such as &#039;&#039;&amp;quot;the_black_one_that_I_bought_a_year_ago&amp;quot;&#039;&#039;, or &#039;&#039;&amp;quot;the_one_that_is_over_there_by_the_door&amp;quot;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Each &amp;quot;compartment&amp;quot; (field) also has a name, as well as an expected data type. &#039;&#039;(Stop trying to put screws &amp;quot;there&amp;quot;; that&#039;s my god damn lunchbox, and this is &amp;quot;the spot in which you put the guacamole&amp;quot;!)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a &amp;quot;box&#039;s model&amp;quot; (record&#039;s data type) is declared, it can be used (almost) anywhere that can use a built-in type name (as long as you don&#039;t leave the scope in which the record was declared), such as in functions and other records.&lt;br /&gt;
&lt;br /&gt;
===Declarations===&lt;br /&gt;
The syntax for declaring a new record:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
record &amp;lt;&amp;quot;model&amp;quot; name&amp;gt; { &amp;lt;data type 1&amp;gt; &amp;lt;field name 1&amp;gt;; &amp;lt;data type 2&amp;gt; &amp;lt;field name 2&amp;gt;; ... }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This declared a new data &#039;&#039;&#039;&#039;&#039;type&#039;&#039;&#039;&#039;&#039;, a &#039;&#039;mold&#039;&#039;, a &#039;&#039;blueprint&#039;&#039;... No variable was created here.&lt;br /&gt;
&lt;br /&gt;
To actually &#039;&#039;create&#039;&#039; a variable that &#039;&#039;uses&#039;&#039; this &amp;quot;model&amp;quot;, you would &#039;&#039;&#039;then&#039;&#039;&#039; do:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
human that_guy;&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
You now have 3 &amp;quot;human&amp;quot;s, each with a name, date of birth, location of birth, and clothes (though none of them has had those assigned, yet).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to declare a record and create a variable of that type at the same time. The following is equivalent to the two previous code samples combined:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
} that_guy;&lt;br /&gt;
&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===Accessing the fields===&lt;br /&gt;
Once a variable of a recorded data type was created, you may access its fields with &amp;lt;variable name&amp;gt;.&amp;lt;field name&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
that_guy.name = &amp;quot;Andrew&amp;quot;;&lt;br /&gt;
that_guy.date_of_birth = 08212006;&lt;br /&gt;
that_guy.location_of_birth = $location[Noob Cave];&lt;br /&gt;
&lt;br /&gt;
that_other_guy.name = &amp;quot;Bob&amp;quot;;&lt;br /&gt;
that_other_guy.location_of_birth = $location[South of the Border];&lt;br /&gt;
&lt;br /&gt;
if ( that_other_guy.clothes [ $slot[pants] ] == $item[none] )&lt;br /&gt;
    print( &amp;quot;Put some pants on, &amp;quot; + that_other_guy.name + &amp;quot;!&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Omitting the &amp;quot;model&amp;quot; name===&lt;br /&gt;
When declaring a record, supplying the &amp;quot;model&amp;quot; name (what goes between &amp;quot;record&amp;quot; and the left curly bracket) is not mandatory. If you don&#039;t, the record will be &amp;quot;anonymous&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
An &amp;quot;anonymous&amp;quot; record is like a makeshift bindle; you made it on a whim, it&#039;s unique, it&#039;s yours, you couldn&#039;t replicate it even if you tried, and nobody else wants it.&lt;br /&gt;
&lt;br /&gt;
If you omit data type&#039;s name, you&#039;ll definitely want to supply a variable name after the curly braces, or it will have been a pure waste of time:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record {&lt;br /&gt;
  	int days_spent_travelling;&lt;br /&gt;
	item [int] content;&lt;br /&gt;
} mah_bindle;&lt;br /&gt;
&lt;br /&gt;
mah_bindle.content [0] = $item[ big rock ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===[[New]]===&lt;br /&gt;
[[New]] can be used to assign a whole record at once.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3210</id>
		<title>Data Structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3210"/>
		<updated>2020-08-18T21:47:23Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Contains */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
KoLmafia supports complex data structures such as maps and records made from simple [[Data Types|data types]].&lt;br /&gt;
&lt;br /&gt;
== Maps ==&lt;br /&gt;
If you are new to programming or find the information below confusing, you may want to read [[Map_Guide | A Noob&#039;s Guide to Maps]] first. &lt;br /&gt;
&lt;br /&gt;
Most of this information was copied directly from ASH Maps Tutorial, by Veracity (http://kolmafia.sourceforge.net/advanced.html#maps)&lt;br /&gt;
&lt;br /&gt;
A map is indexed by one data type (the key) and associates that key with another (or the same) data type (the value). The key can be any ASH simple data type: boolean, int, float, string, item, location, class, stat, skill, effect, familiar, slot, or monster. The value can be any ASH data type at all: a simple type, a record, or can be another map. This effectively allows multi-dimensional maps and. In fact, that&#039;s how the syntax we provide for multi-dimensional maps actually operate: maps of maps of maps ...&lt;br /&gt;
&lt;br /&gt;
You can declare a map any time you can declare a variable: as a top level (global) variable, as a function parameter, or as a local variable in any scope.&lt;br /&gt;
&lt;br /&gt;
You can fetch data from a map any time you can provide a data value: in an expression, as a function parameter, on the right side of an assignment statement, from a &amp;quot;return&amp;quot; statement, as so on. You can pass around entire maps, individual elements, or intermediate maps: &amp;quot;slices&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Declarations ===&lt;br /&gt;
&lt;br /&gt;
The syntax for declaring the data type of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;data type&amp;gt; [ &amp;lt;key type&amp;gt;, ... ] &amp;lt;aggregate_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [item] map1;&lt;br /&gt;
float [class, string, int] another_map;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Assignments ===&lt;br /&gt;
&lt;br /&gt;
If you use a map on the left side of an assignment, you set the whole map at once to the new value.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] my_pricelist;&lt;br /&gt;
int [item] new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Some code that updates my_pricelist with new_pricelist */&lt;br /&gt;
&lt;br /&gt;
my_pricelist = new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Now my_pricelist and new_pricelist point to the same aggregate; &lt;br /&gt;
   changes to an element of one of them will be visible in the other */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can initialize an entire aggregate with an &#039;&#039;aggregate literal&#039;&#039;.  For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] my_pricelist = { $item[bum cheek]: 404,&lt;br /&gt;
                           $item[red button]: 100,&lt;br /&gt;
                           $item[red balloon]: 100000 };&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
If you specify a map and a complete set of indices (of the correct types) on the left side of an assignment statement, you set a single element.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] my_pricelist;&lt;br /&gt;
my_pricelist[ $item[ pail ] ] = 1000;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
If you specify a map and a prefix of indices (of the correct type), you directly set one of the intermediate maps, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float [string, int, string] my_map;&lt;br /&gt;
float [int, string] slice1;&lt;br /&gt;
&lt;br /&gt;
/* Some code that fills my_map[ &amp;quot;slice1&amp;quot; ] with slice1 */&lt;br /&gt;
my_map[ &amp;quot;slice1&amp;quot; ] = slice1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
The syntax for referencing an element (or slice) of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate name&amp;gt;[ &amp;lt;key expression&amp;gt;, ... ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All the key expressions will be evaluated at run time. If you specify all the keys the map expects, you fetch data of the type specified by the map. If you specify fewer keys than the map expects, you get an intermediate map, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
As an example:&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean [string, string] props; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
might be used to hold &amp;quot;properties&amp;quot; associated with names.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;pet&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;mammal&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;pet&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;mammal&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;pet&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;fun&amp;quot; ] = true; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
references:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot;] =&amp;gt; true&lt;br /&gt;
boolean [string] animal = props[ &amp;quot;turtle&amp;quot; ];&lt;br /&gt;
animal[ &amp;quot;fun&amp;quot; ] =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Contains ===&lt;br /&gt;
&lt;br /&gt;
You can test the presence of a key in a map using the &amp;quot;contains&amp;quot; operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate reference expression&amp;gt; contains &amp;lt;key expression&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;aggregate reference expression&amp;gt; must evaluate at run time to a map or slice, and must evaluate at run time to a key of the appropriate type. (Note that that is enforced at parse time; ASH can tell the datatype any expression will produce).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props contains &amp;quot;dog&amp;quot; =&amp;gt; true&lt;br /&gt;
props contains &amp;quot;elephant&amp;quot; =&amp;gt; false&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot; ] contains &amp;quot;fun&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;pet&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;favorite food&amp;quot; =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note that only the current slice&#039;s keys are evaluated. This means that:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
boolean [ boolean ] [ boolean ] [ boolean ] [ boolean ] [ boolean ] much_truthness;&lt;br /&gt;
much_truthness [ true ] [ true ] [ false ] [ true ] [ true ] = true;&lt;br /&gt;
&lt;br /&gt;
return much_truthness [ true ] [ true ] contains true;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Returned: false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remove ===&lt;br /&gt;
&lt;br /&gt;
You can remove a key-value association from a map using the &amp;quot;remove&amp;quot; unary operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
remove &amp;lt;aggregate reference&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarification, an aggregate reference is &amp;quot;&amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n&amp;gt; ]&amp;quot; where &amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n-1&amp;gt; ] specifies the &amp;quot;slice&amp;quot; and &amp;lt;index n&amp;gt; specifies the &amp;quot;key&amp;quot;. Which is just what you expect, if you fully specify the indices; for a single dimensional map, &amp;quot;map[10]&amp;quot; -&amp;gt; &amp;quot;map&amp;quot; is the slice and 10 is the key. The &amp;quot;remove&amp;quot; operator removes the &amp;quot;key&amp;quot; from the &amp;quot;slice&amp;quot;. For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [int] map1;&lt;br /&gt;
map1[5] = &amp;quot;foo&amp;quot;;&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot; + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot;  + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
int [string, string] map2;&lt;br /&gt;
map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] = 17;&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1 true foo&lt;br /&gt;
remove: foo&lt;br /&gt;
0 false&lt;br /&gt;
remove:&lt;br /&gt;
1 true 17&lt;br /&gt;
remove: 17&lt;br /&gt;
0 false 0&lt;br /&gt;
remove: 0&lt;br /&gt;
1 aggregate int [string]&lt;br /&gt;
remove: aggregate int [string]&lt;br /&gt;
0 aggregate int [string]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Clear ===&lt;br /&gt;
&lt;br /&gt;
You can remove all &amp;lt;code&amp;gt;key =&amp;gt; value&amp;lt;/code&amp;gt; entries from a map using the {{f|clear}} function:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;clear( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Count ===&lt;br /&gt;
&lt;br /&gt;
The {{f|count}} function returns the number of defined keys for the specified aggregate.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;int size = count( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sort ===&lt;br /&gt;
&lt;br /&gt;
From http://kolmafia.us/showthread.php?t=1738 and http://kolmafia.us/showthread.php?10729&lt;br /&gt;
&lt;br /&gt;
The syntax is:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;sort aggregate by keyExpr;&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;aggregate&amp;lt;/code&amp;gt; is a reference to the object to be sorted - arrays are probably the most useful things to sort, but any mapping type can be used.  But please note that when you sort a map, you change the values that correspond to the index. To sort on a map, you would want to use a multidimensional maps, but note that you can only sort along a single dimension at a time when doing this. Simply put... &amp;quot;sort&amp;quot; is only useful in cases where your data exists entirely in the values of the map; the keys can have no meaning beyond simply being distinct.&lt;br /&gt;
&lt;br /&gt;
The reference must not be enclosed in parentheses, as that would look like a call to a function named &amp;lt;code&amp;gt;sort()&amp;lt;/code&amp;gt; - which is still perfectly valid, &amp;quot;sort&amp;quot; has not become a [[Reserved Words|reserved word]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is an arbitrary expression that defines how the items should be ordered. It is evaluated once for every entry in the aggregate, in a scope with two additional variables implicitly defined: &#039;&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;&#039; and &#039;&amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;&#039;, holding the details of that entry. The value of the &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is used as the sort key; typically it would be an &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;, but can be any ASH type that can be compared via &amp;quot;&amp;lt;&amp;quot; and the other relational operators.&lt;br /&gt;
&lt;br /&gt;
The most basic form of sorting would therefore be &amp;quot;&amp;lt;code&amp;gt;sort ... by value&amp;lt;/code&amp;gt;&amp;quot;, but many useful things can be done with the use of a more complex &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; - the only real restriction is that the expression should not modify the object you&#039;re sorting. For example, if you had an array of items, you could sort it &amp;quot;&amp;lt;code&amp;gt;by autosell_price(value)&amp;lt;/code&amp;gt;&amp;quot;. An array of weapon items could be sorted &amp;quot;&amp;lt;code&amp;gt;by -get_power(value)&amp;lt;/code&amp;gt;&amp;quot; to put it in decreasing order of power. If the elements of your aggregate are records, you&#039;d need to use something like &amp;quot;&amp;lt;code&amp;gt;by value.fieldName&amp;lt;/code&amp;gt;&amp;quot;, since the records themselves can&#039;t be meaningfully compared.&lt;br /&gt;
&lt;br /&gt;
After the sort statement, the aggregate will have exactly the same sets of keys and values as before (even if the keys weren&#039;t consecutive), and the iteration order of the keys will be the same, but the values will likely be associated with different keys. The sort is stable - in other words, elements with sort keys that compare as equal will remain in the same order. This means that you can sort on multiple criteria by simply performing separate sorts for each of the criteria, in increasing order of significance.&lt;br /&gt;
&lt;br /&gt;
To find out how many things you have, you might do:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item [int] whatGot;&lt;br /&gt;
int ctr =0;&lt;br /&gt;
&lt;br /&gt;
foreach it in get_inventory() {&lt;br /&gt;
   whatGot[ctr] = it;&lt;br /&gt;
   ctr+=1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sort whatGot by item_amount(value);&lt;br /&gt;
&lt;br /&gt;
foreach x, it in whatGot&lt;br /&gt;
   print(item_amount(it) + &#039; of &#039; + it);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Note that this use of an optional feature of foreach. The second variable in the foreach is the value of whatGot[x].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A few more examples of things you can do:&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -value&amp;lt;/code&amp;gt;&amp;quot; sorts integers in decreasing order (there&#039;s no similar trick for &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; values).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -index&amp;lt;/code&amp;gt;&amp;quot; reverses the existing order of an array (or map with integer keys).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by random(1000000)&amp;lt;/code&amp;gt;&amp;quot; shuffles into a random order.&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by otherArray[index]&amp;lt;/code&amp;gt;&amp;quot; uses values from a parallel array as the sort keys (you&#039;d then need to do &amp;quot;&amp;lt;code&amp;gt;sort otherArray by value;&amp;lt;/code&amp;gt;&amp;quot; if you wanted the two arrays to remain in sync).&lt;br /&gt;
&lt;br /&gt;
===Iteration===&lt;br /&gt;
To iterate through a map, use the &#039;&#039;&#039;foreach&#039;&#039;&#039; operator. For instance, if you wanted to print out how many of each item you had, you could do something like the following:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] map = get_inventory();&lt;br /&gt;
foreach key in map {&lt;br /&gt;
    print(key + &amp;quot; (&amp;quot; + map[key] + &amp;quot;)&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Multidimensional maps are implemented as maps that map keys to maps. &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is really a mapping of items to int[string] maps. Iteration, therefore, is as follows:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
file_to_map(&amp;quot;somefile.txt&amp;quot;, map);&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    print(k1 + &amp;quot;: &amp;quot;);&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        print(&amp;quot;\t&amp;quot; + k2 + &amp;quot;: &amp;quot; + map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Two things to note: First, &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;int[item, string]map&#039;&#039;&#039;. This really comes down to author preference, although the second form is generally more common. Second, the two following foreach loops are equivalent:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        func(map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
foreach k1, k2 in map {&lt;br /&gt;
    func(map[k1][k2]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Of course, the latter does not lend itself to, say, only printing the first key once, whereas the former can be used that way (see the preceding example).&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
Maps in ASH are implemented internally as TreeMaps [http://download.oracle.com/javase/1.5.0/docs/api/java/util/TreeMap.html]. See below for some implications.&lt;br /&gt;
&lt;br /&gt;
== Arrays ==&lt;br /&gt;
These look and behave like mappings of integers to values, where the keys only take values from 0 to n, but these are implemented as Java Arrays.&lt;br /&gt;
&lt;br /&gt;
===Differences between arrays and maps===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [12] array;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use keys 0 - 11. You get a runtime error if you use any other key. It always uses memory to hold 12 items, even if you only use a couple of them. But it&#039;s a constant time - O(1) - to access any element.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [int] map;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use any int as a key. It has constant memory for the Java map, and additional memory for each element in the map, but is O( log n) to access any particular element.&lt;br /&gt;
&lt;br /&gt;
If you are able to use (a fairly densely packed set of) integers as keys, your program will be faster and use (potentially) slightly more memory.&lt;br /&gt;
&lt;br /&gt;
If you have a sparse set of integers, you can still use an array and get fast access, but you will waste a lot of memory.&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t use integers as keys or don&#039;t want to waste memory on a sparse array, you can have a slower but less memory consuming map.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48703&amp;amp;viewfull=1#post48703]&lt;br /&gt;
&lt;br /&gt;
====Time considerations====&lt;br /&gt;
* Given &#039;&#039;&#039;if (a == item1 || a == item2 || a == item3)&#039;&#039;&#039; and &#039;&#039;&#039;if ($items[item1, item2, item3] contains a)&#039;&#039;&#039;, which is faster?&lt;br /&gt;
&lt;br /&gt;
This is going to depend on the number of items in the list, and which one happens to match; if &#039;a&#039; is almost always item1, then the first form is likely to win on practical grounds, even though it&#039;s theoretically slower (O(n) vs. O(log n)).&lt;br /&gt;
&lt;br /&gt;
The second form is a definite win assuming no such coincidences of the item chosen, a somewhat larger set of items, and that the code is executed more than once per run of the script. The first lookup in a plural constant actually builds an internal map that allows such queries to be efficiently done; this is deferred because typical use of a plural constant involves only iteration, not lookups.&lt;br /&gt;
&lt;br /&gt;
There&#039;s always the &amp;quot;profile&amp;quot; command, if you really need to know which is more efficient in a given situation - although it&#039;s unlikely that either would have a noticeable effect on your script&#039;s performance.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48728&amp;amp;viewfull=1#post48728]&lt;br /&gt;
&lt;br /&gt;
== Records ==&lt;br /&gt;
&lt;br /&gt;
(Link to Veracity&#039;s post introducing the record [http://kolmafia.us/showthread.php?t=280])&lt;br /&gt;
&lt;br /&gt;
Records are custom-made data types, that act like compartmentalized boxes [https://i.imgur.com/rgxLKRC.jpg].&lt;br /&gt;
&lt;br /&gt;
They are &amp;quot;variable packages&amp;quot;, that allow you to group together data of any type, including other records, in them.&lt;br /&gt;
&lt;br /&gt;
Records have &amp;quot;models&amp;quot; (the custom data type of the record itself), and names representing them (though not all of them are creative, such as &#039;&#039;&amp;quot;the_black_one_that_I_bought_a_year_ago&amp;quot;&#039;&#039;, or &#039;&#039;&amp;quot;the_one_that_is_over_there_by_the_door&amp;quot;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Each &amp;quot;compartment&amp;quot; (field) also has a name, as well as an expected data type. &#039;&#039;(Stop trying to put screws &amp;quot;there&amp;quot;; that&#039;s my god damn lunchbox, and this is &amp;quot;the spot in which you put the guacamole&amp;quot;!)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a &amp;quot;box&#039;s model&amp;quot; (record&#039;s data type) is declared, it can be used (almost) anywhere that can use a built-in type name (as long as you don&#039;t leave the scope in which the record was declared), such as in functions and other records.&lt;br /&gt;
&lt;br /&gt;
===Declarations===&lt;br /&gt;
The syntax for declaring a new record:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
record &amp;lt;&amp;quot;model&amp;quot; name&amp;gt; { &amp;lt;data type 1&amp;gt; &amp;lt;field name 1&amp;gt;; &amp;lt;data type 2&amp;gt; &amp;lt;field name 2&amp;gt;; ... }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This declared a new data &#039;&#039;&#039;&#039;&#039;type&#039;&#039;&#039;&#039;&#039;, a &#039;&#039;mold&#039;&#039;, a &#039;&#039;blueprint&#039;&#039;... No variable was created here.&lt;br /&gt;
&lt;br /&gt;
To actually &#039;&#039;create&#039;&#039; a variable that &#039;&#039;uses&#039;&#039; this &amp;quot;model&amp;quot;, you would &#039;&#039;&#039;then&#039;&#039;&#039; do:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
human that_guy;&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
You now have 3 &amp;quot;human&amp;quot;s, each with a name, date of birth, location of birth, and clothes (though none of them has had those assigned, yet).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to declare a record and create a variable of that type at the same time. The following is equivalent to the two previous code samples combined:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
} that_guy;&lt;br /&gt;
&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===Accessing the fields===&lt;br /&gt;
Once a variable of a recorded data type was created, you may access its fields with &amp;lt;variable name&amp;gt;.&amp;lt;field name&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
that_guy.name = &amp;quot;Andrew&amp;quot;;&lt;br /&gt;
that_guy.date_of_birth = 08212006;&lt;br /&gt;
that_guy.location_of_birth = $location[Noob Cave];&lt;br /&gt;
&lt;br /&gt;
that_other_guy.name = &amp;quot;Bob&amp;quot;;&lt;br /&gt;
that_other_guy.location_of_birth = $location[South of the Border];&lt;br /&gt;
&lt;br /&gt;
if ( that_other_guy.clothes [ $slot[pants] ] == $item[none] )&lt;br /&gt;
    print( &amp;quot;Put some pants on, &amp;quot; + that_other_guy.name + &amp;quot;!&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Omitting the &amp;quot;model&amp;quot; name===&lt;br /&gt;
When declaring a record, supplying the &amp;quot;model&amp;quot; name (what goes between &amp;quot;record&amp;quot; and the left curly bracket) is not mandatory. If you don&#039;t, the record will be &amp;quot;anonymous&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
An &amp;quot;anonymous&amp;quot; record is like a makeshift bindle; you made it on a whim, it&#039;s unique, it&#039;s yours, you couldn&#039;t replicate it even if you tried, and nobody else wants it.&lt;br /&gt;
&lt;br /&gt;
If you omit data type&#039;s name, you&#039;ll definitely want to supply a variable name after the curly braces, or it will have been a pure waste of time:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record {&lt;br /&gt;
  	int days_spent_travelling;&lt;br /&gt;
	item [int] content;&lt;br /&gt;
} mah_bindle;&lt;br /&gt;
&lt;br /&gt;
mah_bindle.content [0] = $item[ big rock ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===[[New]]===&lt;br /&gt;
[[New]] can be used to assign a whole record at once.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Relay_Override_Scripting&amp;diff=5921</id>
		<title>Relay Override Scripting</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Relay_Override_Scripting&amp;diff=5921"/>
		<updated>2020-08-14T22:35:38Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: :|&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
A relay script is a script that creates or modifies a web page in the relay browser. It is only in the relay browser that the effects of these scripts can be seen. There are two different kinds of relay override scripts. The first is simply known as a Relay Script. The second is an User Interface script.&lt;br /&gt;
&lt;br /&gt;
==Relay Script==&lt;br /&gt;
Basic relay scripts are used to change the appearance of a KoL page. You will find many examples of relay scripts that you may download from the [http://kolmafia.us/forumdisplay.php?16-Relay-Override-Scripts KoLmafia Forums] to your /relay directory.&lt;br /&gt;
&lt;br /&gt;
===Writing a Relay Script===&lt;br /&gt;
For a simple Relay Script, there are several basic rules:&lt;br /&gt;
#The name of the script must be the same as the page it is overriding, except with an ash extension instead of a php extension. For users who have enabled relay override scripts, mafia will automatically call xyz.ash every time the relay browser attempts to visit xyz.php.&lt;br /&gt;
#Unless the script will display entirely new content, it should first load the unmodified page from KoL using the command [[visit_url|visit_url()]] with no parameters.&lt;br /&gt;
#Then the contents of the page can be modified with [[replace_string|replace_string()]] or other string manipulation functions.&lt;br /&gt;
#Finally, the modified page is written with the [[write|write()]] command.&lt;br /&gt;
&lt;br /&gt;
===Whichplace, Whichshop and Whichstore Overrides===&lt;br /&gt;
For overrides to place.php, shop.php and store.php it is possible to override based on the whichplace, whichshop and whichstore parameters. This is quite helpful so that you can choose to override only specific places and shops without needing to make an override for all of them.&lt;br /&gt;
&lt;br /&gt;
An example is that to override the plains, you&#039;ll note that the URL is &amp;lt;code&amp;gt; place.php?whichplace=plains &amp;lt;/code&amp;gt; so you could override all place.php pages with a place.ash override, or you could choose to override only the plains with a script named place.plains.ash. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Example of Relay Override===&lt;br /&gt;
Here is an example of a relay script.  Assuming it is named shop.shore.ash, it will modify &amp;quot;The Shore, Inc.&amp;quot; Shop at &amp;lt;code&amp;gt; shop.php?whichshop=shore.php &amp;lt;/code&amp;gt; to reveal items that are needed for the level 6 tower monster.&lt;br /&gt;
&amp;lt;div style=&amp;quot;margin-bottom: 1em; border: dashed 1px green; padding: 1em; margin:0px 20px;&amp;quot;&amp;gt;&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
// This script will only work if it is named shop.shore.ash&lt;br /&gt;
buffer telescope(buffer page) {&lt;br /&gt;
   &lt;br /&gt;
   void dynamite() {&lt;br /&gt;
      if(available_amount($item[stick of dynamite]) &amp;lt; 1) page.replace_string(&amp;quot;&amp;lt;b&amp;gt;dude ranch souvenir crate&amp;lt;/b&amp;gt;&amp;quot;,&lt;br /&gt;
         &amp;quot;&amp;lt;font color=\&amp;quot;green\&amp;quot;&amp;gt;&amp;lt;b&amp;gt;dude ranch souvenir crate&amp;lt;br /&amp;gt;(stick of dynamite needed)&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   void orchid() {&lt;br /&gt;
      if(available_amount($item[tropical orchid]) &amp;lt; 1 &amp;amp;&amp;amp; available_amount($item[packet of orchid seeds]) &amp;lt; 1) page.replace_string(&amp;quot;&amp;lt;b&amp;gt;tropical island souvenir crate&amp;lt;/b&amp;gt;&amp;quot;,&lt;br /&gt;
         &amp;quot;&amp;lt;font color=\&amp;quot;green\&amp;quot;&amp;gt;&amp;lt;b&amp;gt;tropical island souvenir crate&amp;lt;br /&amp;gt;(tropical orchid needed)&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
&lt;br /&gt;
   void fence() {&lt;br /&gt;
      if(available_amount($item[barbed-wire fence]) &amp;lt; 1) page.replace_string(&amp;quot;&amp;lt;b&amp;gt;ski resort souvenir crate&amp;lt;/b&amp;gt;&amp;quot;,&lt;br /&gt;
         &amp;quot;&amp;lt;font color=\&amp;quot;green\&amp;quot;&amp;gt;&amp;lt;b&amp;gt;ski resort souvenir crate&amp;lt;br /&amp;gt;(barbed-wire fence needed)&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   if(!can_interact() &amp;amp;&amp;amp; my_path() != &amp;quot;Bugbear Invasion&amp;quot;) {&lt;br /&gt;
      if(my_path() == &amp;quot;Bees Hate You&amp;quot;) {&lt;br /&gt;
         orchid();&lt;br /&gt;
      } else if(get_property(&amp;quot;telescopeUpgrades&amp;quot;) == &amp;quot;7&amp;quot; &amp;amp;&amp;amp; !in_bad_moon()) {&lt;br /&gt;
         switch(get_property(&amp;quot;telescope7&amp;quot;)) {&lt;br /&gt;
         case &amp;quot;see a wooden beam&amp;quot;:&lt;br /&gt;
            dynamite(); break;&lt;br /&gt;
         case &amp;quot;see a formidable stinger&amp;quot;:&lt;br /&gt;
            orchid(); break;&lt;br /&gt;
         case &amp;quot;see a pair of horns&amp;quot;:&lt;br /&gt;
            fence(); break;&lt;br /&gt;
         }&lt;br /&gt;
      } else {&lt;br /&gt;
         dynamite();&lt;br /&gt;
         orchid();&lt;br /&gt;
         fence();&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   &lt;br /&gt;
   // If dinghy plans are needed, you will always need to buy them! Otherwise it is time to look into that UV-resistant compass &lt;br /&gt;
   if(get_property(&amp;quot;lastIslandUnlock&amp;quot;).to_int() &amp;lt; my_ascensions() &amp;amp;&amp;amp; page.contains_text(&amp;quot;dinghy plans&amp;quot;))&lt;br /&gt;
      page.replace_string(&amp;quot;&amp;lt;b&amp;gt;dinghy plans&amp;lt;/b&amp;gt;&amp;quot;, &amp;quot;&amp;lt;font color=\&amp;quot;green\&amp;quot;&amp;gt;&amp;lt;b&amp;gt;dinghy plans&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;quot;);&lt;br /&gt;
   else if(available_amount($item[UV-resistant compass]) + available_amount($item[ornate dowsing rod]) == 0)&lt;br /&gt;
      page.replace_string(&amp;quot;UV-resistant compass&amp;quot;, &amp;quot;&amp;lt;font color=\&amp;quot;green\&amp;quot;&amp;gt;&amp;lt;b&amp;gt;UV-resistant compass&amp;lt;/b&amp;gt;&amp;lt;/font&amp;gt;&amp;quot;);&lt;br /&gt;
   &lt;br /&gt;
   return page;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void main() {&lt;br /&gt;
   visit_url().telescope().ShopWTF().write();&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==User Interface Script==&lt;br /&gt;
&lt;br /&gt;
There are special kinds of relay scripts; scripts with user interfaces. As with a regular relay override script, they go in the &amp;quot;relay&amp;quot; directory. However, they don&#039;t override other pages; their entire content is created from scratch. These scripts can be accessed under the relay drop-down in the bottom-right of the top pane. Their names must start with &amp;quot;relay_&amp;quot; in order for them to show up there.&lt;br /&gt;
&lt;br /&gt;
This can provide a pretty interface and automate tasks, but relay scripts aren&#039;t really suitable for long, ongoing processes such as autoadventuring, since nothing appears in the browser until the script exits. Also, writing them requires a rather different mindset than the sequential execution of a normal script: if the relay script presents options for the user, they are actually read by an entirely separate invocation of the script than the one that displayed the options. The areas in which relay scripts will be the most useful are user-friendly configuration of other scripts, and presentation of options for the user to carry out in the relay browser themselves since the script can simply link to any in-game activity.&lt;br /&gt;
&lt;br /&gt;
===Writing an Interface Script===&lt;br /&gt;
For writing interface scripts, several features were added to KoLmafia.&lt;br /&gt;
* ASH predefined string constant __FILE__, which is the filename of the current script. This allows relay scripts to link or submit a form to themselves, even if the user has renamed them.&lt;br /&gt;
* ASH function [[form_fields|form_fields()]], which returns a string[string] map with all the name/value pairs from the relay request being handled.&lt;br /&gt;
* ASH string functions [[entity_encode|entity_encode()]] and [[entity_decode|entity_decode()]], for converting text that might contain special characters such as ampersands and angle brackets so that it can safely be displayed in HTML, and retrieving such text from form fields.&lt;br /&gt;
&lt;br /&gt;
Additionally, there are some excellent tools for writing form elements in interface scripts on the [http://kolmafia.us/showthread.php?3842-Form-of...HTML KoLmafia Forum]. That script is a toolbox of essential functions for any advanced interface script so make good use of it.&lt;br /&gt;
&lt;br /&gt;
===Example of User Interface===&lt;br /&gt;
Here is an example of a User Interface script. This must be saved in /relay with a name starting with relay, such as &#039;&#039;&#039;relay_breakables.ash&#039;&#039;&#039; to appear in the relay drop-down in KoL&#039;s top menu. This was originally presented by Jason Harper [http://kolmafia.us/showthread.php?3769-Breakable-equipment-fine-tuning here] and makes an excellent example.&lt;br /&gt;
&amp;lt;div style=&amp;quot;margin-bottom: 1em; font-size: 12px; border: dashed 1px green; padding: 1em; margin:0px 20px;&amp;quot;&amp;gt;&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
// The following constant can be edited to add more breakable items. &lt;br /&gt;
// However, please note that adding items here does no good at all&lt;br /&gt;
// unless KoLmafia has been updated to recognize the specific breakage&lt;br /&gt;
// messages of those items.&lt;br /&gt;
boolean[item] breakable = $items[&lt;br /&gt;
   antique helmet, antique spear, antique shield, antique greaves,&lt;br /&gt;
   cyber-mattock, cheap studded belt,&lt;br /&gt;
   sugar chapeau, sugar shank, sugar shield, sugar shillelagh,&lt;br /&gt;
   sugar shirt, sugar shotgun, sugar shorts];&lt;br /&gt;
&lt;br /&gt;
void write_option(string label, string value, string current) {&lt;br /&gt;
   write(&amp;quot;&amp;lt;option value=&#039;&amp;quot;);&lt;br /&gt;
   write(value);&lt;br /&gt;
   write(&amp;quot;&#039;&amp;quot;);&lt;br /&gt;
   if (value == current)&lt;br /&gt;
      write(&amp;quot; selected&amp;quot;);&lt;br /&gt;
   write(&amp;quot;&amp;gt;&amp;quot;);&lt;br /&gt;
   write(entity_encode(label));&lt;br /&gt;
   writeln(&amp;quot;&amp;lt;/option&amp;gt;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
void write_select(string label, string pref, boolean addDefault, string[string] fields) {&lt;br /&gt;
   if (fields contains pref)&lt;br /&gt;
      set_property(pref, fields[pref]);&lt;br /&gt;
   &lt;br /&gt;
   string current = get_property(pref);&lt;br /&gt;
   write(&amp;quot;&amp;lt;tr&amp;gt;&amp;lt;td align=right&amp;gt;&amp;quot;);&lt;br /&gt;
   write(label);&lt;br /&gt;
   write(&amp;quot;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;select name=&#039;&amp;quot;);&lt;br /&gt;
   write(pref);&lt;br /&gt;
   writeln(&amp;quot;&#039;&amp;gt;&amp;quot;);&lt;br /&gt;
   &lt;br /&gt;
   if (addDefault)&lt;br /&gt;
      write_option(&amp;quot;Use default&amp;quot;, &amp;quot;&amp;quot;, current);&lt;br /&gt;
   write_option(&amp;quot;Abort on breakage&amp;quot;, &amp;quot;1&amp;quot;, current);&lt;br /&gt;
   write_option(&amp;quot;Equip previous item&amp;quot;, &amp;quot;2&amp;quot;, current);&lt;br /&gt;
   write_option(&amp;quot;Re-equip from inventory (if available), or abort&amp;quot;, &amp;quot;3&amp;quot;, current);&lt;br /&gt;
   write_option(&amp;quot;Re-equip from inventory, or equip previous item&amp;quot;, &amp;quot;4&amp;quot;, current);&lt;br /&gt;
   write_option(&amp;quot;Acquire new item &amp;amp; re-equip&amp;quot;, &amp;quot;5&amp;quot;, current);&lt;br /&gt;
   writeln(&amp;quot;&amp;lt;/select&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
   &lt;br /&gt;
void main() {&lt;br /&gt;
   write(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;body&amp;gt;&amp;lt;form method=POST action=&#039;&amp;quot;);&lt;br /&gt;
   write(__FILE__);&lt;br /&gt;
   writeln(&amp;quot;&#039;&amp;gt;&amp;quot;);&lt;br /&gt;
   write(&amp;quot;Breakable equipment fine tuning v1.0, by jasonharper@pobox.com&amp;quot;);&lt;br /&gt;
   writeln(&amp;quot; (in-game: &amp;lt;a href=&#039;sendmessage.php?toid=363053&#039;&amp;gt;Seventh&amp;lt;/a&amp;gt;)&amp;quot;);&lt;br /&gt;
   write(&amp;quot;&amp;lt;p&amp;gt;&amp;quot;);&lt;br /&gt;
   write(&amp;quot;This script lets you override the default behavior when equipment breaks in combat,&amp;quot;);&lt;br /&gt;
   write(&amp;quot; on an item-by-item basis.  The default setting (found in the Item section of Choice Advs)&amp;quot;);&lt;br /&gt;
   writeln(&amp;quot; is duplicated here for your convenience.&amp;quot;);&lt;br /&gt;
   writeln(&amp;quot;&amp;lt;table border=0&amp;gt;&amp;quot;);&lt;br /&gt;
   string[string] fields = form_fields();&lt;br /&gt;
   write_select(&amp;quot;Default&amp;quot;, &amp;quot;breakableHandling&amp;quot;, false, fields);&lt;br /&gt;
   foreach itm in breakable&lt;br /&gt;
      write_select(to_string(itm), &amp;quot;breakableHandling&amp;quot; + to_int(itm), true, fields);&lt;br /&gt;
   writeln(&amp;quot;&amp;lt;/table&amp;gt;&amp;quot;);&lt;br /&gt;
   writeln(&amp;quot;&amp;lt;input type=submit value=&#039;Save changes&#039;&amp;gt;&amp;quot;);&lt;br /&gt;
   writeln(&amp;quot;&amp;lt;/form&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Advance Techniques for Interface Scripting===&lt;br /&gt;
Adding CSS Styles:&lt;br /&gt;
*To have a fancier Relay Script, one can add CSS styles to certain elements.  Example of this can be found Bale’s OCD Manager Relay script. &lt;br /&gt;
&lt;br /&gt;
Tools: &lt;br /&gt;
*[http://www.quackit.com/ Quackit] has a lot of basic info on HTML/CSS/etc. It also has a decent [http://www.quackit.com/html/online-html-editor/full/ WYSIWYG editor] for basic styling and layouts. &lt;br /&gt;
*[http://jsfiddle.net/ JSFiddle] allows you to enter HTML, CSS, and java script and run it all to see what it creates. It also has a handy “TidyUP” feature which will auto-indent HTML and will highlight HTML tags in red if they are improper which is great for debugging. &lt;br /&gt;
*[http://www.css-generators.com/#Markup CSS Generator] Offers quick CSS for buttons/paragraphs/tables/etc for more advance styling options.&lt;br /&gt;
*[http://www.csstablegenerator.com/ CSS Table Generator] is an excellent resource for CSS Tables designs.&lt;br /&gt;
*[http://www.regexplanet.com/advanced/java/index.html RegexPlanet] is a handy tool to convert CSS/HTML into a Java string. After writing/generating HTML/CSS for your relay script, it can be a pain to “convert” it all by hand into text that will work well within the .ash Relay Script. Instead, you can copy/paste it all into Regexplannet as a Regular Expression. After clicking Test, it will throw up some error (obviously), but will still convert it all into a Java string, which is what you want. Copy paste “as a Java string” into your relay script, after a page.append, and you should be good to go. You can then break it up for easier reading, but it is not necessary. &lt;br /&gt;
&lt;br /&gt;
===Example of Using CSS in a User Interface Script===&lt;br /&gt;
Note: Instead of using the function write, the example will use a buffer called page which everything will be appended too.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Note 2: Example also shows why it is a good practice to use \&amp;quot; instead of single quotes when typing HTML. Using \” will prevent values containing a single quote from messing up. &lt;br /&gt;
&amp;lt;div style=&amp;quot;margin-bottom: 1em; font-size: 12px; border: dashed 1px green; padding: 1em; margin:0px 20px;&amp;quot;&amp;gt;&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
////////// Beginning of form functions based strongly on jasonharper&#039;s htmlform.ash from http://kolmafia.us/showthread.php?3842&lt;br /&gt;
string[string] fields;	// shared result from form_fields()&lt;br /&gt;
boolean success;	// form successfully submitted&lt;br /&gt;
buffer page;&lt;br /&gt;
&lt;br /&gt;
boolean test_button(string name) {&lt;br /&gt;
	if(name == &amp;quot;&amp;quot;)	return false;&lt;br /&gt;
	return success &amp;amp;&amp;amp; fields contains name;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//This Example shows what it is a bad idea to use single quotes instead of full quotes for values&lt;br /&gt;
boolean write_button_Example(string name, string label) {&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;input type=\&amp;quot;submit\&amp;quot; name=\&amp;quot;&amp;quot;+name+&amp;quot;\&amp;quot; value=&#039;&amp;quot;+label+&amp;quot;&#039;/&amp;gt;&amp;quot;);&lt;br /&gt;
	return test_button(name);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Jason&#039;s Button re-written to use page.append instead of write&lt;br /&gt;
boolean write_button(string name, string label) {&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;input type=\&amp;quot;submit\&amp;quot; name=\&amp;quot;&amp;quot;+name+&amp;quot;\&amp;quot; value=\&amp;quot;&amp;quot;+label+&amp;quot;\&amp;quot;/&amp;gt;&amp;quot;);&lt;br /&gt;
	return test_button(name);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//Added a class to the button, designating a class will allow all buttons of that class to be changed by that class&#039;s CSS&lt;br /&gt;
boolean write_button2(string name, string label, string css_class) {&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;input type=\&amp;quot;submit\&amp;quot; name=\&amp;quot;&amp;quot;+name+&amp;quot;\&amp;quot; class=\&amp;quot;&amp;quot;+css_class+&amp;quot;\&amp;quot; value=\&amp;quot;&amp;quot;+label+&amp;quot;\&amp;quot;/&amp;gt;&amp;quot;);&lt;br /&gt;
	return test_button(name);&lt;br /&gt;
}&lt;br /&gt;
boolean write_button2(string name, string label) {return write_button2(name, label, &amp;quot;&amp;quot;);}&lt;br /&gt;
////////// End of jasonharper&#039;s htmlform.ash&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
void styles() { //Function that contains all CSS&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;style type=&#039;text/css&#039;&amp;gt;&amp;quot;+&lt;br /&gt;
	//Shiny button CSS, turned into a convenient Java String. Note: For the purpose of Wiki formatting, it was broken up into segments. However, it could have been left as one long string.&lt;br /&gt;
	&amp;quot;.shiny{ cursor:pointer; border-width:4px; border-style:solid; border-color:#000000; -webkit-border-radius: 18px; -moz-border-radius: 18px; border-radius: 18px; text-align:center;&amp;quot;+&lt;br /&gt;
        &amp;quot;height:40px; padding-top:undefinedpx; padding-bottom:undefinedpx; font-size:15px; font-family:arial; color:#ffffff;&amp;quot;+&lt;br /&gt;
        &amp;quot;background:#2d10bc; display:inline-block; }.shiny:hover{ background:#e85b4c; }&amp;quot;+&lt;br /&gt;
	&amp;quot;&amp;lt;/style&amp;gt;&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
/*CSS For Shiny Button, before it was put into regexplanet as a regular expression, was generated using the &amp;quot;CSS Generator&amp;quot; listed above.&lt;br /&gt;
.shiny{&lt;br /&gt;
 cursor:pointer;&lt;br /&gt;
 border-width:4px;&lt;br /&gt;
 border-style:solid;&lt;br /&gt;
 border-color:#000000;&lt;br /&gt;
 -webkit-border-radius: 18px;&lt;br /&gt;
 -moz-border-radius: 18px;&lt;br /&gt;
 border-radius: 18px;&lt;br /&gt;
 text-align:center;&lt;br /&gt;
 width:100px; //Delete the width so it isn&#039;t fixed&lt;br /&gt;
 height:40px;&lt;br /&gt;
 padding-top:undefinedpx;&lt;br /&gt;
 padding-bottom:undefinedpx;&lt;br /&gt;
 font-size:15px;&lt;br /&gt;
 font-family:arial;&lt;br /&gt;
 color:#ffffff;&lt;br /&gt;
 background:#2d10bc;&lt;br /&gt;
 display:inline-block;&lt;br /&gt;
 }.shiny:hover{&lt;br /&gt;
 background:#e85b4c;&lt;br /&gt;
 }&lt;br /&gt;
 */&lt;br /&gt;
	&lt;br /&gt;
	&lt;br /&gt;
void main() {&lt;br /&gt;
	fields = form_fields();&lt;br /&gt;
	success = count(fields) &amp;gt; 0;&lt;br /&gt;
	&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;html&amp;gt;&amp;lt;head&amp;gt;&amp;quot;); // write_page()&lt;br /&gt;
	styles();&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;/head&amp;gt;&amp;lt;body&amp;gt;&amp;lt;form name=&#039;relayform&#039; method=&#039;POST&#039; action=&#039;&#039;&amp;gt;&amp;quot;);&lt;br /&gt;
	write_button_Example(&amp;quot;test&amp;quot;, &amp;quot;John&#039;s Button&amp;quot;); //Will generate a button with just &amp;quot;John&amp;quot; as it uses single quotes in the label instead of \&amp;quot;&lt;br /&gt;
	write_button(&amp;quot;test2&amp;quot;, &amp;quot;John&#039;s Button&amp;quot;);&lt;br /&gt;
	write_button2(&amp;quot;test3&amp;quot;, &amp;quot;John&#039;s Super Button&amp;quot;, &amp;quot;shiny&amp;quot;);&lt;br /&gt;
	write_button2(&amp;quot;test4&amp;quot;, &amp;quot;John&#039;s not so super button&amp;quot;);&lt;br /&gt;
	write_button2(&amp;quot;test5&amp;quot;, &amp;quot;John&#039;s super awesome shiny button again&amp;quot;, &amp;quot;shiny&amp;quot;);&lt;br /&gt;
	page.append(&amp;quot;&amp;lt;/form&amp;gt;&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;&amp;quot;); 	// finish_page()&lt;br /&gt;
	writeln(page);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Additional CSS Styling Ideas and Jason&#039;s functions using page.append can be found in [http://kolmafia.us/showthread.php?1818-OCD-Inventory-control Bale&#039;s OCD Relay Script] and [http://kolmafia.us/showthread.php?17230-EoD-SC-Ascension-Checklist-Handler EoD&#039;s Ascension Checklist Relay Script].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Item&amp;diff=1758</id>
		<title>Item</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Item&amp;diff=1758"/>
		<updated>2020-08-14T04:45:31Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Proxy Record Fields */ proxy record: name&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:item}}&lt;br /&gt;
&lt;br /&gt;
{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
This datatype represents any item in all of KoL. Note that unlike most special datatypes, &lt;br /&gt;
item references can make use of the item ID number.&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=For example, you could assign the item plexiglass pants as follows:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item it = $item[ 1234 ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The full range, besides $item[ none ], is too much to list and keep up with here. &lt;br /&gt;
Please see the Wiki {{kolwiki|Items}} page for more item information.&lt;br /&gt;
&lt;br /&gt;
==Related Functions==&lt;br /&gt;
&lt;br /&gt;
{{Flink|void|add_item_condition|int|item}}&lt;br /&gt;
{{Flink|boolean|autosell|int|item}}&lt;br /&gt;
{{Flink|int|autosell_price|item}}&lt;br /&gt;
{{Flink|int|available_amount|item}}&lt;br /&gt;
{{Flink|boolean|boolean_modifier|item|string}}&lt;br /&gt;
{{Flink|boolean|buy|{{opt|coinmaster}}|int|item}}&lt;br /&gt;
{{Flink|int|buy|int|item|int}}&lt;br /&gt;
{{Flink|int|buy_price|coinmaster|item}}&lt;br /&gt;
{{Flink|boolean|buy_using_storage|int|item}}&lt;br /&gt;
{{Flink|int|buy_using_storage|int|item|int}}&lt;br /&gt;
{{Flink|boolean|buys_item|coinmaster|item}}&lt;br /&gt;
{{Flink|boolean|can_equip|item}}&lt;br /&gt;
{{Flink|boolean|chew|int|item}}&lt;br /&gt;
{{Flink|class|class_modifier|item|string}}&lt;br /&gt;
{{Flink|int|closet_amount|item}}&lt;br /&gt;
{{Flink|boolean|craft|string|int|item|item}}&lt;br /&gt;
{{Flink|string|craft_type|item}}&lt;br /&gt;
{{Flink|int|creatable_amount|item}}&lt;br /&gt;
{{Flink|int|creatable_turns|{{opt|item}}|{{opt|int}}|{{opt|boolean}}}}&lt;br /&gt;
{{Flink|boolean|create|int|item}}&lt;br /&gt;
{{Flink|item|daily_special}}&lt;br /&gt;
{{Flink|int|display_amount|item}}&lt;br /&gt;
{{Flink|boolean|drink|int|item}}&lt;br /&gt;
{{Flink|boolean|eat|int|item}}&lt;br /&gt;
{{Flink|boolean|eatsilent|int|item}}&lt;br /&gt;
{{Flink|effect|effect_modifier|item|string}}&lt;br /&gt;
{{Flink|boolean|equip|{{opt|slot}}|item}}&lt;br /&gt;
{{Flink|int|equipped_amount|item}}&lt;br /&gt;
{{Flink|item|equipped_item|slot}}&lt;br /&gt;
{{Flink|int [item]|extract_items|string}}&lt;br /&gt;
{{Flink|item|familiar_equipment|familiar}}&lt;br /&gt;
{{Flink|item|familiar_equipped_equipment|familiar}}&lt;br /&gt;
{{Flink|int [item]|get_campground}}&lt;br /&gt;
{{Flink|int [item]|get_chateau}}&lt;br /&gt;
{{Flink|int [item]|get_clan_lounge}}&lt;br /&gt;
{{Flink|item|get_dwelling}}&lt;br /&gt;
{{Flink|int [item]|get_ingredients|item}}&lt;br /&gt;
{{Flink|int [item]|get_inventory}}&lt;br /&gt;
{{Flink|int|get_power|item}}&lt;br /&gt;
{{Flink|int [item]|get_related|item|string}}&lt;br /&gt;
{{Flink|int [item]|get_shop}}&lt;br /&gt;
{{Flink|boolean|have_equipped|item}}&lt;br /&gt;
{{Flink|boolean|hermit|int|item}}&lt;br /&gt;
{{Flink|float|historical_age|item}}&lt;br /&gt;
{{Flink|int|historical_price|item}}&lt;br /&gt;
{{Flink|boolean|is_coinmaster_item|item}}&lt;br /&gt;
{{Flink|boolean|is_discardable|item}}&lt;br /&gt;
{{Flink|boolean|is_displayable|item}}&lt;br /&gt;
{{Flink|boolean|is_giftable|item}}&lt;br /&gt;
{{Flink|boolean|is_goal|item}}&lt;br /&gt;
{{Flink|boolean|is_npc_item|item}}&lt;br /&gt;
{{Flink|boolean|is_tradeable|item}}&lt;br /&gt;
{{Flink|boolean|is_trendy|item/familiar/skill/string}}&lt;br /&gt;
{{Flink|boolean|is_unrestricted|item/familiar/skill/string}}&lt;br /&gt;
{{Flink|int|item_amount|item}}&lt;br /&gt;
{{Flink|float|item_drop_modifier}}&lt;br /&gt;
{{Flink|int [item]|item_drops|{{opt|monster}}}}&lt;br /&gt;
{{Flink|record [int]|item_drops_array|{{opt|monster}}}}&lt;br /&gt;
{{Flink|string|item_type|item}}&lt;br /&gt;
{{Flink|string|last_item_message}}&lt;br /&gt;
{{Flink|int|mall_price|item}}&lt;br /&gt;
{{Flink|item|minstrel_instrument}}&lt;br /&gt;
{{Flink|int|npc_price|item}}&lt;br /&gt;
{{Flink|float|numeric_modifier|item|string}}&lt;br /&gt;
{{Flink|float|numeric_modifier|familiar|string|int|item}}&lt;br /&gt;
{{Flink|item [int]|outfit_pieces|string}}&lt;br /&gt;
{{Flink|boolean|overdrink|int|item}}&lt;br /&gt;
{{Flink|boolean|put_closet|int|{{opt|item}}}}&lt;br /&gt;
{{Flink|boolean|put_display|int|item}}&lt;br /&gt;
{{Flink|boolean|put_shop|int|int|{{opt|int}}|item}}&lt;br /&gt;
{{Flink|boolean|put_stash|int|item}}&lt;br /&gt;
{{Flink|void|remove_item_condition|int|item}}&lt;br /&gt;
{{Flink|boolean|retrieve_item|int|item}}&lt;br /&gt;
{{Flink|boolean|sell|coinmaster|int|item}}&lt;br /&gt;
{{Flink|int|sell_price|coinmaster|item}}&lt;br /&gt;
{{Flink|boolean|sells_item|coinmaster|item}}&lt;br /&gt;
{{Flink|int|shop_amount|item}}&lt;br /&gt;
{{Flink|int|shop_price|item}}&lt;br /&gt;
{{Flink|int|stash_amount|item}}&lt;br /&gt;
{{Flink|int|storage_amount|item}}&lt;br /&gt;
{{Flink|boolean|take_closet|int|{{opt|item}}}}&lt;br /&gt;
{{Flink|boolean|take_display|int|item}}&lt;br /&gt;
{{Flink|boolean|take_shop|{{opt|int}}|item}}&lt;br /&gt;
{{Flink|boolean|take_stash|int|item}}&lt;br /&gt;
{{Flink|boolean|take_storage|int|item}}&lt;br /&gt;
{{Flink|buffer|throw_item|item}}&lt;br /&gt;
{{Flink|buffer|throw_items|item|item}}&lt;br /&gt;
{{Flink|item|to_item|strict_string}}&lt;br /&gt;
{{Flink|item|to_item|int}}&lt;br /&gt;
{{Flink|item|to_item|string|int}}&lt;br /&gt;
{{Flink|string|to_plural|item}}&lt;br /&gt;
{{Flink|slot|to_slot|item}}&lt;br /&gt;
{{Flink|boolean|use|int|item}}&lt;br /&gt;
{{Flink|int|weapon_hands|item}}&lt;br /&gt;
{{Flink|stat|weapon_type|item}}&lt;br /&gt;
&lt;br /&gt;
==Proxy Record Fields==&lt;br /&gt;
&lt;br /&gt;
Here are the proxy record fields for items.  Proxy records are discussed in more detail [[Proxy Records|here]].&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;3&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1px&amp;quot; class=&amp;quot;sortable&amp;quot;&lt;br /&gt;
|- | style=&amp;quot;background-color: #F2F2F2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
! Default value&lt;br /&gt;
! ASH Accessor Function / Notes&lt;br /&gt;
|-&lt;br /&gt;
| name&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| plural&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| descid&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| image&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| smallimage&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| levelreq&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| quality&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| adventures&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| muscle&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| mysticality&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| moxie&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| fullness&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| inebriety&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| spleen&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| minhp&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| maxhp&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| minmp&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| maxmp&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| dailyusesleft&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| notes&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| quest&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| gift&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| tradeable&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| discardable&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| combat&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| combat_reusable&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| usable&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| reusable&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| multi&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| fancy&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| candy&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| seller&lt;br /&gt;
| coinmaster&lt;br /&gt;
| none&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| buyer&lt;br /&gt;
| coinmaster&lt;br /&gt;
| none&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| name_length&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]] [[Category:Data Types]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Control_Structures&amp;diff=3173</id>
		<title>Control Structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Control_Structures&amp;diff=3173"/>
		<updated>2020-08-08T20:36:42Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* for */ no floats&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Conditional==&lt;br /&gt;
===if===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean )&lt;br /&gt;
{&lt;br /&gt;
   // any statements here&lt;br /&gt;
   // are only going to be executed&lt;br /&gt;
   // if the boolean returns true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Single-statement conditionals may omit the curly braces.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean )&lt;br /&gt;
   // curly braces aren&#039;t required if only one statement follows the conditional&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
===else===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean )&lt;br /&gt;
{&lt;br /&gt;
   // statements if true&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
   // the statements here&lt;br /&gt;
   // are only going to be executed&lt;br /&gt;
   // if the boolean returns false&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===else if===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean 1 )&lt;br /&gt;
{&lt;br /&gt;
   // statements if true&lt;br /&gt;
}&lt;br /&gt;
else if ( boolean 2 )&lt;br /&gt;
{&lt;br /&gt;
   // the statements here&lt;br /&gt;
   // are only going to be executed&lt;br /&gt;
   // if boolean 1 returns false&lt;br /&gt;
   // &amp;amp; boolean 2 returns true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===switch===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch ( variable )&lt;br /&gt;
{&lt;br /&gt;
   case value:&lt;br /&gt;
      // statements if variable == value&lt;br /&gt;
      // more such statements&lt;br /&gt;
      break;&lt;br /&gt;
   //repeat above for as many values as desired&lt;br /&gt;
   default:&lt;br /&gt;
      // statements executed if&lt;br /&gt;
      // none of the cases were true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=&amp;quot;variable&amp;quot; and every &amp;quot;value&amp;quot; can be expressions as complex as wanted, as long as their end result is always of the same datatype. NO silent conversion is done, so the following &#039;&#039;&#039;will generate an error&#039;&#039;&#039;:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch ( 10 + 1 )&lt;br /&gt;
{&lt;br /&gt;
   case &amp;quot;1&amp;quot; + &amp;quot;1&amp;quot;:&lt;br /&gt;
      // Whatever you want; it doesn&#039;t matter, as 11 can&#039;t be compared with &amp;quot;11&amp;quot;&lt;br /&gt;
      break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Putting a &#039;&#039;break&#039;&#039; in each case isn&#039;t mandatory. If no &#039;&#039;break&#039;&#039; is placed on the path taken, once the last line of the case is reached, execution simply goes on, and will execute (will &amp;quot;fall-through&amp;quot;) the content of the next case/default.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch ( int guess_my_age )&lt;br /&gt;
{&lt;br /&gt;
   case 24:&lt;br /&gt;
   case 26:&lt;br /&gt;
      print(&amp;quot;You were SO close!&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case 25:&lt;br /&gt;
      print(&amp;quot;You got it!&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   default:&lt;br /&gt;
      print(&amp;quot;Nope&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=The default value of a switch structure&#039;s parameter is true. This means that if switch has no parameter, it is the same as submitting &#039;&#039;&#039;switch (true) [...]&#039;&#039;&#039;. Each case is then evaluated as a boolean expression, like a string of if-then statements.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch&lt;br /&gt;
{&lt;br /&gt;
   case boolean expression:&lt;br /&gt;
      // if the expression is true, this statement is executed&lt;br /&gt;
      // more such statements&lt;br /&gt;
      break;&lt;br /&gt;
   //repeat above for as many conditionals as desired&lt;br /&gt;
   default:&lt;br /&gt;
      // statements executed if&lt;br /&gt;
      // none of the cases were true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The default doesn&#039;t need to be the last statement (which is useful when using the aforementioned fall-through mechanic). If the default is placed early (e.g. as the first statement), it will NOT have priority over the other cases; if the value submitted to the switch matches one of the cases, execution will jump to it, even if placed after the default. &amp;lt;br&amp;gt;&lt;br /&gt;
Putting a &#039;&#039;break&#039;&#039; at the end of the switch is generally considered good practice, but achieves nothing.&lt;br /&gt;
&lt;br /&gt;
==Unconditional==&lt;br /&gt;
===try / finally===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Block1 is executed as normal, and then block2 is executed regardless of whether&lt;br /&gt;
block1 finished normally, generated an error, or encountered a &#039;return&#039;,&lt;br /&gt;
&#039;break&#039;, or &#039;continue&#039; statement.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
   // block1&lt;br /&gt;
}&lt;br /&gt;
finally&lt;br /&gt;
{&lt;br /&gt;
   // block2&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===static===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
static&lt;br /&gt;
{&lt;br /&gt;
   // any statements here&lt;br /&gt;
   // are only going to be executed once at the&lt;br /&gt;
   // first time the script executes in a session.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Single-statement static declarations may omit the curly braces.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
static&lt;br /&gt;
   // curly braces aren&#039;t required if only one statement follows the static keyword.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Keep in mind that when using imports, a static call will only apply to the script that imports it.&lt;br /&gt;
*If foo.ash has a static variable, but bar.ash imports foo.ash, KoLmafia will keep separate values for both foo.ash and bar.ash.&lt;br /&gt;
*If bar.ash is changed, its static variable is reset, but not foo.ash&#039;s.&lt;br /&gt;
*If foo.ash is changed, both scripts&#039; variables are reset.&lt;br /&gt;
&lt;br /&gt;
==Loops==&lt;br /&gt;
===while===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
while ( boolean )&lt;br /&gt;
{&lt;br /&gt;
   // as with an if statement&lt;br /&gt;
   // this area is only entered&lt;br /&gt;
   // if the boolean tests true&lt;br /&gt;
   // once all this is done&lt;br /&gt;
   // it goes back to the begining&lt;br /&gt;
   // and will keep executing&lt;br /&gt;
   // as long as the boolean remains true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===repeat until===&lt;br /&gt;
&lt;br /&gt;
This is similar to the [http://en.wikipedia.org/wiki/Do_while_loop do...while loop], but only ends the loop when the &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; expression evaluates to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
repeat&lt;br /&gt;
{&lt;br /&gt;
   // this is the same&lt;br /&gt;
   // as the while loop above&lt;br /&gt;
   // with one exception:&lt;br /&gt;
   // all of this code will&lt;br /&gt;
   // execute at least once&lt;br /&gt;
   // as the test doesn&#039;t occur&lt;br /&gt;
   // until the very end&lt;br /&gt;
} until ( boolean );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===for===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
for x from a to b by c {&lt;br /&gt;
   //do stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Above is the general case. You don&#039;t need to specify whether it&#039;s going up or down - although doing so by using upto or downto does allow a runtime check to make sure you didn&#039;t screw up.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t specify &amp;quot;c&amp;quot;, it defaults to incrementing/decrementing by 1.  The first iteration is at a and the last is at b (that is to say, it goes from a to b, inclusive).&lt;br /&gt;
&lt;br /&gt;
a, b and c are automatically converted to integers. You can&#039;t use floats here.&lt;br /&gt;
&lt;br /&gt;
===foreach===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach key in aggregate {&lt;br /&gt;
   //do stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Assigns each key in the supplied map or slice to &amp;quot;&amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt;&amp;quot; and iterates through the map. Due to how maps are handled, &amp;lt;code&amp;gt;foreach&amp;lt;/code&amp;gt; is guaranteed to iterate through the map in sorted order.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=For example:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean [int][string] map;&lt;br /&gt;
map[15][&amp;quot;test&amp;quot;] = true;&lt;br /&gt;
foreach int_index in map {&lt;br /&gt;
   print(int_index); //this will print &#039;15&#039; once, since there is only one valid value for this index&lt;br /&gt;
   foreach string_index in map[int_index] //this iterates over the &amp;quot;slice&amp;quot; of the map where 1 is fixed as the index&lt;br /&gt;
   { &lt;br /&gt;
      print(string_index); //This will print &amp;quot;test&amp;quot; once, since there is only one valid value for this index&lt;br /&gt;
      print(map[int_index][string_index]); //this will print &amp;quot;true&amp;quot;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
So the output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15&lt;br /&gt;
test&lt;br /&gt;
true&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=For a multidimensional map, instead of nesting &amp;lt;code&amp;gt;foreach&amp;lt;/code&amp;gt; statements two iterators can be used inline.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach x, y in map {&lt;br /&gt;
   //do stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=This is identical to:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach x in map {&lt;br /&gt;
   foreach y in map[x] {&lt;br /&gt;
      //do stuff&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=You can also directly specify the value stored in the map by specifying one more variable than the number of keys in the map:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
//string [string, int, item] my_map;&lt;br /&gt;
foreach s, i, m, value in my_map {&lt;br /&gt;
    print( s + &amp;quot;, &amp;quot; + i + &amp;quot;, &amp;quot; + m + &amp;quot; =&amp;gt; &amp;quot; + value );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
See the page for [[Data Structures]] for more information on aggregates.&lt;br /&gt;
&lt;br /&gt;
==Continuation &amp;amp; Exiting==&lt;br /&gt;
Like many languages with looping structures, ASH supports the break and continue statements.  All looping structures (for, while, repeat until, and foreach) support these statements.&lt;br /&gt;
&lt;br /&gt;
===break===&lt;br /&gt;
Breaks out of the smallest enclosing loop.  In a switch statement, breaks out of the switch statement.  Execution resumes at the first statement after the end of the loop/switch statement.&lt;br /&gt;
&lt;br /&gt;
===continue===&lt;br /&gt;
Continues on to the next iteration of the loop (skipping any statements in this iteration that occur after the continue statement).  In a switch statement, continue is allowed if the switch is inside a loop, and acts as any other continue.&lt;br /&gt;
&lt;br /&gt;
===return===&lt;br /&gt;
Exits the function and returns the value following the return statement, if specified. Note that the value&#039;s datatype must match that of the function itself (void functions can only use return by itself).&lt;br /&gt;
If in a switch statement, don&#039;t place a break after a return!&lt;br /&gt;
&lt;br /&gt;
===exit===&lt;br /&gt;
Exits the script. Using return when in main() achieves the same effect. Note that while this will end the current script, it will not stop automation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3209</id>
		<title>Data Structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Data_Structures&amp;diff=3209"/>
		<updated>2020-08-07T00:31:10Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Records */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
KoLmafia supports complex data structures such as maps and records made from simple [[Data Types|data types]].&lt;br /&gt;
&lt;br /&gt;
== Maps ==&lt;br /&gt;
If you are new to programming or find the information below confusing, you may want to read [[Map_Guide | A Noob&#039;s Guide to Maps]] first. &lt;br /&gt;
&lt;br /&gt;
Most of this information was copied directly from ASH Maps Tutorial, by Veracity (http://kolmafia.sourceforge.net/advanced.html#maps)&lt;br /&gt;
&lt;br /&gt;
A map is indexed by one data type (the key) and associates that key with another (or the same) data type (the value). The key can be any ASH simple data type: boolean, int, float, string, item, location, class, stat, skill, effect, familiar, slot, or monster. The value can be any ASH data type at all: a simple type, a record, or can be another map. This effectively allows multi-dimensional maps and. In fact, that&#039;s how the syntax we provide for multi-dimensional maps actually operate: maps of maps of maps ...&lt;br /&gt;
&lt;br /&gt;
You can declare a map any time you can declare a variable: as a top level (global) variable, as a function parameter, or as a local variable in any scope.&lt;br /&gt;
&lt;br /&gt;
You can fetch data from a map any time you can provide a data value: in an expression, as a function parameter, on the right side of an assignment statement, from a &amp;quot;return&amp;quot; statement, as so on. You can pass around entire maps, individual elements, or intermediate maps: &amp;quot;slices&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=== Declarations ===&lt;br /&gt;
&lt;br /&gt;
The syntax for declaring the data type of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;data type&amp;gt; [ &amp;lt;key type&amp;gt;, ... ] &amp;lt;aggregate_name&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [item] map1;&lt;br /&gt;
float [class, string, int] another_map;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Assignments ===&lt;br /&gt;
&lt;br /&gt;
If you use a map on the left side of an assignment, you set the whole map at once to the new value.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] my_pricelist;&lt;br /&gt;
int [item] new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Some code that updates my_pricelist with new_pricelist */&lt;br /&gt;
&lt;br /&gt;
my_pricelist = new_pricelist;&lt;br /&gt;
&lt;br /&gt;
/* Now my_pricelist and new_pricelist point to the same aggregate; &lt;br /&gt;
   changes to an element of one of them will be visible in the other */&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You can initialize an entire aggregate with an &#039;&#039;aggregate literal&#039;&#039;.  For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] my_pricelist = { $item[bum cheek]: 404,&lt;br /&gt;
                           $item[red button]: 100,&lt;br /&gt;
                           $item[red balloon]: 100000 };&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
If you specify a map and a complete set of indices (of the correct types) on the left side of an assignment statement, you set a single element.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] my_pricelist;&lt;br /&gt;
my_pricelist[ $item[ pail ] ] = 1000;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
If you specify a map and a prefix of indices (of the correct type), you directly set one of the intermediate maps, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float [string, int, string] my_map;&lt;br /&gt;
float [int, string] slice1;&lt;br /&gt;
&lt;br /&gt;
/* Some code that fills my_map[ &amp;quot;slice1&amp;quot; ] with slice1 */&lt;br /&gt;
my_map[ &amp;quot;slice1&amp;quot; ] = slice1;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== References ===&lt;br /&gt;
&lt;br /&gt;
The syntax for referencing an element (or slice) of a map:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate name&amp;gt;[ &amp;lt;key expression&amp;gt;, ... ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
All the key expressions will be evaluated at run time. If you specify all the keys the map expects, you fetch data of the type specified by the map. If you specify fewer keys than the map expects, you get an intermediate map, a &amp;quot;slice&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
As an example:&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean [string, string] props; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
might be used to hold &amp;quot;properties&amp;quot; associated with names.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;pet&amp;quot; ] = true; &lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;mammal&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;pet&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;turtle&amp;quot;, &amp;quot;fun&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;mammal&amp;quot; ] = true;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;pet&amp;quot; ] = false;&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot;, &amp;quot;fun&amp;quot; ] = true; &lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
references:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props[ &amp;quot;dog&amp;quot;, &amp;quot;mammal&amp;quot;] =&amp;gt; true&lt;br /&gt;
boolean [string] animal = props[ &amp;quot;turtle&amp;quot; ];&lt;br /&gt;
animal[ &amp;quot;fun&amp;quot; ] =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Contains ===&lt;br /&gt;
&lt;br /&gt;
You can test the presence of a key in a map using the &amp;quot;contains&amp;quot; operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;aggregate reference expression&amp;gt; contains &amp;lt;key expression&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Where &amp;lt;aggregate reference expression&amp;gt; must evaluate at run time to a map or slice, and must evaluate at run time to a key of the appropriate type. (Note that that is enforced at parse time; ASH can tell the datatype any expression will produce).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
props contains &amp;quot;dog&amp;quot; =&amp;gt; true&lt;br /&gt;
props contains &amp;quot;elephant&amp;quot; =&amp;gt; false&lt;br /&gt;
props[ &amp;quot;aardvark&amp;quot; ] contains &amp;quot;fun&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;pet&amp;quot; =&amp;gt; true&lt;br /&gt;
animal contains &amp;quot;favorite food&amp;quot; =&amp;gt; false&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Remove ===&lt;br /&gt;
&lt;br /&gt;
You can remove a key-value association from a map using the &amp;quot;remove&amp;quot; unary operator:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
remove &amp;lt;aggregate reference&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For clarification, an aggregate reference is &amp;quot;&amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n&amp;gt; ]&amp;quot; where &amp;lt;map name&amp;gt;[ &amp;lt;index 1&amp;gt; ... &amp;lt;index n-1&amp;gt; ] specifies the &amp;quot;slice&amp;quot; and &amp;lt;index n&amp;gt; specifies the &amp;quot;key&amp;quot;. Which is just what you expect, if you fully specify the indices; for a single dimensional map, &amp;quot;map[10]&amp;quot; -&amp;gt; &amp;quot;map&amp;quot; is the slice and 10 is the key. The &amp;quot;remove&amp;quot; operator removes the &amp;quot;key&amp;quot; from the &amp;quot;slice&amp;quot;. For example:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string [int] map1;&lt;br /&gt;
map1[5] = &amp;quot;foo&amp;quot;;&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot; + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
print( count( map1 ) + &amp;quot; &amp;quot; + map1 contains 5 + &amp;quot; &amp;quot;  + map1[5] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map1[5] );&lt;br /&gt;
int [string, string] map2;&lt;br /&gt;
map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] = 17;&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2[&amp;quot;me&amp;quot;] ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] contains &amp;quot;you&amp;quot; + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;,&amp;quot;you&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;, &amp;quot;you&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( &amp;quot;remove: &amp;quot; + remove map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
print( count( map2 ) + &amp;quot; &amp;quot; + map2[&amp;quot;me&amp;quot;] );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
yields:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
1 true foo&lt;br /&gt;
remove: foo&lt;br /&gt;
0 false&lt;br /&gt;
remove:&lt;br /&gt;
1 true 17&lt;br /&gt;
remove: 17&lt;br /&gt;
0 false 0&lt;br /&gt;
remove: 0&lt;br /&gt;
1 aggregate int [string]&lt;br /&gt;
remove: aggregate int [string]&lt;br /&gt;
0 aggregate int [string]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Clear ===&lt;br /&gt;
&lt;br /&gt;
You can remove all &amp;lt;code&amp;gt;key =&amp;gt; value&amp;lt;/code&amp;gt; entries from a map using the {{f|clear}} function:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;clear( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Count ===&lt;br /&gt;
&lt;br /&gt;
The {{f|count}} function returns the number of defined keys for the specified aggregate.&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;int size = count( &amp;lt;aggregate&amp;gt; );&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sort ===&lt;br /&gt;
&lt;br /&gt;
From http://kolmafia.us/showthread.php?t=1738 and http://kolmafia.us/showthread.php?10729&lt;br /&gt;
&lt;br /&gt;
The syntax is:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;sort aggregate by keyExpr;&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;aggregate&amp;lt;/code&amp;gt; is a reference to the object to be sorted - arrays are probably the most useful things to sort, but any mapping type can be used.  But please note that when you sort a map, you change the values that correspond to the index. To sort on a map, you would want to use a multidimensional maps, but note that you can only sort along a single dimension at a time when doing this. Simply put... &amp;quot;sort&amp;quot; is only useful in cases where your data exists entirely in the values of the map; the keys can have no meaning beyond simply being distinct.&lt;br /&gt;
&lt;br /&gt;
The reference must not be enclosed in parentheses, as that would look like a call to a function named &amp;lt;code&amp;gt;sort()&amp;lt;/code&amp;gt; - which is still perfectly valid, &amp;quot;sort&amp;quot; has not become a [[Reserved Words|reserved word]].&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is an arbitrary expression that defines how the items should be ordered. It is evaluated once for every entry in the aggregate, in a scope with two additional variables implicitly defined: &#039;&amp;lt;code&amp;gt;index&amp;lt;/code&amp;gt;&#039; and &#039;&amp;lt;code&amp;gt;value&amp;lt;/code&amp;gt;&#039;, holding the details of that entry. The value of the &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; is used as the sort key; typically it would be an &amp;lt;code&amp;gt;int&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt;, but can be any ASH type that can be compared via &amp;quot;&amp;lt;&amp;quot; and the other relational operators.&lt;br /&gt;
&lt;br /&gt;
The most basic form of sorting would therefore be &amp;quot;&amp;lt;code&amp;gt;sort ... by value&amp;lt;/code&amp;gt;&amp;quot;, but many useful things can be done with the use of a more complex &amp;lt;code&amp;gt;keyExpr&amp;lt;/code&amp;gt; - the only real restriction is that the expression should not modify the object you&#039;re sorting. For example, if you had an array of items, you could sort it &amp;quot;&amp;lt;code&amp;gt;by autosell_price(value)&amp;lt;/code&amp;gt;&amp;quot;. An array of weapon items could be sorted &amp;quot;&amp;lt;code&amp;gt;by -get_power(value)&amp;lt;/code&amp;gt;&amp;quot; to put it in decreasing order of power. If the elements of your aggregate are records, you&#039;d need to use something like &amp;quot;&amp;lt;code&amp;gt;by value.fieldName&amp;lt;/code&amp;gt;&amp;quot;, since the records themselves can&#039;t be meaningfully compared.&lt;br /&gt;
&lt;br /&gt;
After the sort statement, the aggregate will have exactly the same sets of keys and values as before (even if the keys weren&#039;t consecutive), and the iteration order of the keys will be the same, but the values will likely be associated with different keys. The sort is stable - in other words, elements with sort keys that compare as equal will remain in the same order. This means that you can sort on multiple criteria by simply performing separate sorts for each of the criteria, in increasing order of significance.&lt;br /&gt;
&lt;br /&gt;
To find out how many things you have, you might do:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item [int] whatGot;&lt;br /&gt;
int ctr =0;&lt;br /&gt;
&lt;br /&gt;
foreach it in get_inventory() {&lt;br /&gt;
   whatGot[ctr] = it;&lt;br /&gt;
   ctr+=1;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
sort whatGot by item_amount(value);&lt;br /&gt;
&lt;br /&gt;
foreach x, it in whatGot&lt;br /&gt;
   print(item_amount(it) + &#039; of &#039; + it);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Note that this use of an optional feature of foreach. The second variable in the foreach is the value of whatGot[x].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A few more examples of things you can do:&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -value&amp;lt;/code&amp;gt;&amp;quot; sorts integers in decreasing order (there&#039;s no similar trick for &amp;lt;code&amp;gt;string&amp;lt;/code&amp;gt; values).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by -index&amp;lt;/code&amp;gt;&amp;quot; reverses the existing order of an array (or map with integer keys).&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by random(1000000)&amp;lt;/code&amp;gt;&amp;quot; shuffles into a random order.&lt;br /&gt;
* &amp;quot;&amp;lt;code&amp;gt;by otherArray[index]&amp;lt;/code&amp;gt;&amp;quot; uses values from a parallel array as the sort keys (you&#039;d then need to do &amp;quot;&amp;lt;code&amp;gt;sort otherArray by value;&amp;lt;/code&amp;gt;&amp;quot; if you wanted the two arrays to remain in sync).&lt;br /&gt;
&lt;br /&gt;
===Iteration===&lt;br /&gt;
To iterate through a map, use the &#039;&#039;&#039;foreach&#039;&#039;&#039; operator. For instance, if you wanted to print out how many of each item you had, you could do something like the following:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item] map = get_inventory();&lt;br /&gt;
foreach key in map {&lt;br /&gt;
    print(key + &amp;quot; (&amp;quot; + map[key] + &amp;quot;)&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Multidimensional maps are implemented as maps that map keys to maps. &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is really a mapping of items to int[string] maps. Iteration, therefore, is as follows:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
file_to_map(&amp;quot;somefile.txt&amp;quot;, map);&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    print(k1 + &amp;quot;: &amp;quot;);&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        print(&amp;quot;\t&amp;quot; + k2 + &amp;quot;: &amp;quot; + map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Two things to note: First, &#039;&#039;&#039;int[item][string]map&#039;&#039;&#039; is equivalent to &#039;&#039;&#039;int[item, string]map&#039;&#039;&#039;. This really comes down to author preference, although the second form is generally more common. Second, the two following foreach loops are equivalent:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int[item][string] map;&lt;br /&gt;
foreach k1 in map {&lt;br /&gt;
    foreach k2 in map[k1] {&lt;br /&gt;
        func(map[k1][k2]);&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
foreach k1, k2 in map {&lt;br /&gt;
    func(map[k1][k2]);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Of course, the latter does not lend itself to, say, only printing the first key once, whereas the former can be used that way (see the preceding example).&lt;br /&gt;
&lt;br /&gt;
===Implementation===&lt;br /&gt;
Maps in ASH are implemented internally as TreeMaps [http://download.oracle.com/javase/1.5.0/docs/api/java/util/TreeMap.html]. See below for some implications.&lt;br /&gt;
&lt;br /&gt;
== Arrays ==&lt;br /&gt;
These look and behave like mappings of integers to values, where the keys only take values from 0 to n, but these are implemented as Java Arrays.&lt;br /&gt;
&lt;br /&gt;
===Differences between arrays and maps===&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [12] array;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use keys 0 - 11. You get a runtime error if you use any other key. It always uses memory to hold 12 items, even if you only use a couple of them. But it&#039;s a constant time - O(1) - to access any element.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;item [int] map;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Can use any int as a key. It has constant memory for the Java map, and additional memory for each element in the map, but is O( log n) to access any particular element.&lt;br /&gt;
&lt;br /&gt;
If you are able to use (a fairly densely packed set of) integers as keys, your program will be faster and use (potentially) slightly more memory.&lt;br /&gt;
&lt;br /&gt;
If you have a sparse set of integers, you can still use an array and get fast access, but you will waste a lot of memory.&lt;br /&gt;
&lt;br /&gt;
If you can&#039;t use integers as keys or don&#039;t want to waste memory on a sparse array, you can have a slower but less memory consuming map.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48703&amp;amp;viewfull=1#post48703]&lt;br /&gt;
&lt;br /&gt;
====Time considerations====&lt;br /&gt;
* Given &#039;&#039;&#039;if (a == item1 || a == item2 || a == item3)&#039;&#039;&#039; and &#039;&#039;&#039;if ($items[item1, item2, item3] contains a)&#039;&#039;&#039;, which is faster?&lt;br /&gt;
&lt;br /&gt;
This is going to depend on the number of items in the list, and which one happens to match; if &#039;a&#039; is almost always item1, then the first form is likely to win on practical grounds, even though it&#039;s theoretically slower (O(n) vs. O(log n)).&lt;br /&gt;
&lt;br /&gt;
The second form is a definite win assuming no such coincidences of the item chosen, a somewhat larger set of items, and that the code is executed more than once per run of the script. The first lookup in a plural constant actually builds an internal map that allows such queries to be efficiently done; this is deferred because typical use of a plural constant involves only iteration, not lookups.&lt;br /&gt;
&lt;br /&gt;
There&#039;s always the &amp;quot;profile&amp;quot; command, if you really need to know which is more efficient in a given situation - although it&#039;s unlikely that either would have a noticeable effect on your script&#039;s performance.&lt;br /&gt;
&lt;br /&gt;
[http://kolmafia.us/showthread.php?6425-Sorting-skills-by-mana-cost&amp;amp;p=48728&amp;amp;viewfull=1#post48728]&lt;br /&gt;
&lt;br /&gt;
== Records ==&lt;br /&gt;
&lt;br /&gt;
(Link to Veracity&#039;s post introducing the record [http://kolmafia.us/showthread.php?t=280])&lt;br /&gt;
&lt;br /&gt;
Records are custom-made data types, that act like compartmentalized boxes [https://i.imgur.com/rgxLKRC.jpg].&lt;br /&gt;
&lt;br /&gt;
They are &amp;quot;variable packages&amp;quot;, that allow you to group together data of any type, including other records, in them.&lt;br /&gt;
&lt;br /&gt;
Records have &amp;quot;models&amp;quot; (the custom data type of the record itself), and names representing them (though not all of them are creative, such as &#039;&#039;&amp;quot;the_black_one_that_I_bought_a_year_ago&amp;quot;&#039;&#039;, or &#039;&#039;&amp;quot;the_one_that_is_over_there_by_the_door&amp;quot;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
Each &amp;quot;compartment&amp;quot; (field) also has a name, as well as an expected data type. &#039;&#039;(Stop trying to put screws &amp;quot;there&amp;quot;; that&#039;s my god damn lunchbox, and this is &amp;quot;the spot in which you put the guacamole&amp;quot;!)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Once a &amp;quot;box&#039;s model&amp;quot; (record&#039;s data type) is declared, it can be used (almost) anywhere that can use a built-in type name (as long as you don&#039;t leave the scope in which the record was declared), such as in functions and other records.&lt;br /&gt;
&lt;br /&gt;
===Declarations===&lt;br /&gt;
The syntax for declaring a new record:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
record &amp;lt;&amp;quot;model&amp;quot; name&amp;gt; { &amp;lt;data type 1&amp;gt; &amp;lt;field name 1&amp;gt;; &amp;lt;data type 2&amp;gt; &amp;lt;field name 2&amp;gt;; ... }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
};&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
This declared a new data &#039;&#039;&#039;&#039;&#039;type&#039;&#039;&#039;&#039;&#039;, a &#039;&#039;mold&#039;&#039;, a &#039;&#039;blueprint&#039;&#039;... No variable was created here.&lt;br /&gt;
&lt;br /&gt;
To actually &#039;&#039;create&#039;&#039; a variable that &#039;&#039;uses&#039;&#039; this &amp;quot;model&amp;quot;, you would &#039;&#039;&#039;then&#039;&#039;&#039; do:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
human that_guy;&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
You now have 3 &amp;quot;human&amp;quot;s, each with a name, date of birth, location of birth, and clothes (though none of them has had those assigned, yet).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It is possible to declare a record and create a variable of that type at the same time. The following is equivalent to the two previous code samples combined:&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record human {&lt;br /&gt;
    string name;&lt;br /&gt;
    int date_of_birth;&lt;br /&gt;
    location location_of_birth;&lt;br /&gt;
    item [slot] clothes;&lt;br /&gt;
} that_guy;&lt;br /&gt;
&lt;br /&gt;
human this_guy;&lt;br /&gt;
human that_other_guy;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===Accessing the fields===&lt;br /&gt;
Once a variable of a recorded data type was created, you may access its fields with &amp;lt;variable name&amp;gt;.&amp;lt;field name&amp;gt;:&lt;br /&gt;
&lt;br /&gt;
{{CodeSample&lt;br /&gt;
|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
that_guy.name = &amp;quot;Andrew&amp;quot;;&lt;br /&gt;
that_guy.date_of_birth = 08212006;&lt;br /&gt;
that_guy.location_of_birth = $location[Noob Cave];&lt;br /&gt;
&lt;br /&gt;
that_other_guy.name = &amp;quot;Bob&amp;quot;;&lt;br /&gt;
that_other_guy.location_of_birth = $location[South of the Border];&lt;br /&gt;
&lt;br /&gt;
if ( that_other_guy.clothes [ $slot[pants] ] == $item[none] )&lt;br /&gt;
    print( &amp;quot;Put some pants on, &amp;quot; + that_other_guy.name + &amp;quot;!&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Omitting the &amp;quot;model&amp;quot; name===&lt;br /&gt;
When declaring a record, supplying the &amp;quot;model&amp;quot; name (what goes between &amp;quot;record&amp;quot; and the left curly bracket) is not mandatory. If you don&#039;t, the record will be &amp;quot;anonymous&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
An &amp;quot;anonymous&amp;quot; record is like a makeshift bindle; you made it on a whim, it&#039;s unique, it&#039;s yours, you couldn&#039;t replicate it even if you tried, and nobody else wants it.&lt;br /&gt;
&lt;br /&gt;
If you omit data type&#039;s name, you&#039;ll definitely want to supply a variable name after the curly braces, or it will have been a pure waste of time:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
record {&lt;br /&gt;
  	int days_spent_travelling;&lt;br /&gt;
	item [int] content;&lt;br /&gt;
} mah_bindle;&lt;br /&gt;
&lt;br /&gt;
mah_bindle.content [0] = $item[ big rock ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===[[New]]===&lt;br /&gt;
[[New]] can be used to assign a whole record at once.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Equipment&amp;diff=814</id>
		<title>Equipment</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Equipment&amp;diff=814"/>
		<updated>2020-07-31T21:37:30Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Equipment Commands */ equipped_amount()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Equipment Commands==&lt;br /&gt;
{{Flink|boolean|equip|{{opt|slot}}|item|desc=Equips the specified item and reports success.}}&lt;br /&gt;
{{Flink|item|equipped_item|slot|desc=Returns the item equipped in the specified slot.}}&lt;br /&gt;
{{Flink|boolean|have_equipped|item|desc=Reports if the specified item is currently equipped by your character.}}&lt;br /&gt;
{{Flink|int|equipped_amount|item|desc=Returns the amount of a given item currently equipped on your character.}}&lt;br /&gt;
{{Flink|boolean|can_equip|item|desc=Tells if you meet the requirements for equipping the given item (regardless of its availability).}}&lt;br /&gt;
{{Flink|int|weapon_hands|item|desc=Reports how many weapon-hand slots are required for a given item (0 - 2). Off-hand items return 0.}}&lt;br /&gt;
{{Flink|stat|weapon_type|item|desc=Returns the equip requirement stat for the specified item. If it is not a weapon, this function returns $stat[none].}}&lt;br /&gt;
{{Flink|boolean|have_familiar|familiar|desc=Reports on whether you have the specified familiar either in your Terrarium or equipped.}}&lt;br /&gt;
{{Flink|boolean|use_familiar|familiar|desc=Attempts to make the specified familiar your currently used one and reports success.}}&lt;br /&gt;
{{Flink|item|familiar_equipment|familiar|desc=Reports the most commonly associated familiar equipment for the specified familiar.}}&lt;br /&gt;
{{Flink|item|familiar_equipped_equipment|familiar|desc=Returns the item currently equipped on the specified familiar (or $item[none] if you don&#039;t have that familiar).}}&lt;br /&gt;
{{Flink|boolean|enthrone_familiar|familiar|desc=Enthrones the specified familiar.}}&lt;br /&gt;
{{Flink|familiar|my_enthroned_familiar|desc=Returns the familiar currently enthroned.}}&lt;br /&gt;
{{Flink|boolean|bjornify_familiar|familiar|desc=Bjornifies the specified familiar.}}&lt;br /&gt;
{{Flink|familiar|my_bjorned_familiar|desc=Returns the familiar currently in the Buddy Bjorn.}}&lt;br /&gt;
{{Flink|boolean|maximize|string|boolean}}&lt;br /&gt;
{{Flink|boolean|maximize|string|int|int|boolean|desc=Checks for and optionally equips the optimal gear for any given parameters.}}&lt;br /&gt;
&lt;br /&gt;
==Outfit Commands==&lt;br /&gt;
{{Flink|boolean|have_outfit|string|desc=Reports on whether or not you&#039;re currently capable of equipping the specified (in-game or custom) outfit, based on your stats &amp;amp; inventory availability of all outfit pieces.}}&lt;br /&gt;
{{Flink|boolean|outfit|string|desc=Attempts to wear the specified outfit and reports success.}}&lt;br /&gt;
{{Flink|item [int]|outfit_pieces|string|desc=Returns an array of the items which compose an outfit.}}&lt;br /&gt;
{{Flink|boolean|is_wearing_outfit|string|desc=Reports on whether or not you&#039;re wearing the specified (in-game or custom) outfit.}}&lt;br /&gt;
{{Flink|string [int]|get_outfits|desc=This function returns a  list of all KoL outfits that the character currently owns and can wear.}}&lt;br /&gt;
{{Flink|string [int]|get_custom_outfits|desc=This function returns a  list of all currently defined custom outfits.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Control_Structures&amp;diff=3172</id>
		<title>Control Structures</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Control_Structures&amp;diff=3172"/>
		<updated>2020-07-29T23:04:41Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* switch */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Conditional==&lt;br /&gt;
===if===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean )&lt;br /&gt;
{&lt;br /&gt;
   // any statements here&lt;br /&gt;
   // are only going to be executed&lt;br /&gt;
   // if the boolean returns true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Single-statement conditionals may omit the curly braces.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean )&lt;br /&gt;
   // curly braces aren&#039;t required if only one statement follows the conditional&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
===else===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean )&lt;br /&gt;
{&lt;br /&gt;
   // statements if true&lt;br /&gt;
}&lt;br /&gt;
else&lt;br /&gt;
{&lt;br /&gt;
   // the statements here&lt;br /&gt;
   // are only going to be executed&lt;br /&gt;
   // if the boolean returns false&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===else if===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if ( boolean 1 )&lt;br /&gt;
{&lt;br /&gt;
   // statements if true&lt;br /&gt;
}&lt;br /&gt;
else if ( boolean 2 )&lt;br /&gt;
{&lt;br /&gt;
   // the statements here&lt;br /&gt;
   // are only going to be executed&lt;br /&gt;
   // if boolean 1 returns false&lt;br /&gt;
   // &amp;amp; boolean 2 returns true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===switch===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch ( variable )&lt;br /&gt;
{&lt;br /&gt;
   case value:&lt;br /&gt;
      // statements if variable == value&lt;br /&gt;
      // more such statements&lt;br /&gt;
      break;&lt;br /&gt;
   //repeat above for as many values as desired&lt;br /&gt;
   default:&lt;br /&gt;
      // statements executed if&lt;br /&gt;
      // none of the cases were true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=&amp;quot;variable&amp;quot; and every &amp;quot;value&amp;quot; can be expressions as complex as wanted, as long as their end result is always of the same datatype. NO silent conversion is done, so the following &#039;&#039;&#039;will generate an error&#039;&#039;&#039;:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch ( 10 + 1 )&lt;br /&gt;
{&lt;br /&gt;
   case &amp;quot;1&amp;quot; + &amp;quot;1&amp;quot;:&lt;br /&gt;
      // Whatever you want; it doesn&#039;t matter, as 11 can&#039;t be compared with &amp;quot;11&amp;quot;&lt;br /&gt;
      break;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Putting a &#039;&#039;break&#039;&#039; in each case isn&#039;t mandatory. If no &#039;&#039;break&#039;&#039; is placed on the path taken, once the last line of the case is reached, execution simply goes on, and will execute (will &amp;quot;fall-through&amp;quot;) the content of the next case/default.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch ( int guess_my_age )&lt;br /&gt;
{&lt;br /&gt;
   case 24:&lt;br /&gt;
   case 26:&lt;br /&gt;
      print(&amp;quot;You were SO close!&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   case 25:&lt;br /&gt;
      print(&amp;quot;You got it!&amp;quot;);&lt;br /&gt;
      break;&lt;br /&gt;
   default:&lt;br /&gt;
      print(&amp;quot;Nope&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=The default value of a switch structure&#039;s parameter is true. This means that if switch has no parameter, it is the same as submitting &#039;&#039;&#039;switch (true) [...]&#039;&#039;&#039;. Each case is then evaluated as a boolean expression, like a string of if-then statements.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
switch&lt;br /&gt;
{&lt;br /&gt;
   case boolean expression:&lt;br /&gt;
      // if the expression is true, this statement is executed&lt;br /&gt;
      // more such statements&lt;br /&gt;
      break;&lt;br /&gt;
   //repeat above for as many conditionals as desired&lt;br /&gt;
   default:&lt;br /&gt;
      // statements executed if&lt;br /&gt;
      // none of the cases were true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
The default doesn&#039;t need to be the last statement (which is useful when using the aforementioned fall-through mechanic). If the default is placed early (e.g. as the first statement), it will NOT have priority over the other cases; if the value submitted to the switch matches one of the cases, execution will jump to it, even if placed after the default. &amp;lt;br&amp;gt;&lt;br /&gt;
Putting a &#039;&#039;break&#039;&#039; at the end of the switch is generally considered good practice, but achieves nothing.&lt;br /&gt;
&lt;br /&gt;
==Unconditional==&lt;br /&gt;
===try / finally===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Block1 is executed as normal, and then block2 is executed regardless of whether&lt;br /&gt;
block1 finished normally, generated an error, or encountered a &#039;return&#039;,&lt;br /&gt;
&#039;break&#039;, or &#039;continue&#039; statement.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
try&lt;br /&gt;
{&lt;br /&gt;
   // block1&lt;br /&gt;
}&lt;br /&gt;
finally&lt;br /&gt;
{&lt;br /&gt;
   // block2&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===static===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
static&lt;br /&gt;
{&lt;br /&gt;
   // any statements here&lt;br /&gt;
   // are only going to be executed once at the&lt;br /&gt;
   // first time the script executes in a session.&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=Single-statement static declarations may omit the curly braces.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
static&lt;br /&gt;
   // curly braces aren&#039;t required if only one statement follows the static keyword.&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Keep in mind that when using imports, a static call will only apply to the script that imports it.&lt;br /&gt;
*If foo.ash has a static variable, but bar.ash imports foo.ash, KoLmafia will keep separate values for both foo.ash and bar.ash.&lt;br /&gt;
*If bar.ash is changed, its static variable is reset, but not foo.ash&#039;s.&lt;br /&gt;
*If foo.ash is changed, both scripts&#039; variables are reset.&lt;br /&gt;
&lt;br /&gt;
==Loops==&lt;br /&gt;
===while===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
while ( boolean )&lt;br /&gt;
{&lt;br /&gt;
   // as with an if statement&lt;br /&gt;
   // this area is only entered&lt;br /&gt;
   // if the boolean tests true&lt;br /&gt;
   // once all this is done&lt;br /&gt;
   // it goes back to the begining&lt;br /&gt;
   // and will keep executing&lt;br /&gt;
   // as long as the boolean remains true&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===repeat until===&lt;br /&gt;
&lt;br /&gt;
This is similar to the [http://en.wikipedia.org/wiki/Do_while_loop do...while loop], but only ends the loop when the &amp;lt;code&amp;gt;boolean&amp;lt;/code&amp;gt; expression evaluates to &amp;lt;code&amp;gt;true&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
repeat&lt;br /&gt;
{&lt;br /&gt;
   // this is the same&lt;br /&gt;
   // as the while loop above&lt;br /&gt;
   // with one exception:&lt;br /&gt;
   // all of this code will&lt;br /&gt;
   // execute at least once&lt;br /&gt;
   // as the test doesn&#039;t occur&lt;br /&gt;
   // until the very end&lt;br /&gt;
} until ( boolean );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
===for===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
for x from a to b by c {&lt;br /&gt;
   //do stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Above is the general case. You don&#039;t need to specify whether it&#039;s going up or down - although doing so by using upto or downto does allow a runtime check to make sure you didn&#039;t screw up.&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t specify &amp;quot;c&amp;quot;, it defaults to incrementing/decrementing by 1.  The first iteration is at a and the last is at b (that is to say, it goes from a to b, inclusive).&lt;br /&gt;
&lt;br /&gt;
===foreach===&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach key in aggregate {&lt;br /&gt;
   //do stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Assigns each key in the supplied map or slice to &amp;quot;&amp;lt;code&amp;gt;key&amp;lt;/code&amp;gt;&amp;quot; and iterates through the map. Due to how maps are handled, &amp;lt;code&amp;gt;foreach&amp;lt;/code&amp;gt; is guaranteed to iterate through the map in sorted order.&lt;br /&gt;
&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=For example:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean [int][string] map;&lt;br /&gt;
map[15][&amp;quot;test&amp;quot;] = true;&lt;br /&gt;
foreach int_index in map {&lt;br /&gt;
   print(int_index); //this will print &#039;15&#039; once, since there is only one valid value for this index&lt;br /&gt;
   foreach string_index in map[int_index] //this iterates over the &amp;quot;slice&amp;quot; of the map where 1 is fixed as the index&lt;br /&gt;
   { &lt;br /&gt;
      print(string_index); //This will print &amp;quot;test&amp;quot; once, since there is only one valid value for this index&lt;br /&gt;
      print(map[int_index][string_index]); //this will print &amp;quot;true&amp;quot;&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
So the output is&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
15&lt;br /&gt;
test&lt;br /&gt;
true&lt;br /&gt;
&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=For a multidimensional map, instead of nesting &amp;lt;code&amp;gt;foreach&amp;lt;/code&amp;gt; statements two iterators can be used inline.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach x, y in map {&lt;br /&gt;
   //do stuff&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=This is identical to:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach x in map {&lt;br /&gt;
   foreach y in map[x] {&lt;br /&gt;
      //do stuff&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=You can also directly specify the value stored in the map by specifying one more variable than the number of keys in the map:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
//string [string, int, item] my_map;&lt;br /&gt;
foreach s, i, m, value in my_map {&lt;br /&gt;
    print( s + &amp;quot;, &amp;quot; + i + &amp;quot;, &amp;quot; + m + &amp;quot; =&amp;gt; &amp;quot; + value );&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
See the page for [[Data Structures]] for more information on aggregates.&lt;br /&gt;
&lt;br /&gt;
==Continuation &amp;amp; Exiting==&lt;br /&gt;
Like many languages with looping structures, ASH supports the break and continue statements.  All looping structures (for, while, repeat until, and foreach) support these statements.&lt;br /&gt;
&lt;br /&gt;
===break===&lt;br /&gt;
Breaks out of the smallest enclosing loop.  In a switch statement, breaks out of the switch statement.  Execution resumes at the first statement after the end of the loop/switch statement.&lt;br /&gt;
&lt;br /&gt;
===continue===&lt;br /&gt;
Continues on to the next iteration of the loop (skipping any statements in this iteration that occur after the continue statement).  In a switch statement, continue is allowed if the switch is inside a loop, and acts as any other continue.&lt;br /&gt;
&lt;br /&gt;
===return===&lt;br /&gt;
Exits the function and returns the value following the return statement, if specified. Note that the value&#039;s datatype must match that of the function itself (void functions can only use return by itself).&lt;br /&gt;
If in a switch statement, don&#039;t place a break after a return!&lt;br /&gt;
&lt;br /&gt;
===exit===&lt;br /&gt;
Exits the script. Using return when in main() achieves the same effect. Note that while this will end the current script, it will not stop automation.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Get_campground&amp;diff=4041</id>
		<title>Get campground</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Get_campground&amp;diff=4041"/>
		<updated>2020-07-22T04:45:29Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: lists the telescope&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|get_campground}}{{&lt;br /&gt;
#vardefine:return_type|int [item]}}{{&lt;br /&gt;
#vardefine:aggregate|yes}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns a map of your campground items as integers, keyed by item names.&lt;br /&gt;
&amp;lt;ul&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Most values will be 1 to represent the item exists; some can be as high as 9, such as pretty bouquets and fences.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Not all items will be included; Hippy Stone, Colossal Closet, Quest Log, Trophy Case, Terrarium, and Mystical Bookshelf are ignored.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Your dwelling itself is processed separately, using {{f|get_dwelling}}&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt; Furnishings for your dwelling (some &amp;quot;Tasteful&amp;quot; gifts, Really Good Feng Shui, etc.) will be listed on their own in the result.&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ul&amp;gt;|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=The following will save a text file in your data directory with your campground information.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int [item] mystuff;&lt;br /&gt;
mystuff = get_campground();&lt;br /&gt;
map_to_file(mystuff , &amp;quot;campy.txt&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|get_dwelling|get_clan_lounge|map_to_file}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Item Management]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Boolean_modifier&amp;diff=5040</id>
		<title>Boolean modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Boolean_modifier&amp;diff=5040"/>
		<updated>2020-07-01T21:20:15Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|boolean_modifier}}{{&lt;br /&gt;
#vardefine:return_type|boolean}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|str}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|it}}|&lt;br /&gt;
parameter2={{Param|string|str}}|&lt;br /&gt;
p1desc={{pspan|it}} is the (optional) item in question|&lt;br /&gt;
p2desc={{pspan|str}} is the modifier name|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
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. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
For a list of fields that this function takes, see [[Modifiers#Boolean_Modifiers|Modifiers]].|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Simple Examples|&lt;br /&gt;
description=Tells you if you can adventure underwater or not.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if(!(boolean_modifier(&amp;quot;Adventure Underwater&amp;quot;))||!(boolean_modifier(&amp;quot;Underwater Familiar&amp;quot;))) {&lt;br /&gt;
   print(&amp;quot;You can&#039;t adventure underwater.&amp;quot;, &amp;quot;red&amp;quot;);&lt;br /&gt;
   print(&amp;quot;Either you won&#039;t be able to breathe, or your familiar won&#039;t.&amp;quot;,&amp;quot;red&amp;quot;);&lt;br /&gt;
   exit;&lt;br /&gt;
}&lt;br /&gt;
print(&amp;quot;You can adventure underwater.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Informs the player of how many accordion thief songs he can have active at one time.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean four_songs = boolean_modifier(&amp;quot;four songs&amp;quot;);&lt;br /&gt;
   # plexiglass pendant and/or brimstone beret grant 4 songs total.&lt;br /&gt;
boolean extra_song = boolean_modifier(&amp;quot;additional song&amp;quot;);&lt;br /&gt;
   # La Hebilla del Cinturón de Lopez adds one song&lt;br /&gt;
int max_songs = 3 + to_int(four_songs) + to_int(extra_song);&lt;br /&gt;
print(&amp;quot;You can currently hold &amp;quot;+ max_songs +&amp;quot; songs in your head at a time.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|effect_modifier|numeric_modifier|string_modifier}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Effect_modifier&amp;diff=6400</id>
		<title>Effect modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Effect_modifier&amp;diff=6400"/>
		<updated>2020-07-01T21:19:58Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|effect_modifier}}{{&lt;br /&gt;
#vardefine:return_type|effect}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
function_description=Returns an effect if {{pspan|check_me}} is effect specific. {{pspan|modifier_name}} is the &amp;lt;b&amp;gt;[[modifiers|modifier]]&amp;lt;/b&amp;gt; to check for.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Prints a list of all items that have intrinsic effects|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
effect eff;&lt;br /&gt;
foreach doodad in $items[] {&lt;br /&gt;
   eff = effect_modifier( doodad , &amp;quot;Intrinsic Effect&amp;quot; );&lt;br /&gt;
   if(eff != $effect[none])&lt;br /&gt;
      print(doodad +&amp;quot; grants &amp;quot;+ eff);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Return the effect granted by drinking a particular potion.|&lt;br /&gt;
code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
effect potion_to_effect(item potion) }&lt;br /&gt;
   return effect_modifier(potion, &amp;quot;effect&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
more_info= See [http://kolmafia.us/showthread.php?802 this thread] for details.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|boolean_modifier|numeric_modifier|string_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Numeric_modifier&amp;diff=2656</id>
		<title>Numeric modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Numeric_modifier&amp;diff=2656"/>
		<updated>2020-07-01T21:19:44Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|numeric_modifier}}{{&lt;br /&gt;
#vardefine:return_type|float}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function3={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function4={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|effect|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function5={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|skill|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
p1desc={{Pspan|check_me}} is the string, item, effect or skill to check|&lt;br /&gt;
p2desc={{Pspan|modifier_name}} is the &amp;lt;b&amp;gt;[[modifiers|modifier]]&amp;lt;/b&amp;gt; to check|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns your current modifier total for {{pspan|modifier_name}}, or the amount of modification from {{pspan|check_me}} if specified.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Special Syntax for Familiars===&lt;br /&gt;
{{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|familiar|buddy}}|&lt;br /&gt;
parameter2={{Param|string|check_me}}|&lt;br /&gt;
parameter3={{Param|int|weight}}|&lt;br /&gt;
parameter4={{Param|item|equipment}}|&lt;br /&gt;
p1desc={{Pspan|buddy}} is the familiar to check|&lt;br /&gt;
p2desc={{Pspan|check_me}} is the modifier to check|&lt;br /&gt;
p3desc={{Pspan|weight}} is the familiar&#039;s weight (buffed, not including equipment)|&lt;br /&gt;
p4desc={{Pspan|equipment}} is the familiar&#039;s equipment|&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;p&amp;gt;Returns the familiar&#039;s effect on this modifier (for instance, a baby gravy fairy would return some positive float for &amp;quot;Item Drop&amp;quot;).|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Prints your current Initiative:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float init = numeric_modifier( &amp;quot;initiative&amp;quot; );&lt;br /&gt;
print(init);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Function that checks if a single effect from a given list will buff your muscle over an amount goal. The name of the first effect to satisfy the goal is printed, or you are warned if none is found.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean buffMuscleTo( int goal ) {&lt;br /&gt;
   int current_muscle = my_buffedstat( $stat[Muscle] ) ;&lt;br /&gt;
   int base_muscle = my_basestat( $stat[Muscle] ) ;&lt;br /&gt;
   int muscle_increase ;&lt;br /&gt;
   if ( current_muscle &amp;gt;= goal ) return true ;&lt;br /&gt;
   &lt;br /&gt;
   foreach it in $effects[Tomato Power, Phorcefullness, Gr8tness, Incredibly Hulking] {&lt;br /&gt;
      if ( have_effect(it) &amp;gt; 0 ) continue ;&lt;br /&gt;
      muscle_increase = floor( base_muscle * numeric_modifier( it, &amp;quot;Muscle Percent&amp;quot; ) / 100 );&lt;br /&gt;
      if ( current_muscle + muscle_increase &amp;gt;= goal ) {&lt;br /&gt;
         print(it + &amp;quot; will bring your muscle over &amp;quot; + goal);&lt;br /&gt;
         return true;&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   print(&amp;quot;No effect found&amp;quot;);&lt;br /&gt;
   return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
code2={{CodeSample|&lt;br /&gt;
title=Potion/effect-giving items|&lt;br /&gt;
description=To get a modifier from a consumable which gives an effect, it is first necessary to convert the item into its given effect with [[effect_modifier]]. &amp;lt;br&amp;gt; This snippet calculates what your meat drop bonus would be after eating a {{kolwiki|sweet roll alabama}}:|&lt;br /&gt;
code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float meat_boost = numeric_modifier( &amp;quot;meat drop&amp;quot; );&lt;br /&gt;
effect effect_from_item = effect_modifier( $item[Sweet roll Alabama] , &amp;quot;effect&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
meat_boost += numeric_modifier( effect_from_item , &amp;quot;meat drop&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
cli_equiv=The CLI command &amp;quot;modtrace&amp;quot; gives access to the same information when the correct parameters are specified.|&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
more_info= For a full list of modifiers, see [[modifiers]].&amp;lt;br&amp;gt;&lt;br /&gt;
For more information about numeric_modifier(), see the following thread: [http://kolmafia.us/showthread.php?802  List].|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|boolean_modifier|effect_modifier|string_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=String_modifier&amp;diff=6405</id>
		<title>String modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=String_modifier&amp;diff=6405"/>
		<updated>2020-07-01T21:19:23Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|string_modifier}}{{&lt;br /&gt;
#vardefine:return_type|string}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}||&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
function_description=Returns a string modifier. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
For a list of fields that this function takes, see [[Modifiers#String_Modifiers|Modifiers]].|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=Checks current equipped outfit.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if(string_modifier(&amp;quot;outfit&amp;quot;) == &amp;quot;knob goblin elite guard uniform&amp;quot;)&lt;br /&gt;
   print(&amp;quot;You are equipped to purchase seltzer.&amp;quot;);&lt;br /&gt;
else print(&amp;quot;The Knob scientists won&#039;t let you into their store dressed like that.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Display all modifiers related to your current moon sign.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
print(&amp;quot;I was born under the sign of the &amp;quot;+ my_sign() +&amp;quot; which gives me these modifiers:&amp;quot;);&lt;br /&gt;
print( string_modifier(&amp;quot;Sign:&amp;quot;+ my_sign(), &amp;quot;Modifiers&amp;quot; ) );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
more_info= See [http://kolmafia.us/showthread.php?802 this thread] for details.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|boolean_modifier|effect_modifier|numeric_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=String_modifier&amp;diff=6404</id>
		<title>String modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=String_modifier&amp;diff=6404"/>
		<updated>2020-07-01T21:09:43Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|string_modifier}}{{&lt;br /&gt;
#vardefine:return_type|string}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}||&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
function_description=Returns a string modifier. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
For a list of fields that this function takes, see [[Modifiers#String_Modifiers|Modifiers]].|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=Checks current equipped outfit.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if(string_modifier(&amp;quot;outfit&amp;quot;) == &amp;quot;knob goblin elite guard uniform&amp;quot;)&lt;br /&gt;
   print(&amp;quot;You are equipped to purchase seltzer.&amp;quot;);&lt;br /&gt;
else print(&amp;quot;The Knob scientists won&#039;t let you into their store dressed like that.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Display all modifiers related to your current moon sign.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
print(&amp;quot;I was born under the sign of the &amp;quot;+ my_sign() +&amp;quot; which gives me these modifiers:&amp;quot;);&lt;br /&gt;
print( string_modifier(&amp;quot;Sign:&amp;quot;+ my_sign(), &amp;quot;Modifiers&amp;quot; ) );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
more_info= See [http://kolmafia.us/showthread.php?802 this thread] for details.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|boolean_modifier|effect_modifier|numeric_modifier|stat_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Boolean_modifier&amp;diff=5039</id>
		<title>Boolean modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Boolean_modifier&amp;diff=5039"/>
		<updated>2020-07-01T21:06:01Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|boolean_modifier}}{{&lt;br /&gt;
#vardefine:return_type|boolean}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|str}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|it}}|&lt;br /&gt;
parameter2={{Param|string|str}}|&lt;br /&gt;
p1desc={{pspan|it}} is the (optional) item in question|&lt;br /&gt;
p2desc={{pspan|str}} is the modifier name|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
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. &amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
For a list of fields that this function takes, see [[Modifiers#Boolean_Modifiers|Modifiers]].|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Simple Examples|&lt;br /&gt;
description=Tells you if you can adventure underwater or not.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if(!(boolean_modifier(&amp;quot;Adventure Underwater&amp;quot;))||!(boolean_modifier(&amp;quot;Underwater Familiar&amp;quot;))) {&lt;br /&gt;
   print(&amp;quot;You can&#039;t adventure underwater.&amp;quot;, &amp;quot;red&amp;quot;);&lt;br /&gt;
   print(&amp;quot;Either you won&#039;t be able to breathe, or your familiar won&#039;t.&amp;quot;,&amp;quot;red&amp;quot;);&lt;br /&gt;
   exit;&lt;br /&gt;
}&lt;br /&gt;
print(&amp;quot;You can adventure underwater.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Informs the player of how many accordion thief songs he can have active at one time.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean four_songs = boolean_modifier(&amp;quot;four songs&amp;quot;);&lt;br /&gt;
   # plexiglass pendant and/or brimstone beret grant 4 songs total.&lt;br /&gt;
boolean extra_song = boolean_modifier(&amp;quot;additional song&amp;quot;);&lt;br /&gt;
   # La Hebilla del Cinturón de Lopez adds one song&lt;br /&gt;
int max_songs = 3 + to_int(four_songs) + to_int(extra_song);&lt;br /&gt;
print(&amp;quot;You can currently hold &amp;quot;+ max_songs +&amp;quot; songs in your head at a time.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|effect_modifier|numeric_modifier|stat_modifier|string_modifier}}|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Effect_modifier&amp;diff=6399</id>
		<title>Effect modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Effect_modifier&amp;diff=6399"/>
		<updated>2020-07-01T21:04:26Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|effect_modifier}}{{&lt;br /&gt;
#vardefine:return_type|effect}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
function_description=Returns an effect if {{pspan|check_me}} is effect specific. {{pspan|modifier_name}} is the &amp;lt;b&amp;gt;[[modifiers|modifier]]&amp;lt;/b&amp;gt; to check for.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Prints a list of all items that have intrinsic effects|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
effect eff;&lt;br /&gt;
foreach doodad in $items[] {&lt;br /&gt;
   eff = effect_modifier( doodad , &amp;quot;Intrinsic Effect&amp;quot; );&lt;br /&gt;
   if(eff != $effect[none])&lt;br /&gt;
      print(doodad +&amp;quot; grants &amp;quot;+ eff);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Return the effect granted by drinking a particular potion.|&lt;br /&gt;
code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
effect potion_to_effect(item potion) }&lt;br /&gt;
   return effect_modifier(potion, &amp;quot;effect&amp;quot;);&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
more_info= See [http://kolmafia.us/showthread.php?802 this thread] for details.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|boolean_modifier|numeric_modifier|stat_modifier|string_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Numeric_modifier&amp;diff=2655</id>
		<title>Numeric modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Numeric_modifier&amp;diff=2655"/>
		<updated>2020-07-01T21:02:14Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: more info about other functions/list of modifiers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|numeric_modifier}}{{&lt;br /&gt;
#vardefine:return_type|float}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function3={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function4={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|effect|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function5={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|skill|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
p1desc={{Pspan|check_me}} is the string, item, effect or skill to check|&lt;br /&gt;
p2desc={{Pspan|modifier_name}} is the &amp;lt;b&amp;gt;[[modifiers|modifier]]&amp;lt;/b&amp;gt; to check|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns your current modifier total for {{pspan|modifier_name}}, or the amount of modification from {{pspan|check_me}} if specified.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Special Syntax for Familiars===&lt;br /&gt;
{{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|familiar|buddy}}|&lt;br /&gt;
parameter2={{Param|string|check_me}}|&lt;br /&gt;
parameter3={{Param|int|weight}}|&lt;br /&gt;
parameter4={{Param|item|equipment}}|&lt;br /&gt;
p1desc={{Pspan|buddy}} is the familiar to check|&lt;br /&gt;
p2desc={{Pspan|check_me}} is the modifier to check|&lt;br /&gt;
p3desc={{Pspan|weight}} is the familiar&#039;s weight (buffed, not including equipment)|&lt;br /&gt;
p4desc={{Pspan|equipment}} is the familiar&#039;s equipment|&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;p&amp;gt;Returns the familiar&#039;s effect on this modifier (for instance, a baby gravy fairy would return some positive float for &amp;quot;Item Drop&amp;quot;).|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Prints your current Initiative:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float init = numeric_modifier( &amp;quot;initiative&amp;quot; );&lt;br /&gt;
print(init);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Function that checks if a single effect from a given list will buff your muscle over an amount goal. The name of the first effect to satisfy the goal is printed, or you are warned if none is found.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean buffMuscleTo( int goal ) {&lt;br /&gt;
   int current_muscle = my_buffedstat( $stat[Muscle] ) ;&lt;br /&gt;
   int base_muscle = my_basestat( $stat[Muscle] ) ;&lt;br /&gt;
   int muscle_increase ;&lt;br /&gt;
   if ( current_muscle &amp;gt;= goal ) return true ;&lt;br /&gt;
   &lt;br /&gt;
   foreach it in $effects[Tomato Power, Phorcefullness, Gr8tness, Incredibly Hulking] {&lt;br /&gt;
      if ( have_effect(it) &amp;gt; 0 ) continue ;&lt;br /&gt;
      muscle_increase = floor( base_muscle * numeric_modifier( it, &amp;quot;Muscle Percent&amp;quot; ) / 100 );&lt;br /&gt;
      if ( current_muscle + muscle_increase &amp;gt;= goal ) {&lt;br /&gt;
         print(it + &amp;quot; will bring your muscle over &amp;quot; + goal);&lt;br /&gt;
         return true;&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   print(&amp;quot;No effect found&amp;quot;);&lt;br /&gt;
   return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
code2={{CodeSample|&lt;br /&gt;
title=Potion/effect-giving items|&lt;br /&gt;
description=To get a modifier from a consumable which gives an effect, it is first necessary to convert the item into its given effect with [[effect_modifier]]. &amp;lt;br&amp;gt; This snippet calculates what your meat drop bonus would be after eating a {{kolwiki|sweet roll alabama}}:|&lt;br /&gt;
code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float meat_boost = numeric_modifier( &amp;quot;meat drop&amp;quot; );&lt;br /&gt;
effect effect_from_item = effect_modifier( $item[Sweet roll Alabama] , &amp;quot;effect&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
meat_boost += numeric_modifier( effect_from_item , &amp;quot;meat drop&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
cli_equiv=The CLI command &amp;quot;modtrace&amp;quot; gives access to the same information when the correct parameters are specified.|&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
more_info= For a full list of modifiers, see [[modifiers]].&amp;lt;br&amp;gt;&lt;br /&gt;
For more information about numeric_modifier(), see the following thread: [http://kolmafia.us/showthread.php?802  List].|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|boolean_modifier|effect_modifier|stat_modifier|string_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Numeric_modifier&amp;diff=2654</id>
		<title>Numeric modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Numeric_modifier&amp;diff=2654"/>
		<updated>2020-07-01T20:47:29Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: add the use of effect_modifier() to get potions&amp;#039; effect modifiers&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|numeric_modifier}}{{&lt;br /&gt;
#vardefine:return_type|float}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function2={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function3={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function4={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|effect|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function5={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|skill|check_me}}|&lt;br /&gt;
parameter2={{Param|string|modifier_name}}|&lt;br /&gt;
p1desc={{Pspan|check_me}} is the string, item, effect or skill to check|&lt;br /&gt;
p2desc={{Pspan|modifier_name}} is the modifier to check|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns your current modifier total for {{pspan|modifier_name}}, or the amount of modification from {{pspan|check_me}} if specified.&amp;lt;/p&amp;gt;&lt;br /&gt;
===Special Syntax for Familiars===&lt;br /&gt;
{{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|familiar|buddy}}|&lt;br /&gt;
parameter2={{Param|string|check_me}}|&lt;br /&gt;
parameter3={{Param|int|weight}}|&lt;br /&gt;
parameter4={{Param|item|equipment}}|&lt;br /&gt;
p1desc={{Pspan|buddy}} is the familiar to check|&lt;br /&gt;
p2desc={{Pspan|check_me}} is the modifier to check|&lt;br /&gt;
p3desc={{Pspan|weight}} is the familiar&#039;s weight (buffed, not including equipment)|&lt;br /&gt;
p4desc={{Pspan|equipment}} is the familiar&#039;s equipment|&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;p&amp;gt;Returns the familiar&#039;s effect on this modifier (for instance, a baby gravy fairy would return some positive float for &amp;quot;Item Drop&amp;quot;).|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Prints your current Initiative:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float init = numeric_modifier( &amp;quot;initiative&amp;quot; );&lt;br /&gt;
print(init);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=Function that checks if a single effect from a given list will buff your muscle over an amount goal. The name of the first effect to satisfy the goal is printed, or you are warned if none is found.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean buffMuscleTo( int goal ) {&lt;br /&gt;
   int current_muscle = my_buffedstat( $stat[Muscle] ) ;&lt;br /&gt;
   int base_muscle = my_basestat( $stat[Muscle] ) ;&lt;br /&gt;
   int muscle_increase ;&lt;br /&gt;
   if ( current_muscle &amp;gt;= goal ) return true ;&lt;br /&gt;
   &lt;br /&gt;
   foreach it in $effects[Tomato Power, Phorcefullness, Gr8tness, Incredibly Hulking] {&lt;br /&gt;
      if ( have_effect(it) &amp;gt; 0 ) continue ;&lt;br /&gt;
      muscle_increase = floor( base_muscle * numeric_modifier( it, &amp;quot;Muscle Percent&amp;quot; ) / 100 );&lt;br /&gt;
      if ( current_muscle + muscle_increase &amp;gt;= goal ) {&lt;br /&gt;
         print(it + &amp;quot; will bring your muscle over &amp;quot; + goal);&lt;br /&gt;
         return true;&lt;br /&gt;
      }&lt;br /&gt;
   }&lt;br /&gt;
   print(&amp;quot;No effect found&amp;quot;);&lt;br /&gt;
   return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
code2={{CodeSample|&lt;br /&gt;
title=Potion/effect-giving items|&lt;br /&gt;
description=To get a modifier from a consumable which gives an effect, it is first necessary to convert the item into its given effect with [[effect_modifier]]. &amp;lt;br&amp;gt; This snippet calculates what your meat drop bonus would be after eating a {{kolwiki|sweet roll alabama}}:|&lt;br /&gt;
code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float meat_boost = numeric_modifier( &amp;quot;meat drop&amp;quot; );&lt;br /&gt;
effect effect_from_item = effect_modifier( $item[Sweet roll Alabama] , &amp;quot;effect&amp;quot; );&lt;br /&gt;
&lt;br /&gt;
meat_boost += numeric_modifier( effect_from_item , &amp;quot;meat drop&amp;quot; );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
cli_equiv=The CLI command &amp;quot;modtrace&amp;quot; gives access to the same information when the correct parameters are specified.|&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
more_info= For a full list of numeric modifiers, see the following thread: [http://kolmafia.us/showthread.php?802  List].|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{SeeAlso|effect_modifier}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Modifier Functions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Your_Character&amp;diff=2021</id>
		<title>Your Character</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Your_Character&amp;diff=2021"/>
		<updated>2020-06-30T23:23:06Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Viewable Info */ get_campground and get_dwelling&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Viewable Info==&lt;br /&gt;
{{flink|string|my_name|desc=Returns your character&#039;s name in lowercase.}}&lt;br /&gt;
{{flink|string|my_id|desc=Returns your character ID.}}&lt;br /&gt;
{{flink|int|get_clan_id|desc=Returns the ID number of the character&#039;s current clan.}}&lt;br /&gt;
{{flink|string|get_clan_name|desc=Returns the name of the character&#039;s current clan.}}&lt;br /&gt;
{{Flink|int|my_ascensions|desc=Returns the number of times your character has ascended.}}&lt;br /&gt;
{{flink|class|my_class|desc=Returns your class.}}&lt;br /&gt;
{{flink|int|my_level|desc=Returns your level.}}&lt;br /&gt;
{{flink|int|my_adventures|desc=Returns the number of adventures you have remaining.}}&lt;br /&gt;
{{flink|int|total_turns_played|desc=Returns total turns played since the character was created.}}&lt;br /&gt;
{{flink|int|turns_played}}&lt;br /&gt;
{{flink|int|my_turncount|desc=Both functions return the number of adventures used this ascension.}}&lt;br /&gt;
{{flink|int|my_daycount|desc=Return the number of days used this ascension.}}&lt;br /&gt;
{{flink|stat|my_primestat|desc=Returns the main stat of your current class.}}&lt;br /&gt;
{{flink|int|my_basestat|stat|desc=Returns your base value in the given stat (or substat).}}&lt;br /&gt;
{{flink|int|my_buffedstat|stat|desc=Returns your buffed value in the given stat (or substat).}}&lt;br /&gt;
{{flink|boolean|hippy_stone_broken|desc=Reports if your Hippy Stone is currently broken.}}&lt;br /&gt;
{{flink|int|pvp_attacks_left|desc=Returns number of PvP attacks remaining.}}&lt;br /&gt;
{{flink|int|total_free_rests|desc=Returns the total number of free rests available to your character.}}&lt;br /&gt;
{{flink|int [item]|get_campground|desc=Returns a map of your campground items as integers, keyed by item names.}}&lt;br /&gt;
{{flink|item|get_dwelling|desc=Returns the item corresponding with your dwelling (the item used to get the dwelling).}}&lt;br /&gt;
{{flink|thrall|my_thrall|desc=Returns your current pasta thrall.}}&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
{{flink|int|my_hp|desc=Returns your current HP.}}&lt;br /&gt;
{{flink|int|my_mp|desc=Returns your current MP.}}&lt;br /&gt;
{{flink|int|my_maxhp|desc=Returns your current maximum HP.}}&lt;br /&gt;
{{flink|int|my_maxmp|desc=Returns your current maximum MP.}}&lt;br /&gt;
{{flink|int|my_soulsauce|desc=Returns your current Soulsauce.}}&lt;br /&gt;
{{flink|int|my_audience|desc=Returns your current Audience.}}&lt;br /&gt;
{{flink|int|my_thunder|desc=Returns your current Thunder.}}&lt;br /&gt;
{{flink|int|my_rain|desc=Returns your current Rain.}}&lt;br /&gt;
{{flink|int|my_lightning|desc=Returns your current Lightning.}}&lt;br /&gt;
&lt;br /&gt;
==Familiars and Substitutes==&lt;br /&gt;
{{flink|familiar|my_familiar|desc=Returns your current familiar.}}&lt;br /&gt;
{{flink|int|familiar_weight|familiar|desc=Returns the base weight of the specified familiar.}}&lt;br /&gt;
{{flink|boolean|is_familiar_equipment_locked|desc=Returns lock status of familiar equipment.}}&lt;br /&gt;
{{flink|void|lock_familiar_equipment|boolean|desc=Locks or Unlocks familiar equipment.}}&lt;br /&gt;
{{flink|int|minstrel_level|desc=Reports Clancy&#039;s level.}}&lt;br /&gt;
{{flink|item|minstrel_instrument|desc=Reports Clancy&#039;s equipped item.}}&lt;br /&gt;
{{flink|boolean|minstrel_quest|desc=Reports if Clancy has a new quest for you.}}&lt;br /&gt;
{{flink|string|my_companion|desc=Returns your current companion.}}&lt;br /&gt;
&lt;br /&gt;
==Hidden Info==&lt;br /&gt;
{{flink|string|my_hash|desc=Returns the password hash for your current session.}}&lt;br /&gt;
{{flink|stat|current_hit_stat|desc=Returns the stat currently used to calculate to-hit percentage.}}&lt;br /&gt;
{{flink|int|buffed_hit_stat|desc=Returns the buffed value of your currently used to-hit stat.}}&lt;br /&gt;
{{flink|int|raw_damage_absorption|desc=Returns your current DA total.}}&lt;br /&gt;
{{flink|float|damage_absorption_percent|desc=Returns the percentage of damage mitigated by your DA.}}&lt;br /&gt;
{{flink|int|damage_reduction|desc=Returns the amount of damage reduction your character currently has.}}&lt;br /&gt;
{{flink|float|elemental_resistance|element|desc=Returns the percentage of damage reduction to the given element based on your current resistance to that element.}}&lt;br /&gt;
{{flink|float|combat_rate_modifier|desc=Returns the percentage adjustment to your combat rate.}}&lt;br /&gt;
{{flink|float|initiative_modifier|desc=Returns the percentage adjustment to your chance of gaining initiative.}}&lt;br /&gt;
{{flink|float|experience_bonus|desc=Returns the amount of bonus experience your receive after combat.}}&lt;br /&gt;
{{flink|float|meat_drop_modifier|desc=Returns the percentage adjustment to meat drops after combat.}}&lt;br /&gt;
{{flink|float|item_drop_modifier|desc=Returns the percentage adjustment to item drops after combat.}}&lt;br /&gt;
{{flink|int|monster_level_adjustment|desc=Returns the total +ML you have active, including your sign-specific device.}}&lt;br /&gt;
{{flink|stat|stat_bonus_today}}&lt;br /&gt;
{{flink|stat|stat_bonus_tomorrow|desc=These two functions report on what stat has a stat-day bonus or $stat[none] if it isn&#039;t a stat day.}}&lt;br /&gt;
{{flink|int|current_mcd|desc=Returns the current setting of your sign-specific +ML device.}}&lt;br /&gt;
{{flink|int|weight_adjustment|desc=Returns the cumulative total of all familiar weight adjustments from all sources.}}&lt;br /&gt;
{{flink|boolean|get_ignore_zone_warnings|desc=Returns the value of the KoL option to disable &amp;quot;This area might be too tough for you&amp;quot; warnings.}}&lt;br /&gt;
{{flink|string [location] [int]|get_florist_plants|desc=Returns the a map of all plants currently planted in every location.}}&lt;br /&gt;
&lt;br /&gt;
==Sign &amp;amp; Path==&lt;br /&gt;
{{flink|boolean|can_eat|desc=Reports on whether your characters path allows food consumption.}}&lt;br /&gt;
{{flink|boolean|can_drink|desc=Reports on whether your characters path allows booze consumption}}&lt;br /&gt;
{{flink|boolean|can_interact|desc=Reports on whether your character can access the mall, gift packages, etc.}}&lt;br /&gt;
{{flink|boolean|in_hardcore|desc=Reports on whether your character is under Hardcore restrictions.}}&lt;br /&gt;
{{flink|item|daily_special|desc=Returns the daily special at your sign eatery.}}&lt;br /&gt;
{{flink|boolean|in_moxie_sign}}&lt;br /&gt;
{{flink|boolean|in_muscle_sign}}&lt;br /&gt;
{{flink|boolean|in_mysticality_sign}}&lt;br /&gt;
{{flink|boolean|in_bad_moon|desc=These four functions report on the stat gains granted by your character&#039;s ascension moon sign.}}&lt;br /&gt;
{{flink|string|my_path|desc=The ascension path your character chose.}}&lt;br /&gt;
{{flink|string|my_path_id|desc=The number of the ascension path your character chose.}}&lt;br /&gt;
{{flink|string|my_sign|desc=The moon sign your character ascended under.}}&lt;br /&gt;
&lt;br /&gt;
==Consumption==&lt;br /&gt;
{{flink|int|my_fullness|desc=Returns how full you are.}}&lt;br /&gt;
{{flink|int|fullness_limit|desc=Returns your maximum fullness.}}&lt;br /&gt;
{{flink|int|my_inebriety|desc=Returns your current drunkenness.}}&lt;br /&gt;
{{flink|int|inebriety_limit|desc=Returns your maximum safe drunk (before overdrinking).}}&lt;br /&gt;
{{flink|int|my_spleen_use|desc=Returns your current spleen use.}}&lt;br /&gt;
{{flink|int|spleen_limit|desc=Returns your spleen limit.}}&lt;br /&gt;
&lt;br /&gt;
==Location Availability==&lt;br /&gt;
{{flink|boolean|black_market_available|desc=Returns the availability of the Black Market.}}&lt;br /&gt;
{{flink|boolean|canadia_available|desc=Returns the availability of Little Canadia.}}&lt;br /&gt;
{{flink|boolean|dispensary_available|desc=Returns the availability of the Knob Dispensary.}}&lt;br /&gt;
{{flink|boolean|florist_available|desc=Returns the availability of The Florist Friar&#039;s Cottage.}}&lt;br /&gt;
{{flink|boolean|gnomads_available|desc=Returns the availability of the Gnomish Gnomad Camp.}}&lt;br /&gt;
{{flink|boolean|guild_store_available|desc=Returns the availability of your guild store.}}&lt;br /&gt;
{{flink|boolean|hidden_temple_unlocked|desc=Returns the availability of the Hidden Temple.}}&lt;br /&gt;
{{flink|boolean|hippy_store_available|desc=Returns the availability of the Hippy Store.}}&lt;br /&gt;
{{flink|boolean|knoll_available|desc=Returns the availability of the Degrassi Knoll.}}&lt;br /&gt;
{{flink|boolean|white_citadel_available|desc=Returns the availability of White Citadel.}}&lt;br /&gt;
&lt;br /&gt;
==Misc.==&lt;br /&gt;
{{Flink|string|eudora|desc=Returns your current Eudora correspondent.}}&lt;br /&gt;
{{Flink|boolean|galaktik_cures_discounted|desc=Returns whether Doc&#039;s offers you a discount for quest completion.}}&lt;br /&gt;
{{Flink|int|is_unrestricted|desc=Checks whether a given game resource is available.}}&lt;br /&gt;
{{Flink|int|moon_light|desc=Returns the total lit moon segments.}}&lt;br /&gt;
{{Flink|int|moon_phase|desc=Returns the phase (0-15) of the main moons.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Available_amount&amp;diff=4266</id>
		<title>Available amount</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Available_amount&amp;diff=4266"/>
		<updated>2020-06-23T00:34:28Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: storage_amount()&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|available_amount}}{{&lt;br /&gt;
#vardefine:return_type|int}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|item|it}}|&lt;br /&gt;
p1desc={{Pspan|it}} is the item to check|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the total number available of a given item in all inventory sections accessible to your character based on current restrictions, including equipped items (for equipment). In Ronin, this includes free pulls, but does not include any other items in Hangk&#039;s Storage. Once out of Ronin/run, if [[KoLmafia_Properties#Global_Variables|autoSatisfyWithStorage]] is set to true, this includes items in Hangk&#039;s Storage.&lt;br /&gt;
If [[KoLmafia_Properties#Global_Variables|autoSatisfyWithCloset]] is set to true, this includes closet. If [[KoLmafia_Properties#Global_Variables|autoSatisfyWithStash]] is set to true, this includes clan stash.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Sample|&lt;br /&gt;
description=Enumerates total number of scrolls of ancient forbidden unspeakable evil.|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int current_afue = available_amount($item[scroll of ancient forbidden unspeakable evil]);&lt;br /&gt;
// Calculate minimum of pens, paper and ink:&lt;br /&gt;
int make_afue = available_amount($item[disintegrating quill pen]);&lt;br /&gt;
make_afue = min(make_afue, available_amount($item[tattered scrap of paper]));&lt;br /&gt;
make_afue = min(make_afue, available_amount($item[inkwell]));&lt;br /&gt;
print(&amp;quot;Currently possess &amp;quot;+ current_afue + &amp;quot; afue scrolls.&amp;quot;);&lt;br /&gt;
print(&amp;quot;Can make another &amp;quot;+ make_afue +&amp;quot; scrolls from parts.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|closet_amount|display_amount|equipped_amount|item_amount|shop_amount|stash_amount|storage_amount}}|&lt;br /&gt;
more_info=Information on handling free pulls is at [[Tips, Tricks and Workarounds#Free Pulls|Tips, Tricks and Workarounds]].|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Item Management]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Path_name_to_id&amp;diff=8547</id>
		<title>Path name to id</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Path_name_to_id&amp;diff=8547"/>
		<updated>2020-06-08T00:48:04Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|path_name_to_id}}{{&lt;br /&gt;
#vardefine:return_type|int}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|name}}|&lt;br /&gt;
p1desc={{Pspan|name}} is the full, exact, case-sensitive name of the path to convert.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the specified path {{pspan|name}} as its {{kolwiki|Paths_by_number|path number}}.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=Following example shows basic path_name_to_id operations.||&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string first = &amp;quot;Bees Hate You&amp;quot;;&lt;br /&gt;
string second = &amp;quot;G-Lover&amp;quot;;&lt;br /&gt;
string third = &amp;quot;Live. Ascend. Repeat.&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
print(first+&amp;quot; gives &amp;quot;+path_name_to_id(first)+&amp;quot;.&amp;quot;);&lt;br /&gt;
print(second+&amp;quot; gives &amp;quot;+path_name_to_id(second)+&amp;quot;.&amp;quot;);&lt;br /&gt;
print(third+&amp;quot; gives &amp;quot;+path_name_to_id(third)+&amp;quot;.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
Gives the following output.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Bees Hate You gives 4.&lt;br /&gt;
G-Lover gives 33.&lt;br /&gt;
Live. Ascend. Repeat. gives 31.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|my_path|my_path_id|path_id_to_name}}|&lt;br /&gt;
special=Returns -1 if given an incorrect/unknown name. Also, &amp;quot;Unrestricted&amp;quot; and &amp;quot;Aftercore&amp;quot; are not valid inputs for 0. &amp;quot;None&amp;quot; is instead expected.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Datatype Conversions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Path_name_to_id&amp;diff=8546</id>
		<title>Path name to id</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Path_name_to_id&amp;diff=8546"/>
		<updated>2020-06-08T00:42:28Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|path_name_to_id}}{{&lt;br /&gt;
#vardefine:return_type|int}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|name}}|&lt;br /&gt;
p1desc={{Pspan|name}} is the &#039;&#039;exact&#039;&#039; name of the path to convert.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the specified path {{pspan|name}} as its {{kolwiki|Paths_by_number|path number}}.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=Following example shows basic path_name_to_id operations.||&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string first = &amp;quot;Bees Hate You&amp;quot;;&lt;br /&gt;
string second = &amp;quot;G-Lover&amp;quot;;&lt;br /&gt;
string third = &amp;quot;Live. Ascend. Repeat.&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
print(first+&amp;quot; gives &amp;quot;+path_name_to_id(first)+&amp;quot;.&amp;quot;);&lt;br /&gt;
print(second+&amp;quot; gives &amp;quot;+path_name_to_id(second)+&amp;quot;.&amp;quot;);&lt;br /&gt;
print(third+&amp;quot; gives &amp;quot;+path_name_to_id(third)+&amp;quot;.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
Gives the following output.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Bees Hate You gives 4.&lt;br /&gt;
G-Lover gives 33.&lt;br /&gt;
Live. Ascend. Repeat. gives 31.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|my_path|my_path_id|path_id_to_name}}|&lt;br /&gt;
special=The input is case-sensitive, and doesn&#039;t accept partial matches. Also, &amp;quot;Unrestricted&amp;quot; and &amp;quot;Aftercore&amp;quot; are not valid inputs. &amp;quot;None&amp;quot; is instead expected.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Datatype Conversions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Datatype_Conversions&amp;diff=1843</id>
		<title>Datatype Conversions</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Datatype_Conversions&amp;diff=1843"/>
		<updated>2020-06-08T00:14:51Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: path_id_to_name and path_name_to_id&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;p&amp;gt;These functions will convert one type of data to another.&amp;lt;/p&amp;gt;&lt;br /&gt;
{{flink|boolean|to_boolean|any|desc=Converts any datatype to a boolean.}}&lt;br /&gt;
{{flink|bounty|to_bounty|string|desc=Converts a string to a bounty.}}&lt;br /&gt;
{{flink|class|to_class|string|desc=Converts a string to a class.}}&lt;br /&gt;
{{flink|effect|to_effect|int}}&lt;br /&gt;
{{flink|effect|to_effect|string}}&lt;br /&gt;
{{flink|effect|to_effect|skill|desc=Converts an int, string or skill to an effect.}}&lt;br /&gt;
{{flink|element|to_element|string|desc=Converts a string to an element.}}&lt;br /&gt;
{{flink|familiar|to_familiar|int}}&lt;br /&gt;
{{flink|familiar|to_familiar|string|desc=Converts an int or a string to a familiar.}}&lt;br /&gt;
{{flink|float|to_float|any|desc=Converts from any datatype to a float.}}&lt;br /&gt;
{{flink|int|path_name_to_id|string}}&lt;br /&gt;
{{flink|int|to_int|any|desc=Converts from any datatype to an int.}}&lt;br /&gt;
{{flink|item|to_item|string}}&lt;br /&gt;
{{flink|item|to_item|int}}&lt;br /&gt;
{{flink|item|to_item|string|int|desc=Converts an int or a string to an item (optionally allowing plural strings with both parameters).}}&lt;br /&gt;
{{flink|location|to_location|string|desc=Converts a string to a location.}}&lt;br /&gt;
{{flink|monster|to_monster|string|desc=Converts a string to a monster.}}&lt;br /&gt;
{{flink|phylum|to_phylum|string|desc=Converts a string to a phylum.}}&lt;br /&gt;
{{flink|string|to_plural|item|desc=Converts an item into the string value of its plural.}}&lt;br /&gt;
{{flink|skill|to_skill|int}}&lt;br /&gt;
{{flink|skill|to_skill|string}}&lt;br /&gt;
{{flink|skill|to_skill|effect|desc=Converts an int, string or effect to a skill.}}&lt;br /&gt;
{{flink|slot|to_slot|item}}&lt;br /&gt;
{{flink|slot|to_slot|string|desc=Converts an item or string to a slot.}}&lt;br /&gt;
{{flink|stat|to_stat|string|desc=Converts a string to a stat.}}&lt;br /&gt;
{{flink|string|path_id_to_name|int}}&lt;br /&gt;
{{flink|string|to_string|any|desc=Converts any datatype to a string.}}&lt;br /&gt;
{{flink|thrall|to_thrall|string}}&lt;br /&gt;
{{flink|thrall|to_thrall|int|desc=Converts a string or int to a thrall.}}&lt;br /&gt;
== Historical note ==&lt;br /&gt;
ASH did not originally support polymorphic functions, so it was not possible to have (for example) a single &#039;&#039;&#039;to_string(any)&#039;&#039;&#039; function that worked on any datatype.  Instead, there were separate &#039;&#039;&#039;int_to_string(int)&#039;&#039;&#039;, &#039;&#039;&#039;item_to_string(item)&#039;&#039;&#039;, etc. functions.  You may see these used in older scripts, and in fact they still work.  The rule is that if a function name is not otherwise defined anywhere, and it ends with one of the modern type conversion function names shown above, it is treated as a call to the modern function.  No check is made to verify that the chopped-off portion of the old function name actually matches the type of its parameter.&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Path_name_to_id&amp;diff=8545</id>
		<title>Path name to id</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Path_name_to_id&amp;diff=8545"/>
		<updated>2020-06-08T00:03:25Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: temporary draft until function is fixed&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|path_name_to_id}}{{&lt;br /&gt;
#vardefine:return_type|int}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|string|name}}|&lt;br /&gt;
p1desc={{Pspan|name}} is the partial(?) name of the path to convert.|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the specified path {{pspan|name}} as its {{kolwiki|Paths_by_number|path number}}. (This function is not yet working; this is a placeholder until it does and can be tested)|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=&amp;lt;Placeholder&amp;gt;.||&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;Placeholder&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
Gives the following output.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;Placeholder&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|my_path|my_path_id|path_id_to_name}}|&lt;br /&gt;
special=&amp;lt;Placeholder&amp;gt;.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Datatype Conversions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Path_id_to_name&amp;diff=8544</id>
		<title>Path id to name</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Path_id_to_name&amp;diff=8544"/>
		<updated>2020-06-07T22:37:56Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: Created page with &amp;quot;{{ #vardefine:name|path_id_to_name}}{{ #vardefine:return_type|string}}{{  FunctionPage| name={{#var:name}}|  function1={{Function| name={{#var:name}}| aggregate={{#var:aggrega...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|path_id_to_name}}{{&lt;br /&gt;
#vardefine:return_type|string}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
parameter1={{Param|int|id}}|&lt;br /&gt;
p1desc={{Pspan|id}} is the {{kolwiki|Paths_by_number|ID of the path}} to convert|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the name of the specified path {{pspan|id}}.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=Following example shows basic path_id_to_name operations.||&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int first = 3;&lt;br /&gt;
int second = 7;&lt;br /&gt;
int third = 24;&lt;br /&gt;
&lt;br /&gt;
print(first+&amp;quot; gives &amp;quot;+path_id_to_name(first)+&amp;quot;.&amp;quot;);&lt;br /&gt;
print(second+&amp;quot; gives &amp;quot;+path_id_to_name(second)+&amp;quot;.&amp;quot;);&lt;br /&gt;
print(third+&amp;quot; gives &amp;quot;+path_id_to_name(third)+&amp;quot;.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
Gives the following output.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
3 gives Oxygenarian.&lt;br /&gt;
7 gives Trendy.&lt;br /&gt;
24 gives One Crazy Random Summer.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|my_path|my_path_id|path_name_to_id}}|&lt;br /&gt;
special=Returns &amp;quot;None&amp;quot; when submitting an ID which doesn&#039;t have a known path tied to, such as 5 (never released), or 60 (not yet known). Also, the 3 first unknown paths return &amp;quot;Path {{Pspan|id}}&amp;quot;, for internal reasons (as of writing this, for example, 40, 41 and 42 return &amp;quot;Path 40&amp;quot;, &amp;quot;Path 41&amp;quot; and &amp;quot;Path 42&amp;quot;.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Datatype Conversions]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Your_Character&amp;diff=2020</id>
		<title>Your Character</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Your_Character&amp;diff=2020"/>
		<updated>2020-06-07T22:04:33Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Sign &amp;amp; Path */ + my_path_id&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Viewable Info==&lt;br /&gt;
{{flink|string|my_name|desc=Returns your character&#039;s name in lowercase.}}&lt;br /&gt;
{{flink|string|my_id|desc=Returns your character ID.}}&lt;br /&gt;
{{flink|int|get_clan_id|desc=Returns the ID number of the character&#039;s current clan.}}&lt;br /&gt;
{{flink|string|get_clan_name|desc=Returns the name of the character&#039;s current clan.}}&lt;br /&gt;
{{Flink|int|my_ascensions|desc=Returns the number of times your character has ascended.}}&lt;br /&gt;
{{flink|class|my_class|desc=Returns your class.}}&lt;br /&gt;
{{flink|int|my_level|desc=Returns your level.}}&lt;br /&gt;
{{flink|int|my_adventures|desc=Returns the number of adventures you have remaining.}}&lt;br /&gt;
{{flink|int|total_turns_played|desc=Returns total turns played since the character was created.}}&lt;br /&gt;
{{flink|int|turns_played}}&lt;br /&gt;
{{flink|int|my_turncount|desc=Both functions return the number of adventures used this ascension.}}&lt;br /&gt;
{{flink|int|my_daycount|desc=Return the number of days used this ascension.}}&lt;br /&gt;
{{flink|stat|my_primestat|desc=Returns the main stat of your current class.}}&lt;br /&gt;
{{flink|int|my_basestat|stat|desc=Returns your base value in the given stat (or substat).}}&lt;br /&gt;
{{flink|int|my_buffedstat|stat|desc=Returns your buffed value in the given stat (or substat).}}&lt;br /&gt;
{{flink|boolean|hippy_stone_broken|desc=Reports if your Hippy Stone is currently broken.}}&lt;br /&gt;
{{flink|int|pvp_attacks_left|desc=Returns number of PvP attacks remaining.}}&lt;br /&gt;
{{flink|int|total_free_rests|desc=Returns the total number of free rests available to your character.}}&lt;br /&gt;
{{flink|thrall|my_thrall|desc=Returns your current pasta thrall.}}&lt;br /&gt;
&lt;br /&gt;
==Resources==&lt;br /&gt;
{{flink|int|my_hp|desc=Returns your current HP.}}&lt;br /&gt;
{{flink|int|my_mp|desc=Returns your current MP.}}&lt;br /&gt;
{{flink|int|my_maxhp|desc=Returns your current maximum HP.}}&lt;br /&gt;
{{flink|int|my_maxmp|desc=Returns your current maximum MP.}}&lt;br /&gt;
{{flink|int|my_soulsauce|desc=Returns your current Soulsauce.}}&lt;br /&gt;
{{flink|int|my_audience|desc=Returns your current Audience.}}&lt;br /&gt;
{{flink|int|my_thunder|desc=Returns your current Thunder.}}&lt;br /&gt;
{{flink|int|my_rain|desc=Returns your current Rain.}}&lt;br /&gt;
{{flink|int|my_lightning|desc=Returns your current Lightning.}}&lt;br /&gt;
&lt;br /&gt;
==Familiars and Substitutes==&lt;br /&gt;
{{flink|familiar|my_familiar|desc=Returns your current familiar.}}&lt;br /&gt;
{{flink|int|familiar_weight|familiar|desc=Returns the base weight of the specified familiar.}}&lt;br /&gt;
{{flink|boolean|is_familiar_equipment_locked|desc=Returns lock status of familiar equipment.}}&lt;br /&gt;
{{flink|void|lock_familiar_equipment|boolean|desc=Locks or Unlocks familiar equipment.}}&lt;br /&gt;
{{flink|int|minstrel_level|desc=Reports Clancy&#039;s level.}}&lt;br /&gt;
{{flink|item|minstrel_instrument|desc=Reports Clancy&#039;s equipped item.}}&lt;br /&gt;
{{flink|boolean|minstrel_quest|desc=Reports if Clancy has a new quest for you.}}&lt;br /&gt;
{{flink|string|my_companion|desc=Returns your current companion.}}&lt;br /&gt;
&lt;br /&gt;
==Hidden Info==&lt;br /&gt;
{{flink|string|my_hash|desc=Returns the password hash for your current session.}}&lt;br /&gt;
{{flink|stat|current_hit_stat|desc=Returns the stat currently used to calculate to-hit percentage.}}&lt;br /&gt;
{{flink|int|buffed_hit_stat|desc=Returns the buffed value of your currently used to-hit stat.}}&lt;br /&gt;
{{flink|int|raw_damage_absorption|desc=Returns your current DA total.}}&lt;br /&gt;
{{flink|float|damage_absorption_percent|desc=Returns the percentage of damage mitigated by your DA.}}&lt;br /&gt;
{{flink|int|damage_reduction|desc=Returns the amount of damage reduction your character currently has.}}&lt;br /&gt;
{{flink|float|elemental_resistance|element|desc=Returns the percentage of damage reduction to the given element based on your current resistance to that element.}}&lt;br /&gt;
{{flink|float|combat_rate_modifier|desc=Returns the percentage adjustment to your combat rate.}}&lt;br /&gt;
{{flink|float|initiative_modifier|desc=Returns the percentage adjustment to your chance of gaining initiative.}}&lt;br /&gt;
{{flink|float|experience_bonus|desc=Returns the amount of bonus experience your receive after combat.}}&lt;br /&gt;
{{flink|float|meat_drop_modifier|desc=Returns the percentage adjustment to meat drops after combat.}}&lt;br /&gt;
{{flink|float|item_drop_modifier|desc=Returns the percentage adjustment to item drops after combat.}}&lt;br /&gt;
{{flink|int|monster_level_adjustment|desc=Returns the total +ML you have active, including your sign-specific device.}}&lt;br /&gt;
{{flink|stat|stat_bonus_today}}&lt;br /&gt;
{{flink|stat|stat_bonus_tomorrow|desc=These two functions report on what stat has a stat-day bonus or $stat[none] if it isn&#039;t a stat day.}}&lt;br /&gt;
{{flink|int|current_mcd|desc=Returns the current setting of your sign-specific +ML device.}}&lt;br /&gt;
{{flink|int|weight_adjustment|desc=Returns the cumulative total of all familiar weight adjustments from all sources.}}&lt;br /&gt;
{{flink|boolean|get_ignore_zone_warnings|desc=Returns the value of the KoL option to disable &amp;quot;This area might be too tough for you&amp;quot; warnings.}}&lt;br /&gt;
{{flink|string [location] [int]|get_florist_plants|desc=Returns the a map of all plants currently planted in every location.}}&lt;br /&gt;
&lt;br /&gt;
==Sign &amp;amp; Path==&lt;br /&gt;
{{flink|boolean|can_eat|desc=Reports on whether your characters path allows food consumption.}}&lt;br /&gt;
{{flink|boolean|can_drink|desc=Reports on whether your characters path allows booze consumption}}&lt;br /&gt;
{{flink|boolean|can_interact|desc=Reports on whether your character can access the mall, gift packages, etc.}}&lt;br /&gt;
{{flink|boolean|in_hardcore|desc=Reports on whether your character is under Hardcore restrictions.}}&lt;br /&gt;
{{flink|item|daily_special|desc=Returns the daily special at your sign eatery.}}&lt;br /&gt;
{{flink|boolean|in_moxie_sign}}&lt;br /&gt;
{{flink|boolean|in_muscle_sign}}&lt;br /&gt;
{{flink|boolean|in_mysticality_sign}}&lt;br /&gt;
{{flink|boolean|in_bad_moon|desc=These four functions report on the stat gains granted by your character&#039;s ascension moon sign.}}&lt;br /&gt;
{{flink|string|my_path|desc=The ascension path your character chose.}}&lt;br /&gt;
{{flink|string|my_path_id|desc=The number of the ascension path your character chose.}}&lt;br /&gt;
{{flink|string|my_sign|desc=The moon sign your character ascended under.}}&lt;br /&gt;
&lt;br /&gt;
==Consumption==&lt;br /&gt;
{{flink|int|my_fullness|desc=Returns how full you are.}}&lt;br /&gt;
{{flink|int|fullness_limit|desc=Returns your maximum fullness.}}&lt;br /&gt;
{{flink|int|my_inebriety|desc=Returns your current drunkenness.}}&lt;br /&gt;
{{flink|int|inebriety_limit|desc=Returns your maximum safe drunk (before overdrinking).}}&lt;br /&gt;
{{flink|int|my_spleen_use|desc=Returns your current spleen use.}}&lt;br /&gt;
{{flink|int|spleen_limit|desc=Returns your spleen limit.}}&lt;br /&gt;
&lt;br /&gt;
==Location Availability==&lt;br /&gt;
{{flink|boolean|black_market_available|desc=Returns the availability of the Black Market.}}&lt;br /&gt;
{{flink|boolean|canadia_available|desc=Returns the availability of Little Canadia.}}&lt;br /&gt;
{{flink|boolean|dispensary_available|desc=Returns the availability of the Knob Dispensary.}}&lt;br /&gt;
{{flink|boolean|florist_available|desc=Returns the availability of The Florist Friar&#039;s Cottage.}}&lt;br /&gt;
{{flink|boolean|gnomads_available|desc=Returns the availability of the Gnomish Gnomad Camp.}}&lt;br /&gt;
{{flink|boolean|guild_store_available|desc=Returns the availability of your guild store.}}&lt;br /&gt;
{{flink|boolean|hidden_temple_unlocked|desc=Returns the availability of the Hidden Temple.}}&lt;br /&gt;
{{flink|boolean|hippy_store_available|desc=Returns the availability of the Hippy Store.}}&lt;br /&gt;
{{flink|boolean|knoll_available|desc=Returns the availability of the Degrassi Knoll.}}&lt;br /&gt;
{{flink|boolean|white_citadel_available|desc=Returns the availability of White Citadel.}}&lt;br /&gt;
&lt;br /&gt;
==Misc.==&lt;br /&gt;
{{Flink|string|eudora|desc=Returns your current Eudora correspondent.}}&lt;br /&gt;
{{Flink|boolean|galaktik_cures_discounted|desc=Returns whether Doc&#039;s offers you a discount for quest completion.}}&lt;br /&gt;
{{Flink|int|is_unrestricted|desc=Checks whether a given game resource is available.}}&lt;br /&gt;
{{Flink|int|moon_light|desc=Returns the total lit moon segments.}}&lt;br /&gt;
{{Flink|int|moon_phase|desc=Returns the phase (0-15) of the main moons.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=My_path_id&amp;diff=8543</id>
		<title>My path id</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=My_path_id&amp;diff=8543"/>
		<updated>2020-06-07T22:03:23Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: Created page with &amp;quot;{{ #vardefine:name|my_path_id}}{{ #vardefine:return_type|int}}{{  FunctionPage| name={{#var:name}}|  function1={{Function| name={{#var:name}}| aggregate={{#var:aggregate}}| re...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|my_path_id}}{{&lt;br /&gt;
#vardefine:return_type|int}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the {{kolwiki|Paths_by_number|ID of the path}} your character chose upon ascension (&amp;quot;0&amp;quot; when in aftercore).|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|my_path|path_id_to_name|path_name_to_id|my_sign|knoll_available|canadia_available|gnomads_available}}|&lt;br /&gt;
special=This function returns &amp;quot;0&amp;quot; when not logged in.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Your Character]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=My_path&amp;diff=7433</id>
		<title>My path</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=My_path&amp;diff=7433"/>
		<updated>2020-06-07T21:53:32Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: see also: the 3 new path ID functions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|my_path}}{{&lt;br /&gt;
#vardefine:return_type|string}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}|&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the path your character chose upon ascension (&amp;quot;None&amp;quot; when in aftercore).|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=This prints all the affects of your moon sign.|&lt;br /&gt;
code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
if(my_path() == &amp;quot;Bees Hate You&amp;quot;)&lt;br /&gt;
   print(&amp;quot;I&#039;m doing a Bees Hate You run.&amp;quot;);&lt;br /&gt;
else print(&amp;quot;Bees do not hate me, thank goodness.&amp;quot;);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
}}|&lt;br /&gt;
see_also={{SeeAlso|my_path_id|path_id_to_name|path_name_to_id|my_sign|knoll_available|canadia_available|gnomads_available}}|&lt;br /&gt;
special=This function returns &amp;quot;None&amp;quot; when not logged in.|&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Your Character]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Combat_rate_modifier&amp;diff=3928</id>
		<title>Combat rate modifier</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Combat_rate_modifier&amp;diff=3928"/>
		<updated>2020-06-03T21:46:24Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: functionally equivalent to numeric_modifier(&amp;quot;Combat Rate&amp;quot;)&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{&lt;br /&gt;
#vardefine:name|combat_rate_modifier}}{{&lt;br /&gt;
#vardefine:return_type|float}}{{&lt;br /&gt;
&lt;br /&gt;
FunctionPage|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
&lt;br /&gt;
function1={{Function|&lt;br /&gt;
name={{#var:name}}|&lt;br /&gt;
aggregate={{#var:aggregate}}|&lt;br /&gt;
return_type={{#var:return_type}}|&lt;br /&gt;
return_also={{#var:return_also}}&lt;br /&gt;
}}|&lt;br /&gt;
&lt;br /&gt;
function_description=Returns the current percentage change on combat frequency including equipment and effects.|&lt;br /&gt;
&lt;br /&gt;
code1={{CodeSample|&lt;br /&gt;
title=Code Samples|&lt;br /&gt;
description=Checks that your combat frequency modifier is positive (for example, before adventuring in the Purple Light District).|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
boolean is_combat_positive() {&lt;br /&gt;
   if(combat_rate_modifier() &amp;gt; 0) {&lt;br /&gt;
      return true;&lt;br /&gt;
   }&lt;br /&gt;
   return false;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
&lt;br /&gt;
moreinfo=This is functionally equivalent to doing &amp;lt;code&amp;gt;numeric_modifier(&amp;quot;Combat Rate&amp;quot;)&amp;lt;/code&amp;gt;}}|&lt;br /&gt;
&lt;br /&gt;
see_also={{SeeAlso|appearance_rates}}|&lt;br /&gt;
special=Returns 0.0 when not logged in.&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Your Character]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Location&amp;diff=1748</id>
		<title>Location</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Location&amp;diff=1748"/>
		<updated>2020-06-03T21:40:38Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Proxy Record Fields */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:location}}&lt;br /&gt;
&lt;br /&gt;
{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
This data type represents any location in KoL in which one can adventure.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $location[ none ], is too much to list and keep &lt;br /&gt;
up with here: please see the Wiki {{kolwiki|Locations}} page for more information.&lt;br /&gt;
&lt;br /&gt;
==Related Functions==&lt;br /&gt;
&lt;br /&gt;
{{Flink|boolean|adv1|location|int|string}}&lt;br /&gt;
{{Flink|boolean|adventure|int|location|{{opt|string}}}}&lt;br /&gt;
{{Flink|float [monster]|appearance_rates|location|{{opt|boolean}}}}&lt;br /&gt;
{{Flink|string [location, 3]|get_florist_plants}}&lt;br /&gt;
{{Flink|monster [int]|get_monsters|location}}&lt;br /&gt;
{{flink|int|jump_chance|location|{{opt|int}}|{{opt|int}}}}&lt;br /&gt;
{{Flink|location|my_location}}&lt;br /&gt;
{{Flink|void|set_location|location}}&lt;br /&gt;
{{Flink|location|to_location|strict_string}}&lt;br /&gt;
{{Flink|location|to_location|int}}&lt;br /&gt;
{{Flink|string|to_url|location}}&lt;br /&gt;
&lt;br /&gt;
==Proxy Record Fields==&lt;br /&gt;
&lt;br /&gt;
Here are the proxy record fields for locations.  Proxy records are discussed in more &lt;br /&gt;
detail [[Proxy Records|here]].&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;3&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1px&amp;quot; class=&amp;quot;sortable&amp;quot;&lt;br /&gt;
|- | style=&amp;quot;background-color: #F2F2F2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
! Default value&lt;br /&gt;
! ASH Accessor Function / Notes&lt;br /&gt;
|-&lt;br /&gt;
| nocombats&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| combat_percent&lt;br /&gt;
| float&lt;br /&gt;
| 0.0&lt;br /&gt;
| the chance of getting a combat encounter INCLUDING your combat_rate_modifier()&lt;br /&gt;
|-&lt;br /&gt;
| zone&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| parent&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| parentdesc&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| environment&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| bounty&lt;br /&gt;
| bounty&lt;br /&gt;
| none&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| combat_queue&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| noncombat_queue&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| turns_spent&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| kisses&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
| {{kolwiki|Dreadsylvania}}&lt;br /&gt;
|-&lt;br /&gt;
| recommended_stat&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| water_level&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
| {{kolwiki|Heavy Rains}}&lt;br /&gt;
|-&lt;br /&gt;
| wanderers&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
| whether wandering monsters can spawn in this zone&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]] [[Category:Data Types]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Location&amp;diff=1747</id>
		<title>Location</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Location&amp;diff=1747"/>
		<updated>2020-06-03T21:28:36Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* Proxy Record Fields */ added combat_percent, wanderers and described some fields&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:location}}&lt;br /&gt;
&lt;br /&gt;
{{TOCright}}&lt;br /&gt;
&lt;br /&gt;
This data type represents any location in KoL in which one can adventure.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $location[ none ], is too much to list and keep &lt;br /&gt;
up with here: please see the Wiki {{kolwiki|Locations}} page for more information.&lt;br /&gt;
&lt;br /&gt;
==Related Functions==&lt;br /&gt;
&lt;br /&gt;
{{Flink|boolean|adv1|location|int|string}}&lt;br /&gt;
{{Flink|boolean|adventure|int|location|{{opt|string}}}}&lt;br /&gt;
{{Flink|float [monster]|appearance_rates|location|{{opt|boolean}}}}&lt;br /&gt;
{{Flink|string [location, 3]|get_florist_plants}}&lt;br /&gt;
{{Flink|monster [int]|get_monsters|location}}&lt;br /&gt;
{{flink|int|jump_chance|location|{{opt|int}}|{{opt|int}}}}&lt;br /&gt;
{{Flink|location|my_location}}&lt;br /&gt;
{{Flink|void|set_location|location}}&lt;br /&gt;
{{Flink|location|to_location|strict_string}}&lt;br /&gt;
{{Flink|location|to_location|int}}&lt;br /&gt;
{{Flink|string|to_url|location}}&lt;br /&gt;
&lt;br /&gt;
==Proxy Record Fields==&lt;br /&gt;
&lt;br /&gt;
Here are the proxy record fields for locations.  Proxy records are discussed in more &lt;br /&gt;
detail [[Proxy Records|here]].&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;3&amp;quot; cellspacing=&amp;quot;0&amp;quot; border=&amp;quot;1px&amp;quot; class=&amp;quot;sortable&amp;quot;&lt;br /&gt;
|- | style=&amp;quot;background-color: #F2F2F2&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Field&lt;br /&gt;
! Data type&lt;br /&gt;
! Default value&lt;br /&gt;
! ASH Accessor Function / Notes&lt;br /&gt;
|-&lt;br /&gt;
| nocombats&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| combat_percent&lt;br /&gt;
| float&lt;br /&gt;
| 0.0&lt;br /&gt;
| the chance of getting a combat encounter AFTER applying numeric_modifier(&amp;quot;Combat Rate&amp;quot;)&lt;br /&gt;
|-&lt;br /&gt;
| zone&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| parent&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| parentdesc&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| environment&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| bounty&lt;br /&gt;
| bounty&lt;br /&gt;
| none&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| combat_queue&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| noncombat_queue&lt;br /&gt;
| string&lt;br /&gt;
| &amp;quot;&amp;quot;&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| turns_spent&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| kisses&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
| {{kolwiki|Dreadsylvania}}&lt;br /&gt;
|-&lt;br /&gt;
| recommended_stat&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| water_level&lt;br /&gt;
| int&lt;br /&gt;
| 0&lt;br /&gt;
| {{kolwiki|Heavy Rains}}&lt;br /&gt;
|-&lt;br /&gt;
| wanderers&lt;br /&gt;
| boolean&lt;br /&gt;
| false&lt;br /&gt;
| whether wandering monsters can spawn in this zone&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]] [[Category:Data Types]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
	<entry>
		<id>https://wiki.kolmafia.us/index.php?title=Data_Types&amp;diff=6825</id>
		<title>Data Types</title>
		<link rel="alternate" type="text/html" href="https://wiki.kolmafia.us/index.php?title=Data_Types&amp;diff=6825"/>
		<updated>2020-03-17T22:21:44Z</updated>

		<summary type="html">&lt;p&gt;Fredg1: /* float */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TOCright}}&lt;br /&gt;
==Primitive Datatypes==&lt;br /&gt;
&lt;br /&gt;
===void===&lt;br /&gt;
Can be thought of better as the absence of a datatype. No value can be assigned to &#039;&#039;&#039;void&#039;&#039;&#039; nor can a value be returned from a function of datatype &#039;&#039;&#039;void&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===boolean===&lt;br /&gt;
A boolean value is either &#039;&#039;&#039;true&#039;&#039;&#039; or &#039;&#039;&#039;false&#039;&#039;&#039;. By default, a boolean variable is set to false.&lt;br /&gt;
&lt;br /&gt;
===int===&lt;br /&gt;
&lt;br /&gt;
A whole number (short for &amp;quot;integer&amp;quot;), either positive or negative (or 0).  The int used by KoLmafia is a 32-bit signed int, meaning it has a maximum value of 2,147,483,647 and a minimum value of -2,147,483,648. The default value of a integer variable is 0.&lt;br /&gt;
&lt;br /&gt;
Be careful when doing math with integers! As with some other strongly-typed languages, numbers are converted to integers at every step of the operation when only integer types are used. For example:&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
int a = 1;&lt;br /&gt;
int b = 2;&lt;br /&gt;
print( a / b * 2 );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Will give the output &amp;quot;0,&amp;quot; not &amp;quot;1&amp;quot; as you may expect. Changing either variable to a float type will &amp;quot;correct&amp;quot; this.&lt;br /&gt;
&lt;br /&gt;
===float===&lt;br /&gt;
&lt;br /&gt;
The float data type is a single-precision 32-bit IEEE 754 floating point. Its range of values is beyond the scope of this discussion, but is specified in [http://java.sun.com/docs/books/jls/third_edition/html/typesValues.html#4.2.3 section 4.2.3 of the Java Language Specification], and a tool to help understand / quickly see how/where imprecisions happen can be found [https://www.h-schmidt.net/FloatConverter/IEEE754.html here].&lt;br /&gt;
&lt;br /&gt;
When assigning to a variable of type float, one should be careful to always enter numbers in decimal form, as unwanted behavior can result from supplying a value that KoLmafia may interpret as an int type without the decimal point.&lt;br /&gt;
&lt;br /&gt;
Note that float is not infinitely precise; it intrinsically rounds off after a certain point. This loss of accuracy is for the sake of storage, but beware of the possibility of small errors compounding from multiple float types.&lt;br /&gt;
{{&lt;br /&gt;
CodeSample|&lt;br /&gt;
description=For instance, try the following code as an example of how rather long post-decimal portions are handled:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
float f;&lt;br /&gt;
f = 4.9999999;&lt;br /&gt;
print( f );&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The default value of a &amp;lt;code&amp;gt;float&amp;lt;/code&amp;gt; variable is 0.0.&lt;br /&gt;
&lt;br /&gt;
===string===&lt;br /&gt;
&lt;br /&gt;
A group of characters including, but not limited to: lowercase letters, uppercase characters, numbers, and various control characters. When assigning a value to a string, always enclose the desired value in either single or double quotes (note you must use the same quote type on both ends of the string assignment). If you need to include the same character inside of the string itself, you will need to escape it first with a backslash.{{CodeSample|&lt;br /&gt;
description=For example:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
string s = &amp;quot;This is my \&amp;quot;friend\&amp;quot; Pete.&amp;quot;;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;|&lt;br /&gt;
moreinfo=&lt;br /&gt;
Will result in the following being stored to s:&lt;br /&gt;
&amp;lt;pre&amp;gt;This is my &amp;quot;friend&amp;quot; Pete&amp;lt;/pre&amp;gt;}}&lt;br /&gt;
The default value of a string is an empty string, or literally &amp;lt;code&amp;gt;&amp;quot;&amp;quot;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===buffer===&lt;br /&gt;
&lt;br /&gt;
Similar to a string, but more efficient in certain operations, including concatenation and passing as function arguments. For the most part, you can interchange references to strings and buffers. However, you should test all such actions first, as a few functions require a specific datatype to be supplied as a parameter. (Most notably, those listed under [[String Handling Routines#Regular Expressions|Regular Expressions]].)&lt;br /&gt;
&lt;br /&gt;
==Special Datatypes==&lt;br /&gt;
&lt;br /&gt;
Several datatypes are included in KoLmafia to represent common categories within the KoL universe.&lt;br /&gt;
&lt;br /&gt;
Note that while variables of these types are declared in the same way as for Primitive Datatypes; assigning and referencing them is done differently.&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=For example, to declare an item datatype and assign it a value, you would use the following line of code:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item it = $item[ broken skull ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The default values of any variable of one of the following types is &amp;lt;code&amp;gt;$&#039;&#039;type&#039;&#039;[ none ]&amp;lt;/code&amp;gt;. For example, the default value of a &amp;lt;code&amp;gt;item&amp;lt;/code&amp;gt; variable is &amp;lt;code&amp;gt;$item[ none ]&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
===bounty===&lt;br /&gt;
&lt;br /&gt;
([[Bounty#Related Functions|Related Functions]])  ([[Bounty#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
These are the non-items that the bounty hunter asks you to retrieve from monsters around the kingdom. There are quite a lot of them (42 in total) so I won&#039;t list them all here. You can find more about bounties at the {{kolwiki|The Bounty Hunter Hunter&#039;s Shack}}.&lt;br /&gt;
&lt;br /&gt;
===class===&lt;br /&gt;
&lt;br /&gt;
([[Class#Related Functions|Related Functions]])  ([[Class#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Besides $class[ none ], there are six possible values for this datatype:&lt;br /&gt;
&lt;br /&gt;
* Seal Clubber&lt;br /&gt;
* Turtle Tamer&lt;br /&gt;
* Pastamancer&lt;br /&gt;
* Sauceror&lt;br /&gt;
* Disco Bandit&lt;br /&gt;
* Accordion Thief&lt;br /&gt;
&lt;br /&gt;
===coinmaster===&lt;br /&gt;
&lt;br /&gt;
([[Coinmaster#Related Functions|Related Functions]])  ([[Coinmaster#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
All shops that deal with currency other than meat. Known values include:&lt;br /&gt;
&lt;br /&gt;
* {{kolwiki|The Bounty Hunter Hunter&#039;s Shack|Bounty Hunter Hunter}}&lt;br /&gt;
* {{kolwiki|Mr. Store}}&lt;br /&gt;
* {{kolwiki|Hermit}}&lt;br /&gt;
* {{kolwiki|The Shore, Inc. Gift Shop}}&lt;br /&gt;
* {{kolwiki|The Trapper&#039;s Cabin|The Trapper}}&lt;br /&gt;
* {{kolwiki|A Vending Machine|Vending Machine}}&lt;br /&gt;
* {{kolwiki|The Swagger Shop}}&lt;br /&gt;
* {{kolwiki|The Hippy Camp (Wartime)|Dimemaster}}&lt;br /&gt;
* {{kolwiki|The Orcish Frat House|Quartersmaster}}&lt;br /&gt;
* {{kolwiki|BURT|Bugbear Token}}&lt;br /&gt;
* {{kolwiki|Freshwater Fishbonery}}&lt;br /&gt;
* {{kolwiki|Big Brother}}&lt;br /&gt;
* {{kolwiki|The Terrified Eagle Inn}}&lt;br /&gt;
* {{kolwiki|Ticket Redemption Counter|Arcade Ticket Counter}}&lt;br /&gt;
* {{kolwiki|Cashier|Game Shoppe}}&lt;br /&gt;
* {{kolwiki|Cashier|Game Shoppe Snacks}}&lt;br /&gt;
* {{kolwiki|The Isotope Smithery|Isotope Smithery}}&lt;br /&gt;
* {{kolwiki|Dollhawker&#039;s Emporium}}&lt;br /&gt;
* {{kolwiki|The Lunar Lunch-o-Mat|Lunar Lunch-o-Mat}}&lt;br /&gt;
* {{kolwiki|Paul&#039;s Boutique}}&lt;br /&gt;
* {{kolwiki|The Frozen Brogurt Stand}}&lt;br /&gt;
* {{kolwiki|Buff Jimmy&#039;s Souvenir Shop}}&lt;br /&gt;
* {{kolwiki|Taco Dan&#039;s Taco Stand}}&lt;br /&gt;
* {{kolwiki|You&#039;re the Fudge Wizard Now, Dog|Fudge Wand}}&lt;br /&gt;
* {{kolwiki|The Neandermall}}&lt;br /&gt;
* {{kolwiki|Legitimate Shoe Repair, Inc.}}&lt;br /&gt;
* {{kolwiki|warbear black box|Warbear Black Box}}&lt;br /&gt;
* {{kolwiki|The Dinsey Company Store}}&lt;br /&gt;
* {{kolwiki|Internet Meme Shop}}&lt;br /&gt;
&lt;br /&gt;
===effect===&lt;br /&gt;
&lt;br /&gt;
([[Effect#Related Functions|Related Functions]])  ([[Effect#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any effect you can be under in KoL, whether from items, skills, or what-have-you, is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $effect[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Effects}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===element===&lt;br /&gt;
&lt;br /&gt;
([[Element#Related Functions|Related Functions]])  ([[Element#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Besides $element[ none ], there are seven possible values for this datatype. (Note that &amp;quot;Bad Spelling&amp;quot; is not considered a true element.)&lt;br /&gt;
Also note that these names are case-sensitive (referencing $element[ Spooky ] will generate an error).&lt;br /&gt;
&lt;br /&gt;
* cold&lt;br /&gt;
* hot&lt;br /&gt;
* sleaze&lt;br /&gt;
* spooky&lt;br /&gt;
* stench&lt;br /&gt;
* slime&lt;br /&gt;
* supercold&lt;br /&gt;
&lt;br /&gt;
===familiar===&lt;br /&gt;
&lt;br /&gt;
([[Familiar#Related Functions|Related Functions]])  ([[Familiar#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any familiar available in KoL is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $familiar[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Familiars}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===item===&lt;br /&gt;
&lt;br /&gt;
([[Item#Related Functions|Related Functions]])  ([[Item#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any item in all of KoL is valid for this datatype. Note that unlike most special datatypes, item references can make use of the item ID number.&lt;br /&gt;
{{CodeSample|&lt;br /&gt;
description=For example, you could assign the item plexiglass pants as follows:|&lt;br /&gt;
code=&lt;br /&gt;
&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
item it = $item[ 1234 ];&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The full range, besides $item[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Items}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===location===&lt;br /&gt;
&lt;br /&gt;
([[Location#Related Functions|Related Functions]])  ([[Location#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any location one can adventure at in KoL is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $location[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Locations}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===monster===&lt;br /&gt;
&lt;br /&gt;
([[Monster#Related Functions|Related Functions]])  ([[Monster#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any monster you can encounter in KoL is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $monster[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Monster Compendium}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===phylum===&lt;br /&gt;
&lt;br /&gt;
([[Phylum#Related Functions|Related Functions]])  ([[Phylum#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Each monster has a {{kolwiki|Phylum}}. Besides $phylum[none], the possible values for this datatype are:&lt;br /&gt;
&lt;br /&gt;
* beast&lt;br /&gt;
* bug&lt;br /&gt;
* constellation&lt;br /&gt;
* construct&lt;br /&gt;
* demon&lt;br /&gt;
* dude&lt;br /&gt;
* elemental&lt;br /&gt;
* elf&lt;br /&gt;
* fish&lt;br /&gt;
* goblin&lt;br /&gt;
* hippy&lt;br /&gt;
* hobo&lt;br /&gt;
* humanoid&lt;br /&gt;
* horror&lt;br /&gt;
* mer-kin&lt;br /&gt;
* orc&lt;br /&gt;
* penguin&lt;br /&gt;
* pirate&lt;br /&gt;
* plant&lt;br /&gt;
* slime&lt;br /&gt;
* undead&lt;br /&gt;
* weird&lt;br /&gt;
&lt;br /&gt;
===servant===&lt;br /&gt;
&lt;br /&gt;
([[Servant#Related Functions|Related Functions]])  ([[Servant#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Servants are unique to the {{kolwiki|Actually Ed the Undying}} path and located {{kolwiki|The Servants&#039; Quarters}}, replacing familiars.&lt;br /&gt;
&lt;br /&gt;
* Assassin&lt;br /&gt;
* Belly-Dancer&lt;br /&gt;
* Bodyguard&lt;br /&gt;
* Cat&lt;br /&gt;
* Maid&lt;br /&gt;
* Priest&lt;br /&gt;
* Scribe&lt;br /&gt;
&lt;br /&gt;
===skill===&lt;br /&gt;
&lt;br /&gt;
([[Skill#Related Functions|Related Functions]])  ([[Skill#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Any skill you can have in KoL, whether permable or not, granted by items, &#039;&#039;etc&#039;&#039;., is valid for this datatype.&lt;br /&gt;
&lt;br /&gt;
The full range, besides $skill[ none ], is too much to list and keep up with here: please see the Wiki {{kolwiki|Skills}} page for more information.&lt;br /&gt;
&lt;br /&gt;
===slot===&lt;br /&gt;
&lt;br /&gt;
([[Slot#Related Functions|Related Functions]])  (slot has no proxy record fields)&lt;br /&gt;
&lt;br /&gt;
Besides $slot[ none ], there are 16 possible values for this datatype.&lt;br /&gt;
&lt;br /&gt;
* hat&lt;br /&gt;
* back&lt;br /&gt;
* weapon&lt;br /&gt;
* off-hand&lt;br /&gt;
* shirt&lt;br /&gt;
* pants&lt;br /&gt;
* acc1&lt;br /&gt;
* acc2&lt;br /&gt;
* acc3&lt;br /&gt;
* familiar&lt;br /&gt;
* sticker1&lt;br /&gt;
* sticker2&lt;br /&gt;
* sticker3&lt;br /&gt;
* fakehand&lt;br /&gt;
* bootspur&lt;br /&gt;
* bootskin&lt;br /&gt;
&lt;br /&gt;
===stat===&lt;br /&gt;
&lt;br /&gt;
([[Stat#Related Functions|Related Functions]])  (stat has no proxy record fields)&lt;br /&gt;
&lt;br /&gt;
Besides $stat[ none ], there are six possible values for this datatype (the last three are for referencing sub-stats).&lt;br /&gt;
&lt;br /&gt;
* muscle&lt;br /&gt;
* mysticality&lt;br /&gt;
* moxie&lt;br /&gt;
* submuscle&lt;br /&gt;
* submysticality&lt;br /&gt;
* submoxie&lt;br /&gt;
&lt;br /&gt;
===thrall===&lt;br /&gt;
&lt;br /&gt;
([[Thrall#Related Functions|Related Functions]])  ([[Thrall#Proxy Record Fields|Proxy Record Fields]])&lt;br /&gt;
&lt;br /&gt;
Pastamancers have the ability to summon {{kolwiki|Pasta Thralls}}. &lt;br /&gt;
&lt;br /&gt;
* Angel Hair Wisp&lt;br /&gt;
* Elbow Macaroni&lt;br /&gt;
* Lasagmbie&lt;br /&gt;
* Penne Dreadful&lt;br /&gt;
* Spaghetti Elemental&lt;br /&gt;
* Spice Ghost&lt;br /&gt;
* Vampieroghi&lt;br /&gt;
* Vermincelli&lt;br /&gt;
&lt;br /&gt;
==aggregate==&lt;br /&gt;
&lt;br /&gt;
An aggregate is a complex datatype composed of two or more primitive or special datatypes. For more information, see [[Data Structures]].&lt;br /&gt;
&lt;br /&gt;
==record==&lt;br /&gt;
&lt;br /&gt;
Records are user-defined datatypes that hold as many sub-datatypes as desired. For more information, see the page for [[Data Structures]].&lt;br /&gt;
&lt;br /&gt;
==Plural Typed Constants==&lt;br /&gt;
&lt;br /&gt;
(see http://kolmafia.us/showthread.php?p=15592, from which this section is reproduced)&lt;br /&gt;
&lt;br /&gt;
Plural typed constants allow you to easily do something with a list of specified objects, without having to replicate code or laboriously build up an array of the objects so that you can iterate over it. Here&#039;s a quick example:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach weapon in $items[star sword, star staff, star crossbow] {&lt;br /&gt;
   if (available_amount(weapon) &amp;gt; 0) {&lt;br /&gt;
      equip(weapon);&lt;br /&gt;
      break;&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
The syntax is basically the same as the existing typed constant feature, but with an &amp;quot;s&amp;quot; or &amp;quot;es&amp;quot; after the type name. (The &amp;quot;es&amp;quot; case is there so that you can properly pluralize &amp;quot;class&amp;quot;.) The text between the square brackets is interpreted as a comma-separated list of elements, each of which is converted to the specified type as if it were an individual constant. More details:&lt;br /&gt;
* The list can span multiple lines.&lt;br /&gt;
* Whitespace before or after elements is ignored.&lt;br /&gt;
* Completely empty elements are ignored (so that you can leave a comma at the end of the list).&lt;br /&gt;
* You can include a comma or closing square bracket in an element by writing it as &amp;quot;\,&amp;quot; or &amp;quot;\]&amp;quot;.&lt;br /&gt;
* All the other escape sequences allowed in strings are possible, such as &amp;quot;\n&amp;quot; (newline), &amp;quot;\t&amp;quot; (tab), and &amp;quot;\uXXXX&amp;quot; (Unicode character value). To put an actual backslash in an element, you have to write it as &amp;quot;\\&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
The value generated by a plural constant is of type boolean[type], with the keys being the specified elements, and the boolean value always being true - although you won&#039;t normally do anything with the boolean, you&#039;d use a foreach loop to iterate over the keys. You can assign a plural constant to a variable declared as that type, but note that the value differs from a normal map in three important respects:&lt;br /&gt;
* Since the expression that generates it is syntactically a constant, the value has to be immutable. If you were allowed to change it in any way, those changes would appear in every future use of the same constant.&lt;br /&gt;
* There can be multiple instances of the same key - $ints[1,1,2,3,5,8] is perfectly valid, and will result in the value 1 appearing twice in a foreach loop.&lt;br /&gt;
* The keys will appear in the order you wrote them, rather than being sorted alphanumerically as maps usually do.&lt;br /&gt;
&lt;br /&gt;
In addition to being used in a foreach loop, plural constants also efficiently support membership testing via the &#039;contains&#039; operator. Here&#039;s another example:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
for hour from 1 to 12 {&lt;br /&gt;
   print(&amp;quot;It&#039;s &amp;quot; + hour + &amp;quot; o&#039;clock.&amp;quot;);&lt;br /&gt;
   if ($ints[10, 2, 4] contains hour) {&lt;br /&gt;
      print(&amp;quot;Time to drink a Dr Pepper!&amp;quot;);&lt;br /&gt;
   }&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
(Yes, that example could just as easily have been done with a switch statement.)&lt;br /&gt;
&lt;br /&gt;
Iterating over an empty list is rather pointless, so plural constants with no elements are given a different meaning: they represent every value of the specified type, where this is practical. (The &#039;none&#039; value, if defined for a given type, is omitted.) The biggest benefit here is $items[], which lets you loop over every defined item, more efficiently than you could otherwise write in a script (since the list is generated once per session and then cached), and without having to hard-code a maximum item ID number in your script. Example:&lt;br /&gt;
{{CodeSample|code=&amp;lt;syntaxhighlight&amp;gt;&lt;br /&gt;
foreach it in $items[] {&lt;br /&gt;
   if (autosell_price(it) == 42) print(it);&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;}}&lt;br /&gt;
Enumeration of all possible values works with the following types:&lt;br /&gt;
* $booleans[] - false and true.&lt;br /&gt;
* $items[]&lt;br /&gt;
* $locations[]&lt;br /&gt;
* $classes[]&lt;br /&gt;
* $stats[] - Muscle, Mysticality, Moxie: the substat values are omitted.&lt;br /&gt;
* $skills[]&lt;br /&gt;
* $effects[]&lt;br /&gt;
* $familiars[]&lt;br /&gt;
* $slots[] - includes sticker slots and fake hands, which you might not want to consider as normal slots.&lt;br /&gt;
* $monsters[]&lt;br /&gt;
* $elements[] - includes slime now, and possibly other not-quite-elements like cute in the future.&lt;br /&gt;
&lt;br /&gt;
The remaining types that can be used in plural constants require an explicit list of elements, since there are too many possible values:&lt;br /&gt;
* $ints[] - you don&#039;t have enough RAM to store a list with 4 billion elements.&lt;br /&gt;
* $floats[] - ditto.&lt;br /&gt;
* $strings[] - nobody has that much RAM.&lt;br /&gt;
&lt;br /&gt;
==Custom==&lt;br /&gt;
&lt;br /&gt;
===matcher===&lt;br /&gt;
&lt;br /&gt;
A matcher isn&#039;t really a datatype so much as it&#039;s a class, but it is included here for reference, as it is used much as datatypes are in ASH. It can only be declared through the function {{f|create_matcher}}, using two strings. One is the string to find matches in, the other a regular expression to test against. For more information on using a matcher, see [[Regular Expressions]].&lt;br /&gt;
&lt;br /&gt;
[[Category:Scripting]]&lt;/div&gt;</summary>
		<author><name>Fredg1</name></author>
	</entry>
</feed>