<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://elanthipedia.play.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DSETHK93</id>
	<title>Elanthipedia - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://elanthipedia.play.net/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=DSETHK93"/>
	<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/Special:Contributions/DSETHK93"/>
	<updated>2026-05-04T02:12:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.12</generator>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=Talk:Scout_ogre&amp;diff=553786</id>
		<title>Talk:Scout ogre</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=Talk:Scout_ogre&amp;diff=553786"/>
		<updated>2021-05-06T00:55:34Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: Added section and response about spawning locations.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Manipulate Friendship==&lt;br /&gt;
Able to be manipulated at 617 Empathy.  Did not learn.  [[User:HERALD42|HERALD42]] ([[User talk:HERALD42|talk]]) 08:31, 11 August 2015 (CDT)&lt;br /&gt;
&lt;br /&gt;
==Spawning Locations==&lt;br /&gt;
I could not find these neither out Riverhaven&#039;s nor Crossing&#039;s west gates in the TEST instance. After several minutes, I had only seen dozens of [[young ogre]]s. Maybe the Scout Ogres don&#039;t spawn in these areas anymore? [[User:TRAIGA|TRAIGA]] ([[User talk:TRAIGA|talk]]) 00:38, 9 March 2021 (CST)&lt;br /&gt;
:In the main instance, I encountered them in the [[RanikMap5|Rocky Outcrop]] west of Crossing.  This was in the area where the map says &amp;quot;Young Ogres/Blood Wolves.&amp;quot;  I&#039;ve only been hunting there recently, maybe a week or two, and just a few minutes ago was the first time I saw a scout ogre there.  I managed to kill one, and then two more entered, so I made my exit.  I&#039;m not quite up to taking on a group of them, but at least they didn&#039;t eviscerate me like a dire bear does.  Anyway, I was just surprised because I still haven&#039;t seen any young ogres, which are on the map, and then here were these more difficult scout ogres, that aren&#039;t on the map.  But they&#039;re there in the game.  --[[User:DSETHK93|DSETHK93]] ([[User talk:DSETHK93|talk]]) 19:55, 5 May 2021 (CDT)&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=Talk:Zone_map&amp;diff=546193</id>
		<title>Talk:Zone map</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=Talk:Zone_map&amp;diff=546193"/>
		<updated>2021-03-03T05:48:46Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Visual Representation */ new section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Maps Still Needing Zone Placement ==&lt;br /&gt;
&lt;br /&gt;
These maps still need placement in their appropriate zone(s).  They are typically maps that are near zone borders and simply need someone to go through in game and verify which zone the majority of the map belongs to.&amp;lt;br&amp;gt;&lt;br /&gt;
If a map is predominantly made up of one zone, with a smattering of non-landmark rooms from another zone, just include it in the first zone.&amp;lt;br&amp;gt;&lt;br /&gt;
If a map contains large portions made up two zones, include it in both zones with the qualifier &#039;Portions of&#039; in front of it.  This is also the approach to take if only a smattering of rooms belong to one zone, but they make up a landmark area.&lt;br /&gt;
:* [[RanikMap3  | Map 3 ]] - Outside the West Gate + Lake of Dreams&lt;br /&gt;
:* [[RanikMap3a  | Map 3a ]] - Temple Hill Housing Area&lt;br /&gt;
:* [[RanikMap4  | Map 4 ]] - Goblins + The Hunting Preserve&lt;br /&gt;
:* [[RanikMap11  | Map 11 ]] - NTR, including Vipers + Rock Guardians&lt;br /&gt;
:* [[RanikMap11a  | Map 11a ]] - Leucros and Vipers&lt;br /&gt;
:* [[RanikMap12  | Map 12 ]] - More NTR + Reavers&lt;br /&gt;
:* [[RanikMap12a  | Map 12a ]] - Dense Copse + Temple&lt;br /&gt;
:* [[RanikMap13a  | Map 13a ]] - North Roads Caravansary&lt;br /&gt;
:* [[RanikMap14  | Map 14 ]] - Blue-Belly Crocodile Area, Homes, a few other things&lt;br /&gt;
:* [[RanikMap14a  | Map 14a ]] - Gate of Souls&lt;br /&gt;
:* [[RanikMap14b  | Map 14b ]] - Greater Fist&lt;br /&gt;
:* [[RanikMap14c  | Map 14c ]] - Swim to Haven!&lt;br /&gt;
:* [[RanikMap31c  | Map 31c ]] - Pejek Bog&lt;br /&gt;
:* [[RanikMap31e  | Map 31e ]] - Abandoned Castle&lt;br /&gt;
:* [[RanikMap33  | Map 33 ]] - Road to Theren&lt;br /&gt;
:* [[RanikMap34d  | Map 34d ]] - Forest Gryphons&lt;br /&gt;
:* [[RanikMap60b  | Map 60b ]] - River Sprites and Segoltha River&lt;br /&gt;
:* [[RanikMap61a  | Map 61a ]] - Boggy Marsh of Leth, Moss Meys&lt;br /&gt;
:* [[RanikMap61c  | Map 61c ]] - Treehopper Toads&lt;br /&gt;
:* [[RanikMap70  | Map 70 ]] - Outside the West gate of Shard&lt;br /&gt;
:* [[RanikMap70a  | Map 70a ]] - Crystal Forest housing area&lt;br /&gt;
:* [[RanikMap128a  | Map 128a ]] - Liirewsag River&lt;br /&gt;
&lt;br /&gt;
== Rakash Village and Road to Rakash Village ==&lt;br /&gt;
&lt;br /&gt;
The placement of these two zones (MM and NN) are currently just a logical guess based on nearby locations and various Locate-shift capabilities.  Confirmation of their exact locations would be appreciated as I am currently unable to do so myself.--[[User:Evran|Evran]] 18:30, 28 September 2010 (UTC)&lt;br /&gt;
:Done--[[User:Evran|Evran]] 20:01, 1 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Questions on the Map and Formulas ==&lt;br /&gt;
&lt;br /&gt;
I&#039;m very new to the guild, so I&#039;m not yet comfortable with what the ranges should be; however, I know that something is wrong.  On the page, it shows that I need a minimum of about 241 PM to go 2 zones on mainland with 80 mana in a moongate.  I have 111 PM.  I dropped a beam at the NE gate of Crossing (solidly in P) and opened a moongate from the south dock of the Haven ferry using 35 held mana.  Because that location is not directly listed, I wanted to make sure I was solidly two zones away, so I went to Riverhaven.  I was able to, at 111 PM, open a moongate to Crossing with 50 mana.  The data on the page indicates I shouldn&#039;t be able to do it with any less than 241 PM at 80 mana.  I think something is off on the page.  --[[User:Aristrondr|Aristrondr]] 04:04, 1 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
Also just confirmed range with opening a gate from Throne City to Crossing at 111 PM using about 45 mana.  --[[User:Aristrondr|Aristrondr]] 04:47, 1 December 2010 (UTC)&lt;br /&gt;
:All those formulae I reconstructed from memory of output from the [[Coordinate Chart]] since I currently don&#039;t have access to the coordinate chart.  I do remember at low ranks there was a certain minimum distance that kicked in regardless of skill, and I had placed that at a distance of 1.  Its entirely possible that&#039;s a distance of &amp;gt;2 when the formula applies instead of the &amp;gt;=2 that I have listed.  I also might have the whole mainland scale off by 100 ranks... When I&#039;m able to actually run the coordinate program, I&#039;ll confirm them.  Let me know what ranges you can get once you hit 141 ranks?  That would let me know if I&#039;ve got that off by 100 ranks or not.--[[User:Evran|Evran]] 19:59, 1 December 2010 (UTC)&lt;br /&gt;
::Okay, that should be fixed now.  I had the both the distance modifiers and constant off by a bit so that the island to mainland values were correct, but the mainland numbers were wrong.  Let me know if you find any more inconsistancies. --[[User:Evran|Evran]] 21:21, 1 December 2010 (UTC)&lt;br /&gt;
&lt;br /&gt;
== Visual Representation ==&lt;br /&gt;
&lt;br /&gt;
The visual representation of the distance calculation is very nicely done.  But it only goes up to distances of 10, while it appears that zone 00 (Fang Cove) is further than that from zones A (Muspar&#039;i) and B.  I calculate those distances at 12 and 11, respectively; it&#039;s 9 up and 9 or 7 over:  9^2 + 9^2 = 162 &amp;gt; 12^2, 9^2 + 7^2 = 130 &amp;gt; 11^2.  I don&#039;t believe any other distances greater than 10 exist between any zones containing locations.  Does the game in fact treat these zones as having those greater distances between them?  Or does it use some other mechanic, such as defaulting them to 10, or asserting that their distance is too great for any mechanic that relies on distance?  --[[User:DSETHK93|DSETHK93]] ([[User talk:DSETHK93|talk]]) 23:48, 2 March 2021 (CST)&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=Pathway_of_Damage&amp;diff=539104</id>
		<title>Pathway of Damage</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=Pathway_of_Damage&amp;diff=539104"/>
		<updated>2020-11-23T08:25:07Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: Added messaging.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{GuildAbility&lt;br /&gt;
|name=Damage&lt;br /&gt;
|guild=warrior mage&lt;br /&gt;
|prereqs=&amp;amp;#8203;4th Circle, Quest&lt;br /&gt;
|slots=-&lt;br /&gt;
|diff=-&lt;br /&gt;
|type=pathway&lt;br /&gt;
|contest1=-&lt;br /&gt;
|contest2=-&lt;br /&gt;
|skill=Summoning&lt;br /&gt;
|path=Fire&lt;br /&gt;
|desc=By manipulating this pathway into your targeting matrices, it will allow you to increase the damage capacity of your targeted spells.&lt;br /&gt;
|buffs=No buffs&lt;br /&gt;
|debuffs=No debuffs&lt;br /&gt;
|dtype=No damage&lt;br /&gt;
|htype=No heal&lt;br /&gt;
|effect=Increase damage of TM spells&lt;br /&gt;
|messaging=You focus on manipulating an aethereal pathway to enhance the damage of your targeted spells.&lt;br /&gt;
&lt;br /&gt;
You continue to discharge power, carving a favorable pathway into the aethereal landscape.&lt;br /&gt;
}}&lt;br /&gt;
==Notes==&lt;br /&gt;
&amp;quot;This one is fairly straightforward. It provides a damage boost to TM spells if they hit the target. The reasoning behind Pathway Focus Damage (PF Damage) being the first ability of AP is that we&#039;d like to help the younger folk in learning TM. A boost to TM damage should help add some experience to the TM pool and hopefully make it a bit easier to learn the skill. The best is wreaking more havoc upon your enemies by adding some extra oompf to you spells.&amp;quot; -GM [[Chakram]]&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=Talk:RanikMap1&amp;diff=528713</id>
		<title>Talk:RanikMap1</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=Talk:RanikMap1&amp;diff=528713"/>
		<updated>2020-09-15T06:37:59Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Map info to be fixed or added */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;See [[Talk:RanikMap1/Archives]] for archived discussions.&lt;br /&gt;
&lt;br /&gt;
== Map info to be fixed or added==&lt;br /&gt;
* Access to swim the Segoltha River (to Leth) can be found in the room West from the Sand Spit Tavern.&lt;br /&gt;
* Alchemy Society building is 1 East from the Engineering Society&lt;br /&gt;
* Enchanting Society building is up by the Paladin Guild (confirm 2 or 3 rooms South)&lt;br /&gt;
* Meeting Hall building is near the Barbarian Guild (confirm 1 or 2 rooms West)&lt;br /&gt;
* That &amp;quot;E&amp;quot; under the Oxenwaithe Bridge is difficult to notice in white against the river (just north of pawn shop); to my eye, it looks like &amp;quot;go bridge&amp;quot; is provided as a bidirectional movement command.  Maybe the box to the right of the bridge could be moved further right, leaving space for &amp;quot;E&amp;quot; in normal font against white background?  --[[User:DSETHK93|DSETHK93]] ([[User talk:DSETHK93|talk]]) 01:37, 15 September 2020 (CDT)&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=Primary_Magic_skill&amp;diff=527719</id>
		<title>Primary Magic skill</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=Primary_Magic_skill&amp;diff=527719"/>
		<updated>2020-08-24T14:44:35Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: Significant rewrite, explaining formulas and impact of PM on casting.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{UpdateDR3|Article needs development, correction}}&lt;br /&gt;
The &#039;&#039;&#039;Primary Magic [[page type is::skill]]&#039;&#039;&#039; (also known as &#039;&#039;&#039;PM&#039;&#039;&#039; or simply &#039;&#039;&#039;Primary&#039;&#039;&#039;) is a [[magic skillset|magic skill]] that partly determines how many mana streams you can put into a [[Spells|spell]] without backfiring, when casting any [[:Category:Analogous_Patterns_Spellbook|Analogous Patterns spell]] or a spell of your [[:Category:Magic Types|magic type]]. Ironically, the Primary Magic skill is of secondary importance, compared to the specific magic skills ({{skill|Augmentation}}, {{skill|Debilitation}}, {{skill|Targeted Magic}}, {{skill|Utility}}, and {{skill|Warding}}); the effective casting level is a weighted average of Primary Magic and the specific magic skill, with Primary Magic counting only one-fourth as much as the specific skill (see formulas, below).  For most magic users, Primary Magic effectively provides a small bonus to the specific magic skills. &lt;br /&gt;
Primary Magic is replaced by {{skill|Sorcery}} when casting [[:Category:Sorcerous Magic|Sorcery]] or a spell not of your magic type.&lt;br /&gt;
&lt;br /&gt;
Your magic type and the corresponding name of your Primary Magic skill is different depending on your [[guild]].&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Guild!!Skill Name!![[Mana]] Type&lt;br /&gt;
|-&lt;br /&gt;
|[[Barbarian]]||Inner Fire skill||None&lt;br /&gt;
|-&lt;br /&gt;
|[[Bard]]||Elemental Magic skill||Elemental&lt;br /&gt;
|-&lt;br /&gt;
|[[Cleric]]||Holy Magic skill||Holy&lt;br /&gt;
|-&lt;br /&gt;
|[[Empath]]||Life Magic skill||Life&lt;br /&gt;
|-&lt;br /&gt;
|[[Moon Mage]]||Lunar Magic skill||Lunar&lt;br /&gt;
|-&lt;br /&gt;
|[[Necromancer]]||Arcane Magic skill||Necromatic&lt;br /&gt;
|-&lt;br /&gt;
|[[Paladin]]||Holy Magic skill||Holy&lt;br /&gt;
|-&lt;br /&gt;
|[[Ranger]]||Life Magic skill||Life&lt;br /&gt;
|-&lt;br /&gt;
|[[Thief]]||Inner Magic skill||None&lt;br /&gt;
|-&lt;br /&gt;
|[[Trader]]||Lunar Magic skill||Lunar&lt;br /&gt;
|-&lt;br /&gt;
|[[Warrior Mage]]||Elemental Magic skil|||Elemental&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Outside teaching issues, the skill works the same for all guilds.&lt;br /&gt;
&lt;br /&gt;
==Spells and abilities that boost Primary Magic==&lt;br /&gt;
{{#ask:[[Boosts::Primary Magic skill]]&lt;br /&gt;
|?guild association is&lt;br /&gt;
|format=ul&lt;br /&gt;
|headers=hide&lt;br /&gt;
|default=None&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Spells and abilities that decrease Primary Magic==&lt;br /&gt;
{{#ask:[[Debuffs::Primary Magic skill]]&lt;br /&gt;
|?guild association is&lt;br /&gt;
|format=ul&lt;br /&gt;
|headers=hide&lt;br /&gt;
|default=None&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Teaching==&lt;br /&gt;
Attempting to teach someone using a different form of skill, such as a Lunar Magic caster teaching an Elemental Magic user, will result instead in the learning of the [[Sorcery skill]]. Teaching within mana types will teach the skill, even if the teacher and student are different guilds, such as a Bard teaching a Warrior Mage.&lt;br /&gt;
&lt;br /&gt;
Magic users cannot teach this skill to non-magic users.&lt;br /&gt;
&lt;br /&gt;
==Training==&lt;br /&gt;
In general, PM is learned best from casting higher tier (thus more difficult) spells without full preparation, especially when straining your ability (i.e. near backfiring).&lt;br /&gt;
&lt;br /&gt;
==Casting Formula==&lt;br /&gt;
Reverse engineering has been performed on years of game data and determined that there are two formulas in place for this mastery skill.  In these formulas, the Primary Magic skill is represented by &amp;quot;PM,&amp;quot; and the applicable specific magic skill is represented by &amp;quot;SMS.&amp;quot;  These are base formulas, and do not account for any bonuses the character may have in effect, such as from feats or from other spells.  Note that every spell falls into at least one of the specific magic skill categories; most use exactly one, but for any spell that uses more than one the caster&#039;s effective level will be calculated using the skill in which they have the fewest ranks, to reflect that competence in all specific magic skills is required to cast that spell.  Casting will teach mainly that SMS, with a modicum of experience for any other SMS used by the spell.&lt;br /&gt;
&lt;br /&gt;
Normally, the formula for your effective casting ranks is (PM+(SMS*4))/5, which can also be written as 0.2*PM + 0.8*SMS.  It can also be described as 20% of your Primary Magic plus 80% of your specific magic skill, or a weighted average with the specific magic skill counting four times as much.  However, effective casting ranks are capped at 130% of your Primary Magic skill; in the event that your specific magic skill is greater than 1.38 times your PM, which using the default formula would produce values great than 130% of PM, the effective casting ranks are instead just set equal to PM*1.3.&lt;br /&gt;
&lt;br /&gt;
Most magic users will have at least as many ranks in PM as in their highest specific magic skill, because training a specific skill usually also trains PM.  So PM will normally provide a small boost to a specific magic skill when casting.  In particular, since even magic primary guilds can advance indefinitely while leaving at least one specific magic skill untrained, this enables a high-circle character to pick up a new spell for an untrained specific magic skill and start using it modestly, without having to backtrack to training methods for absolute beginners.  In contrast, most magic users will have lower Sorcery skill ranks than their other magic skills, so the same mechanic will prevent them from gaining the full benefits of their skill ranks in the specific magic skills when casting sorcerously, even before the additional difficulty level of sorcerous casting is considered.&lt;br /&gt;
&lt;br /&gt;
{{RefAl}}&lt;br /&gt;
{{cat|Magic skillset,Skills}}&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=Scholarship_skill&amp;diff=527672</id>
		<title>Scholarship skill</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=Scholarship_skill&amp;diff=527672"/>
		<updated>2020-08-23T07:45:12Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Training Scholarship */ Added sigil harvesting.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
Scholarship is used to more effectively teach and learn from being taught. It is also used to determine how much information you can obtain from the [[Recall command]]. It may also have some other benefits especially for [[Moon Mage|Moon Mages]] and [[Bard|Bards]].&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
The following guilds have circle requirements in scholarship:&lt;br /&gt;
*[[Empath]]&lt;br /&gt;
*[[Moon Mage]]&lt;br /&gt;
*[[Warrior Mage]]&lt;br /&gt;
*[[Paladin]]&lt;br /&gt;
&lt;br /&gt;
==Spells and abilities that boost Scholarship==&lt;br /&gt;
{{#ask:[[Boosts::Scholarship skill]]&lt;br /&gt;
|?guild association is&lt;br /&gt;
|format=ul&lt;br /&gt;
|headers=hide&lt;br /&gt;
|default=None&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Spells and abilities that decrease Scholarship==&lt;br /&gt;
{{#ask:[[Debuffs::Scholarship skill]]&lt;br /&gt;
|?guild association is&lt;br /&gt;
|format=ul&lt;br /&gt;
|headers=hide&lt;br /&gt;
|default=None&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
==Teaching==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Teaching&#039;&#039;&#039; is the art of conveying concepts and ideas to others in such way as to improve the students&#039; ability in the subject being taught.&lt;br /&gt;
&lt;br /&gt;
===Class size===&lt;br /&gt;
&lt;br /&gt;
Student size is now as many as will listen in to the class. Scholarship ranks will impact how well one teaches, but virtually anyone can teach any class regardless of skill in the topic or scholarship skill.&lt;br /&gt;
&lt;br /&gt;
===Factors That Affect Experience Gained From Classes===&lt;br /&gt;
&lt;br /&gt;
*Scholarship ranks&lt;br /&gt;
*[[Charisma (stat)|charisma]]: the bonus is linear&lt;br /&gt;
*[[Intelligence (stat)|intelligence]]: the bonus is linear&lt;br /&gt;
*[[Wisdom (stat)|wisdom]]: plays a small role; the bonus is linear&lt;br /&gt;
*whether the teacher and student belong to the same guild&lt;br /&gt;
*whether the teacher and student are of the same race&lt;br /&gt;
*The Bard spell [[Faenella&#039;s Grace]] boosts scholarship and reduces the time between teaching pulses.&lt;br /&gt;
*For purposes of experience earned for teaching a class, only one F2P character in the class will count regardless of the number of F2P characters in the class.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
Room-based bonuses to teaching were removed on 4/4/2015.&amp;lt;ref&amp;gt;[[Post:Teaching Updates - 04/04/2015 - 16:04]]&amp;lt;/ref&amp;gt;&lt;br /&gt;
:&amp;quot;They were extremely inconsistent and poorly implemented anyhow, so I doubt this will have any practical ramifications, but I&#039;m including it for the sake of transparency.  (It gave bonuses based off key words in the name of rooms for example...)&amp;quot; --GM [[Raesh]] (4/4/2015)&lt;br /&gt;
&lt;br /&gt;
===Teaching Supernatural Skills===&lt;br /&gt;
&lt;br /&gt;
{|border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable sortable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Skill!!Who Can Teach!!Who Can Learn&lt;br /&gt;
|-&lt;br /&gt;
|[[Arcana skill|Arcana]]||everyone||everyone&lt;br /&gt;
|-&lt;br /&gt;
|[[Augmentation skill|Augmentation]]||all except Commoners||all except Commoners*&lt;br /&gt;
|-&lt;br /&gt;
|[[Debilitation skill|Debilitation]]||all except Commoners||all except Commoners*&lt;br /&gt;
|-&lt;br /&gt;
|[[Utility skill|Utility]]||all except Barbarians and Commoners||all except Barbarians and Commoners*&lt;br /&gt;
|-&lt;br /&gt;
|[[Warding skill|Warding]]||all except Commoners and Thieves||all except Commoners and Thieves*&lt;br /&gt;
|-&lt;br /&gt;
|[[Attunement skill|Attunement]]||magic users||magic users&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Holy Magic]]||Clerics, Paladins||magic users**&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Life Magic]]||Empaths, Rangers||magic users**&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Elemental Magic]]||Warrior Mages, Bards||magic users**&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Lunar Magic]]||Moon Mages, Traders||magic users**&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Arcane Magic]]||Necromancers||magic users**&lt;br /&gt;
|-&lt;br /&gt;
|[[Sorcery skill|Sorcery]]||magic users||magic users&lt;br /&gt;
|-&lt;br /&gt;
|[[Targeted Magic skill|Targeted Magic]]||magic users||magic users&lt;br /&gt;
|-&lt;br /&gt;
|[[Astrology skill|Astrology]]||Moon Mages||Moon Mages&lt;br /&gt;
|-&lt;br /&gt;
|[[Empathy]]||Empaths||Empaths&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Inner Fire]]||Barbarians||Barbarians&lt;br /&gt;
|-&lt;br /&gt;
|[[Primary Magic skill|Inner Magic]]||Thieves||Thieves&lt;br /&gt;
|-&lt;br /&gt;
|[[Summoning skill|Summoning]]||Warrior Mages||Warrior Mages&lt;br /&gt;
|-&lt;br /&gt;
|[[Theurgy skill|Theurgy]]||Clerics||Clerics&lt;br /&gt;
|}&lt;br /&gt;
&amp;lt;nowiki&amp;gt;*&amp;lt;/nowiki&amp;gt;Magic users can teach each other at normal efficiency, as can Barbarians teaching Barbarians and Thieves teaching Thieves. Between magic users and non-magic users, the class is least efficient. Classes between Barbarians and Thieves are at the mid-point.&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;nowiki&amp;gt;**&amp;lt;/nowiki&amp;gt;When teaching [[Primary Magic skill|primary magic]], if the teacher and student are attuned to different frequencies of mana, the student will learn [[Sorcery skill|sorcery]] instead of primary magic. This does not trigger justice like an actual Sorcery class does.&lt;br /&gt;
&lt;br /&gt;
===Teaching in Combat===&lt;br /&gt;
&lt;br /&gt;
As of 4/4/2015, all guilds can teach only the following skills in combat&amp;lt;ref&amp;gt;[[Post:Teaching Updates - 04/04/2015 - 03:44]]&amp;lt;/ref&amp;gt;:&lt;br /&gt;
*[[Armor Skillset|all armor skills]]&lt;br /&gt;
*[[Weapon Skillset|all weapon skills]]&lt;br /&gt;
*[[Debilitation skill|debilitation]]&lt;br /&gt;
*[[Warding skill|warding]]&lt;br /&gt;
*[[Targeted Magic skill|targeted magic]]&lt;br /&gt;
*[[Evasion skill|evasion]]&lt;br /&gt;
*[[Tactics skill|tactics]]&lt;br /&gt;
*[[Barbarian|Barbarians]] can teach [[Expertise skill|expertise]] to fellow [[Barbarian|Barbarians]].&lt;br /&gt;
*[[Thief|Thieves]] can teach [[Backstab skill|backstab]] to fellow [[Thief|Thieves]].&lt;br /&gt;
*[[Paladin|Paladins]] can teach [[Conviction skill|conviction]] to fellow [[Paladin|Paladins]].&lt;br /&gt;
*[[Scholarship skill|scholarship]] can be learned by OBSERVING any class that can be taught during combat.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;While teaching during combat only&#039;&#039;&#039;, &amp;quot;the rate of learning will depend on the lore skill set placement of the teacher.&amp;quot;&amp;lt;ref&amp;gt;[[Post:Teaching Updates - 04/04/2015 - 03:44]]&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
It is by design that [[Bard|Bards]] can no longer teach any skill in combat.&lt;br /&gt;
:&amp;quot;I was asked to even out the teaching perk to all lore primaries instead of benefiting just Bards.&amp;quot; --GM [[Raesh]] (4/4/2015)&lt;br /&gt;
:&amp;quot;Learning even more skills while in combat is the reverse of what we want to be encouraging.&amp;quot; --GM [[Raesh]] (4/4/2015)&lt;br /&gt;
&lt;br /&gt;
===Invisibility/Hiding===&lt;br /&gt;
&lt;br /&gt;
The teacher must be visible in order to teach all but the following skills:&lt;br /&gt;
*[[Backstab skill|backstab]]&lt;br /&gt;
*[[Perception skill|perception]]&lt;br /&gt;
*[[Scouting skill|scouting]]&lt;br /&gt;
*[[Stealth skill|stealth]]&lt;br /&gt;
*[[Thievery skill|thievery]]&lt;br /&gt;
&lt;br /&gt;
===Teaching and the Justice Mechanics===&lt;br /&gt;
&lt;br /&gt;
While in a [[Justice|justice]] zone:&lt;br /&gt;
*Teaching or listening to [[Thievery skill|thievery]] or [[Sorcery skill|sorcery]] will result in a charge of aiding and abetting unless both the teacher and student are in hiding.&amp;lt;ref&amp;gt;[[Post:Teaching Updates - 04/04/2015 - 16:04]]&amp;lt;/ref&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
*Teaching [[Sorcery skill|sorcery]] will result in a charge of [[Justice|forbidden practices]].&lt;br /&gt;
&lt;br /&gt;
==Training Scholarship==&lt;br /&gt;
&lt;br /&gt;
The following activities teach scholarship:&lt;br /&gt;
*teaching a class of any subject&lt;br /&gt;
*listening to any class&lt;br /&gt;
:*Teaching a class on scholarship is now wasteful, since any student can convert any ongoing class to his own personal scholarship class by using {{com|listen}} {{tt|to [player] observe}}&lt;br /&gt;
*reading books at a [[:Category:Libraries|library]]&lt;br /&gt;
*reading guild [[:Category:Renown scrolls|renown scrolls]]&lt;br /&gt;
*reading primers for [[Prayer Beads|bead carving]]&lt;br /&gt;
*studying [[crafting]] books&lt;br /&gt;
*studying art&lt;br /&gt;
*studying instructions for [[origami]]&lt;br /&gt;
*studying patterns for [[embroidery]]&lt;br /&gt;
*studying spellbooks&lt;br /&gt;
*studying [[anatomy charts]] (also teaches [[Empathy skill]] to Empaths and [[First Aid skill]] to all guilds)&lt;br /&gt;
*using the {{com|Recall}} command&lt;br /&gt;
*reading enchantment scolls (Moon Mages only)&lt;br /&gt;
*studying trading ledgers (Traders only)&lt;br /&gt;
*[[sigil harvesting]] (also teaches [[Arcana skill|Arcana]] and [[Outdoorsmanship skill|Outdoorsmanship]])&lt;br /&gt;
:*It is not necessary that one actually harvest a sigil; the [[Perceive command|PERCEIVE]] SIGIL command can teach scholarship twice in a given room, once each for the primary and secondary sigil when they are found.&lt;br /&gt;
&lt;br /&gt;
{{RefAl|r=y}}&lt;br /&gt;
{{cat|Lore skillset,Skills}}[[page type is::skill| ]]&lt;br /&gt;
*[http://www.play.net/dr/news.asp?id=75 Teaching 2.0 on Play.net]&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527589</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527589"/>
		<updated>2020-08-20T09:40:16Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Regular Expressions */ Added known exception to standard syntax.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* GOTO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;:  Instructs the script to jump to the line labeled with the string.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
Note that labels do not restrict the script or actually divide it into sections.  If the script comes to a line with a label on it, it will continue to execute, regardless of whether or not it was explicitly sent to that label.  If your intention is &#039;&#039;not&#039;&#039; that the script continue on through a label and to the next line, you need to include some code to prevent that, such as preceding the label with an EXIT command or a GOTO for a different label.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. It is fine that multiple results use the same label, since the label exists independently of the MATCH table.  For example, the instruction for a MATCH of &amp;quot;You&amp;quot; to go to the cycle label does not replace or alter the previous instruction that a MATCH of &amp;quot;Stow what?&amp;quot; should go to the same label.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible MATCH, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.  However, when game text contains line breaks, the script searches for all MATCHes up to the first line break, then for all MATCHes up to the second line break, and so forth.  Once a MATCH is found, it can only be supplanted by a higher-priority MATCH if it occurs before the next line break.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions (regex), a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]  However, note that StormFront&#039;s implementation of regex is not inclusive of all syntax.  For example, the only option flag permitted is i, for case insensitivity.&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. Other front ends do not share this function, and even in StormFront it is not always effective.  Often, a script will quickly enter two consecutive game commands by way of PUT or MOVE script commands.  The player may think nothing of chaining commands in this way, due to the claim that StormFront scripts automatically wait during roundtimes.  But, in actuality, this can result in the second command being entered before the first command has been parsed.  The second command is entered before the game has generated results for the first command, including any roundtime.  Thus, at the instant that the script is ready to enter the second command, a fraction of a second after the first command is entered, it finds the game state to &#039;&#039;not&#039;&#039; be in a roundtime and enters that second command.  If the first command causes a roundtime and the second command is one that cannot be done in roundtime, the game will be unable to carry out the second command, but this is already out of the script&#039;s control.  In addition, even when a script is waiting for a roundtime to end as intended by the player, StormFront&#039;s timing is sometimes off; it is common for a script to enter a command with 1 second left on a roundtime, which can cause the rest of the script to become useless.&lt;br /&gt;
&lt;br /&gt;
There are remedies to roundtime issues.  One common solution is to catch failures by including a MATCH for &amp;quot;...wait&amp;quot; from the roundtime messaging; if the script inadvertently runs afoul of a roundtime, the MATCH can be used to direct the script to a label that will let it re-attempt the action.  Alternatively, the line &amp;lt;pre&amp;gt;WAITFOR ROUNDTIME&amp;lt;/pre&amp;gt; is very common in scripts.  This isn&#039;t a special command; it&#039;s just a normal WAITFOR that is looking for the text &amp;quot;roundtime&amp;quot;.  If placed immediately after a command that results in a roundtime, this line forces the script to wait until the game&#039;s messaging for the previous command is complete, because the labeled roundtime is the last line printed.  At that point, StormFront normally will correctly identify that the player character is in roundtime, and will not attempt to enter the next command until that roundtime finishes.  To ensure it correctly times that last second, a simple PAUSE command can be included immediately before the next game command.  (With no numerical argument, PAUSE defaults to one second.)  Note that WAITFOR ROUNDTIME is unnecessary if the command is already followed by MATCHWAIT or a more specific WAITFOR, because these commands also force the script to wait for the game&#039;s messaging.  In fact, they would interfere with each other;  if WAITFOR ROUNDTIME comes first, it will prevent the script from finding any other target text that is part of the command&#039;s messaging, and if it comes second it will not find the roundtime for that action because it wouldn&#039;t start waiting until after the full messaging, including the roundtime, has already been output.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527586</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527586"/>
		<updated>2020-08-20T09:35:54Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Roundtime Handling */ Included more detailed information about causes, and additional solutions.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* GOTO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;:  Instructs the script to jump to the line labeled with the string.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
Note that labels do not restrict the script or actually divide it into sections.  If the script comes to a line with a label on it, it will continue to execute, regardless of whether or not it was explicitly sent to that label.  If your intention is &#039;&#039;not&#039;&#039; that the script continue on through a label and to the next line, you need to include some code to prevent that, such as preceding the label with an EXIT command or a GOTO for a different label.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. It is fine that multiple results use the same label, since the label exists independently of the MATCH table.  For example, the instruction for a MATCH of &amp;quot;You&amp;quot; to go to the cycle label does not replace or alter the previous instruction that a MATCH of &amp;quot;Stow what?&amp;quot; should go to the same label.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible MATCH, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.  However, when game text contains line breaks, the script searches for all MATCHes up to the first line break, then for all MATCHes up to the second line break, and so forth.  Once a MATCH is found, it can only be supplanted by a higher-priority MATCH if it occurs before the next line break.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. Other front ends do not share this function, and even in StormFront it is not always effective.  Often, a script will quickly enter two consecutive game commands by way of PUT or MOVE script commands.  The player may think nothing of chaining commands in this way, due to the claim that StormFront scripts automatically wait during roundtimes.  But, in actuality, this can result in the second command being entered before the first command has been parsed.  The second command is entered before the game has generated results for the first command, including any roundtime.  Thus, at the instant that the script is ready to enter the second command, a fraction of a second after the first command is entered, it finds the game state to &#039;&#039;not&#039;&#039; be in a roundtime and enters that second command.  If the first command causes a roundtime and the second command is one that cannot be done in roundtime, the game will be unable to carry out the second command, but this is already out of the script&#039;s control.  In addition, even when a script is waiting for a roundtime to end as intended by the player, StormFront&#039;s timing is sometimes off; it is common for a script to enter a command with 1 second left on a roundtime, which can cause the rest of the script to become useless.&lt;br /&gt;
&lt;br /&gt;
There are remedies to roundtime issues.  One common solution is to catch failures by including a MATCH for &amp;quot;...wait&amp;quot; from the roundtime messaging; if the script inadvertently runs afoul of a roundtime, the MATCH can be used to direct the script to a label that will let it re-attempt the action.  Alternatively, the line &amp;lt;pre&amp;gt;WAITFOR ROUNDTIME&amp;lt;/pre&amp;gt; is very common in scripts.  This isn&#039;t a special command; it&#039;s just a normal WAITFOR that is looking for the text &amp;quot;roundtime&amp;quot;.  If placed immediately after a command that results in a roundtime, this line forces the script to wait until the game&#039;s messaging for the previous command is complete, because the labeled roundtime is the last line printed.  At that point, StormFront normally will correctly identify that the player character is in roundtime, and will not attempt to enter the next command until that roundtime finishes.  To ensure it correctly times that last second, a simple PAUSE command can be included immediately before the next game command.  (With no numerical argument, PAUSE defaults to one second.)  Note that WAITFOR ROUNDTIME is unnecessary if the command is already followed by MATCHWAIT or a more specific WAITFOR, because these commands also force the script to wait for the game&#039;s messaging.  In fact, they would interfere with each other;  if WAITFOR ROUNDTIME comes first, it will prevent the script from finding any other target text that is part of the command&#039;s messaging, and if it comes second it will not find the roundtime for that action because it wouldn&#039;t start waiting until after the full messaging, including the roundtime, has already been output.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527585</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527585"/>
		<updated>2020-08-20T05:30:53Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Simple Commands */ Added GOTO, which is used but not explained.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* GOTO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;:  Instructs the script to jump to the line labeled with the string.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
Note that labels do not restrict the script or actually divide it into sections.  If the script comes to a line with a label on it, it will continue to execute, regardless of whether or not it was explicitly sent to that label.  If your intention is &#039;&#039;not&#039;&#039; that the script continue on through a label and to the next line, you need to include some code to prevent that, such as preceding the label with an EXIT command or a GOTO for a different label.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. It is fine that multiple results use the same label, since the label exists independently of the MATCH table.  For example, the instruction for a MATCH of &amp;quot;You&amp;quot; to go to the cycle label does not replace or alter the previous instruction that a MATCH of &amp;quot;Stow what?&amp;quot; should go to the same label.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible MATCH, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.  However, when game text contains line breaks, the script searches for all MATCHes up to the first line break, then for all MATCHes up to the second line break, and so forth.  Once a MATCH is found, it can only be supplanted by a higher-priority MATCH if it occurs before the next line break.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527584</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527584"/>
		<updated>2020-08-20T05:24:03Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Labels */ Added info about labels encountered during script execution.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
Note that labels do not restrict the script or actually divide it into sections.  If the script comes to a line with a label on it, it will continue to execute, regardless of whether or not it was explicitly sent to that label.  If your intention is &#039;&#039;not&#039;&#039; that the script continue on through a label and to the next line, you need to include some code to prevent that, such as preceding the label with an EXIT command or a GOTO for a different label.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. It is fine that multiple results use the same label, since the label exists independently of the MATCH table.  For example, the instruction for a MATCH of &amp;quot;You&amp;quot; to go to the cycle label does not replace or alter the previous instruction that a MATCH of &amp;quot;Stow what?&amp;quot; should go to the same label.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible MATCH, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.  However, when game text contains line breaks, the script searches for all MATCHes up to the first line break, then for all MATCHes up to the second line break, and so forth.  Once a MATCH is found, it can only be supplanted by a higher-priority MATCH if it occurs before the next line break.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527583</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527583"/>
		<updated>2020-08-20T05:17:52Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Matches */ Clarified acceptability of label reuse.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. It is fine that multiple results use the same label, since the label exists independently of the MATCH table.  For example, the instruction for a MATCH of &amp;quot;You&amp;quot; to go to the cycle label does not replace or alter the previous instruction that a MATCH of &amp;quot;Stow what?&amp;quot; should go to the same label.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible MATCH, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.  However, when game text contains line breaks, the script searches for all MATCHes up to the first line break, then for all MATCHes up to the second line break, and so forth.  Once a MATCH is found, it can only be supplanted by a higher-priority MATCH if it occurs before the next line break.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527582</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527582"/>
		<updated>2020-08-20T05:08:35Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Match Priority */ Added that line breaks interrupt MATCH priority.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. The fact that the label is the same regardless of the outcome is not important since any number of labels can be mixed.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible MATCH, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.  However, when game text contains line breaks, the script searches for all MATCHes up to the first line break, then for all MATCHes up to the second line break, and so forth.  Once a MATCH is found, it can only be supplanted by a higher-priority MATCH if it occurs before the next line break.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527580</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527580"/>
		<updated>2020-08-20T04:56:02Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* MATCH Quirks */ Added information about these and other quirks.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. The fact that the label is the same regardless of the outcome is not important since any number of labels can be mixed.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible match, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some quirks that can sometimes be exploited for specialized purposes, but at other times causes unexpected script behavior.&lt;br /&gt;
&lt;br /&gt;
While MATCH is almost always used with a MATCHWAIT (and indeed the StormFront Scripting Reference describes MATCH only in terms of being followed by a MATCHWAIT), a MATCHWAIT is not actually required.  Once a MATCH is defined, any occurrence of matched text will trigger the script to jump to the corresponding label.  For this reason, a MATCH table should generally be placed only immediately before the command that is expected to produce text to be matched; if the MATCHes are active too early, they could coincidentally be triggered by text unrelated to their intended targets, such as if another character in the room manipulates an object with the same name as an object your script is meant to interact with.  And when no MATCHWAIT is used, the MATCHes will continue searching and can be triggered as long as the script is still running.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will divert to the run label; if this was not the player&#039;s intention, the script needs to be edited appropriately.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.  If the MATCHes are desired again later, they need to be written in the script again, or the script needs to execute from a label preceding the MATCHes.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. So if you need the script to PAUSE or WAIT in relation to a command used with a MATCH, it is best to include that after the MATCH&#039;s label, rather than immediately after a command that is expected to generate text containing MATCHes.&lt;br /&gt;
&lt;br /&gt;
Further, after a MATCH occurs, any segment of text that the game output at the same time as the MATCHed text has already been scanned, even if it contained line breaks.  As a result, if you want to MATCH with a string only when it occurs after some other string, in a single game output, you cannot do it by chaining MATCHES, i.e., by MATCHing the first string and then immediately trying to MATCH the second string; by the time the second MATCH starts, the output in which the first string was found can no longer be searched due to having already been searched for the first MATCH.  Instead, try a regular expression (see below) containing both strings, with wildcards between them.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527576</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527576"/>
		<updated>2020-08-20T03:52:11Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Match Order */ Clarified section.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. The fact that the label is the same regardless of the outcome is not important since any number of labels can be mixed.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Priority===&lt;br /&gt;
It is important to understand how MATCH operates on text containing more than one MATCH string.  The MATCH will be triggered by the first line containing at least one match string.  But if the line contains more than one possible match, the script assigns priority by the order in which the MATCHes are listed in the script itself--&#039;&#039;not&#039;&#039; the order in which the strings appear in the triggering line.  So MATCHes should be listed in order of importance.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some odd quirks that can be used for specialized purposes. A MATCH will keep looking for it&#039;s string until any MATCH is made. This is unimportant in the typical &amp;quot;MATCH table&amp;quot; such as the first example given above. But if no MATCHWAIT is used, the MATCHes will continue searching.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will suddenly divert to the run label, which can be good or bad.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. This means including PAUSE or WAIT into a MATCH table will result in very odd behavior.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
	<entry>
		<id>https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527562</id>
		<title>How to Script</title>
		<link rel="alternate" type="text/html" href="https://elanthipedia.play.net/index.php?title=How_to_Script&amp;diff=527562"/>
		<updated>2020-08-20T00:46:36Z</updated>

		<summary type="html">&lt;p&gt;DSETHK93: /* Simple Commands */ Added ECHO, which is used in examples below but never explained on this page.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| align=&amp;quot;center&amp;quot; width=&amp;quot;800&amp;quot; style=&amp;quot;background-color: #FFAAAA; border: 1px solid #FF0000; width:85%; padding:1em; text-align:center&amp;quot;&lt;br /&gt;
|rowspan=2|[[Image:Caution.png]]&lt;br /&gt;
|&amp;lt;br /&amp;gt;&amp;lt;font size=&amp;quot;15&amp;quot;&amp;gt;Read This First&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
Unless you are playing in [[The Fallen]], scripting while unresponsive, regardless of your status at the keyboard, is against the rules. It is your responsibility to create scripts that will not continue endlessly, in case you fall asleep or have to leave the keyboard suddenly.&amp;lt;br /&amp;gt;&lt;br /&gt;
This is not a trivial matter and can result in experience penalties, character loss, or permanent lockout.&amp;lt;br /&amp;gt;&#039;&#039;&#039;In game type &amp;quot;NEWS 5 17&amp;quot; to review DR scripting policy.&#039;&#039;&#039;&amp;lt;br /&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;font size=&amp;quot;5&amp;quot;&amp;gt;You have been warned.&amp;lt;/font&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
{{RTOC}}&lt;br /&gt;
&lt;br /&gt;
This section will cover the most basic tools for scripting in the eScape and StormFront FEs.&lt;br /&gt;
&lt;br /&gt;
==Important Notes==&lt;br /&gt;
* Empty space before a command is ignored.&lt;br /&gt;
* Empty lines are ignored.&lt;br /&gt;
* If the end of the script is reached, the script exits.&lt;br /&gt;
* All commands are case insensitive, though variables are not.&lt;br /&gt;
* Only one command can be put on a line.&lt;br /&gt;
&lt;br /&gt;
==Simple Commands==&lt;br /&gt;
* # : Used for commenting, any line that begins with the number symbol is ignored by the script.&lt;br /&gt;
* ECHO &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This displays the string in the game window.  It is useful for debugging and generally for monitoring script run status.&lt;br /&gt;
* PUT &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will cause the script to enter the string as if you typed it into the game and hit enter.&lt;br /&gt;
* MOVE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will do the same thing as PUT, but will then pause the script until a new room is entered.&lt;br /&gt;
* WAIT: This command will pause the script until a prompt is received. It is not affected by suppressing prompts in game.&lt;br /&gt;
* WAITFOR &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: This will pause the script until it sees the string.&lt;br /&gt;
* WAITFORRE &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;: Same as WAITFOR but allows the use of Regular Expressions. See the advanced section for more details.&lt;br /&gt;
* NEXTROOM: This will cause the script to wait until you enter a new room.&lt;br /&gt;
* PAUSE &#039;&#039;&amp;lt;#&amp;gt;&#039;&#039;: This will pause the script for the indicated number of seconds.&lt;br /&gt;
* SAVE: This is only useful in the Wizard, as it does not support standard global variables. See [[#Variables|Variables section]] for the function that replaced it.&lt;br /&gt;
* EXIT: This will end the script.&lt;br /&gt;
&lt;br /&gt;
==Labels==&lt;br /&gt;
Labels are basically like signposts that you can cause the script to jump to. The most common way to cause a script to switch to a label is using &amp;quot;GOTO &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039;&amp;quot; although MATCH/MATCHRE is another way.&lt;br /&gt;
&lt;br /&gt;
A label is placed by putting a word on its own line, followed by a colon, such as&lt;br /&gt;
&amp;lt;pre&amp;gt;thisIsALabel:&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Labels are not case sensitive, so &amp;quot;Label&amp;quot; is the same as &amp;quot;label&amp;quot; is the same as &amp;quot;lAbEl&amp;quot;. Labels cannot have spaces in them, or anything after the colon.&lt;br /&gt;
&lt;br /&gt;
==Pause and Wait==&lt;br /&gt;
Note that these are problematic commands to use, as the entire script pauses when used. This means that it won&#039;t do things like match strings, even if the text shows up. Note that this does not happen during MATCHWAIT (see Match section).&lt;br /&gt;
&lt;br /&gt;
It is generally a better idea to use a MATCH/MATCHWAIT pair instead.&lt;br /&gt;
&lt;br /&gt;
==Matches==&lt;br /&gt;
The combined use of MATCH, MATCHRE and MATCHWAIT are essential tools for the majority of intermediate and advanced scripts.&lt;br /&gt;
&lt;br /&gt;
The MATCH command is executed with two parts, the label and the match string, in the form of &amp;quot;MATCH &#039;&#039;&amp;lt;label&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039;&amp;quot;. If the &#039;&#039;&amp;lt;string&amp;gt;&#039;&#039; is found, the script will immedately jump to the specified label.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an example pulled from a real script (note: the numbers are the line numbers and are not part of the script):&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCH cycle Stow what?&lt;br /&gt;
4	MATCH cycle You are already wearing that.&lt;br /&gt;
5	MATCH cycle But that is already in your inventory.&lt;br /&gt;
6	MATCH cycle You&lt;br /&gt;
7	PUT stow my pickle&lt;br /&gt;
8	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The combination of lines one and two illustrate the most common use for for MATCH. If the game pops up &amp;quot;...wait x seconds&amp;quot; when you attempt a command, it will cycle back to the label on line one and attempt it again.&lt;br /&gt;
&lt;br /&gt;
Lines 3-6 watch for the various outcomes of the command on 7, and will jump to the specified label upon detecting them. The fact that the label is the same regardless of the outcome is not important since any number of labels can be mixed.&lt;br /&gt;
&lt;br /&gt;
Lastly, line 8 is a special command that tells the script &amp;quot;wait here until a match is found&amp;quot;. This can either be desirable, such as if you&#039;re waiting for the barge and don&#039;t want to do anything till it shows up, or can be undesirable, such as when your action produces a result you didn&#039;t put in a MATCH for and will wait forever.&lt;br /&gt;
&lt;br /&gt;
MATCHRE allows use of Regular Expressions in the search string. See the advanced section for details on regular expressions.&lt;br /&gt;
&lt;br /&gt;
===Match Order===&lt;br /&gt;
An important thing to understand the order in which text is MATCHed. It can be thought of as being a first come first serve command. The first line with a MATCH result to come up triggers the MATCH. However, if a line contains two possible MATCHes, then it will go by the order in which the MATCHes are listed in the script itself. Therefor, it is a good idea to list them in order of importance.&lt;br /&gt;
&lt;br /&gt;
===MATCH Quirks===&lt;br /&gt;
MATCH has some odd quirks that can be used for specialized purposes. A MATCH will keep looking for it&#039;s string until any MATCH is made. This is unimportant in the typical &amp;quot;MATCH table&amp;quot; such as the first example given above. But if no MATCHWAIT is used, the MATCHes will continue searching.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	root:&lt;br /&gt;
2	MATCH root ...wait&lt;br /&gt;
3	MATCH run punches you&lt;br /&gt;
4	MATCH hide shoots you&lt;br /&gt;
5	PUT punch bob&lt;br /&gt;
6	PUT kick bob&lt;br /&gt;
7&lt;br /&gt;
8	retreat:&lt;br /&gt;
9	PUT retreat&lt;br /&gt;
10	.....&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the above example, since there is no MATCHWAIT it will punch, then kick, then head onto the retreat label. If somewhere down the line, &amp;quot;punches you&amp;quot; shows up, then it will suddenly divert to the run label, which can be good or bad.&lt;br /&gt;
&lt;br /&gt;
Again, note that once any MATCH has been made, all previous MATCHes are removed.&lt;br /&gt;
&lt;br /&gt;
In addition, MATCHes will not occur on text that shows up during a PAUSE or a WAIT, but will during a MATCHWAIT. This means including PAUSE or WAIT into a MATCH table will result in very odd behavior.&lt;br /&gt;
&lt;br /&gt;
==Variables==&lt;br /&gt;
Variables are basically storage locations for words. They allow you to imput information in one place and retreive it at another. They are refered to using the syntax &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;%target&amp;quot; or &amp;quot;%person&amp;quot;. Note: Unlike labels, variables are case sensitive; &amp;quot;%variable&amp;quot; is NOT the same as &amp;quot;%Variable&amp;quot; or &amp;quot;%vArIaBlE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two main types of variables, and two special ones.&lt;br /&gt;
&lt;br /&gt;
===Command Line Variables===&lt;br /&gt;
The first type is called a command line variable. When you start your script using the &amp;quot;.&#039;&#039;&amp;lt;scriptname&amp;gt;&#039;&#039;&amp;quot; method, after the name you can input up to 9 other words for storage. Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;	.kill him andHim andHimToo her monkey randomGuy&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These are then able to be accessed by the script. They are accessed using &amp;quot;%0&amp;quot; through &amp;quot;%9&amp;quot;, with &amp;quot;%1&amp;quot; being the first word after the script name, &amp;quot;%2&amp;quot; being the second, etc. Note that &amp;quot;%0&amp;quot; is the same as putting &amp;quot;%1 %2 %3 %4 %5&amp;quot; .... &amp;quot;%9&amp;quot;, listing out all the command line variables.&lt;br /&gt;
&lt;br /&gt;
%0 is a special variable that contains all command line variables, including those beond %9.&lt;br /&gt;
&lt;br /&gt;
If you want to use multiple words as a single variable, there are two ways to do this.&lt;br /&gt;
* word_word_word&lt;br /&gt;
* &amp;quot;word word word&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Unfortunately, command line variables cannot be changed once the script is started, with a few exceptions, the major one being SHIFT. Upon encountering SHIFT, &amp;quot;%1&amp;quot; is deleted, and the rest is shifted down one, with &amp;quot;%2&amp;quot; now being &amp;quot;%1&amp;quot;, &amp;quot;%3&amp;quot; being &amp;quot;%2&amp;quot;, all the way to &amp;quot;%9&amp;quot; which is now empty.&lt;br /&gt;
&lt;br /&gt;
How are these useful? Perhaps you wish to write a script that picks and disarms a box for you, however your box can be a crate, a strongbox, a box or even a coffer. Using &amp;quot;%1&amp;quot; in the proper place, you can run your script with &amp;quot;.pick coffer&amp;quot; and it will target your coffer for opening.&lt;br /&gt;
&lt;br /&gt;
Note: These variables are deleted if the script ends for any reason.&lt;br /&gt;
&lt;br /&gt;
It should be noted that if more than 9 variables are used, the program will store them, but they will be unavailable without use of the SHIFT command. For example, if you do include a tenth variable, the first SHIFT will cause it to become &amp;quot;%9&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
===Save===&lt;br /&gt;
The SAVE command, while supported by later versions, is only useful in the Wizard FE. Using SAVE will store the following text into a special variable called %s.&lt;br /&gt;
&lt;br /&gt;
For example,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt; SAVE VariableContents&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
will store VariableContents in %s. This has been superceded by global variables in all later Simutronics Front Ends.&lt;br /&gt;
&lt;br /&gt;
===Global Variables===&lt;br /&gt;
These variables are a different sort, because they can both be accessed from within the script and because they will remain after the script ends. However, unlike command line variables, they can only be altered by a script or through the Variables panel. Like all variables, they take the form of &amp;quot;%&#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
There are two major script commands for interacting with standard variables. The first is SETVARIABLE, which uses the syntax &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name without the %&amp;gt;&#039;&#039; &#039;&#039;&amp;lt;variable contents&amp;gt;&#039;&#039;&amp;quot; such as &amp;quot;SETVARIABLE weapon sword&amp;quot;. One thing to realize is that you can set a variable to nothing, by using &amp;quot;SETVARIABLE &#039;&#039;&amp;lt;variable name&amp;gt;&#039;&#039;&amp;quot;, which can be useful in some advanced scripting.&lt;br /&gt;
&lt;br /&gt;
The second way to interact with them is using DELETEVARIABLE, which does what you&#039;d expect: it removes the variable and its contents.&lt;br /&gt;
&lt;br /&gt;
It is important to distinguish between an empty variable and a deleted variable. An empty variable when you call it, simply adds a blank space, but a deleted variable will insert the variable name when called. Example:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Command:&#039;&#039;&#039;&lt;br /&gt;
: PUT pick coffer %way&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Empty:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer &lt;br /&gt;
:: This will end up picking your coffer normally&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Deleted:&#039;&#039;&#039;&lt;br /&gt;
: Result: pick coffer %way&lt;br /&gt;
::This will result in the game telling you it cannot find your &amp;quot;coffer %way&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
==Counter==&lt;br /&gt;
The counter command provides the ability to do simple math and store the outcome to a variable. You are able to use the counter command in the following ways.&lt;br /&gt;
: COUNTER ( SET | ADD | SUBTRACT | MULTIPLY | DIVIDE ).&lt;br /&gt;
&lt;br /&gt;
The ability to do simple math and store the the value for use later opens up some great possibilities for your scripts.&lt;br /&gt;
&lt;br /&gt;
The counter value itself is stored in the %c variable.&lt;br /&gt;
&lt;br /&gt;
===Counter Commands===&lt;br /&gt;
&#039;&#039;&#039;SET:&#039;&#039;&#039;&lt;br /&gt;
: The SET command allows you to set the %c variable to whatever number (or another variable holding a number)&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;ADD:&#039;&#039;&#039;&lt;br /&gt;
: The ADD command allows you to add a specified number (or variable containing a number) to the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER ADD 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;SUBTRACT:&#039;&#039;&#039;&lt;br /&gt;
: The SUBTRACT command allows you to subtract a specified number (or variable containing a number) from the current counter value.&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER SUBTRACT 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;MULTIPLY:&#039;&#039;&#039;&lt;br /&gt;
: The MULTIPLY command allows you to multiple the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER MULTIPLY 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&#039;&#039;&#039;DIVIDE:&#039;&#039;&#039;&lt;br /&gt;
: The DIVIDE command allows you to divide the current counter value by a specified number (or variable containing a number).&lt;br /&gt;
&amp;lt;pre&amp;gt;1	COUNTER SET 52&lt;br /&gt;
2	ECHO the counter is %c&lt;br /&gt;
3	COUNTER DIVIDE 10&lt;br /&gt;
4	ECHO the counter is %c&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It should be noted that StormFront does not handle decimals at all, and they are simply truncated (rounded down to the nearest whole number).&lt;br /&gt;
&lt;br /&gt;
===Multiple Counters===&lt;br /&gt;
The scripting engine itself does not allow you to have multiple counter variables going at once, there is however a way to get around this.&lt;br /&gt;
Since the engine allows you to store one variable to another, and also allows you to set the current value of the counter you are able&lt;br /&gt;
to preform a little coding magic, and give yourself multiple counters to work with.&lt;br /&gt;
&lt;br /&gt;
The example below takes use of the fact you can set the counter to another variable (provided its a number), then do your math on it, and then&lt;br /&gt;
store its value back to the original variable. Essentially this allows you to have as many counters going on as your heart desires.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	SETVARIABLE MyCounter1 10&lt;br /&gt;
2	SETVARIABLE MyCounter2 20&lt;br /&gt;
3     &lt;br /&gt;
4	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
5	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
6     &lt;br /&gt;
7	COUNTER SET %MyCounter1&lt;br /&gt;
8	ECHO the counter is currently %c&lt;br /&gt;
9	COUNTER ADD 5&lt;br /&gt;
10	ECHO the counter is currently %c&lt;br /&gt;
11	SETVARIABLE MyCounter1 %c&lt;br /&gt;
12     &lt;br /&gt;
13	COUNTER SET %MyCounter2&lt;br /&gt;
14	ECHO the counter is currently %c&lt;br /&gt;
15	COUNTER ADD 5&lt;br /&gt;
16	ECHO the counter is currently %c&lt;br /&gt;
17	SETVARIABLE MyCounter2 %c&lt;br /&gt;
18     &lt;br /&gt;
19	ECHO MyCounter1 is %MyCounter1&lt;br /&gt;
20	ECHO MyCounter2 is %MyCounter2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Logic==&lt;br /&gt;
Many people look at the list of commands and falsely believe that there is no way to control a script beyond the initial command line variables and primative MATCHes and that there are no ways to compare values. The following is a list of ways to give greater responsiveness to these scripts.&lt;br /&gt;
&lt;br /&gt;
===IF===&lt;br /&gt;
The most basic logic statements is the IF_&#039;&#039;&amp;lt;#1-9&amp;gt;&#039;&#039;. When this is added to the line before a command, it will check whether or not the variable is present and, if so, execute the command normally.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	IF_1 GOTO %1&lt;br /&gt;
2	GOTO exit&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This set of lines would check to see if there was anything in command line variable 1 and if so, go to the label that matches it. If not, it would exit the program.&lt;br /&gt;
&lt;br /&gt;
===MATCH/Variable Pairs===&lt;br /&gt;
One of the issues often encountered that MATCH can&#039;t do alone is finding a way to match a string and alter it&#039;s behavior later, beyond the next step. This can be done by using a MATCH to go to a label that will then set a variable.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	MATCH scorpion A scorpion walks in&lt;br /&gt;
2	MATCH spider A spider walks in&lt;br /&gt;
3	MATCHWAIT&lt;br /&gt;
4&lt;br /&gt;
5	scorpion:&lt;br /&gt;
6	SETVARIABLE someVariable scorpion&lt;br /&gt;
7	GOTO nextstep&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see, this enables a variable that can be used much later in the script. In theory, you can set it to react to as many conditions as you want to build MATCH and SETVARIABLE pairs for.&lt;br /&gt;
&lt;br /&gt;
However, the is no way to directly load text from the game into a variable. All possible settings have to be built into the script prior to the event.&lt;br /&gt;
&lt;br /&gt;
===Label/Variable Pairs===&lt;br /&gt;
One of the other important functions needed to a way to vary a script&#039;s behavior based on variables. While IF can do a primitive version of this, and using variables with in game commands can cover many situations, there is a way to do completely internal changes.&lt;br /&gt;
&lt;br /&gt;
An important fact is that both GOTO and MATCH will allow the use of variables in their names. We saw this earlier with GOTO %1, but it&#039;s possible to build compound labels, such as GOTO weapon%WeaponVariable.&lt;br /&gt;
&lt;br /&gt;
If we continue the previous example:&lt;br /&gt;
&amp;lt;pre&amp;gt;1	nextstep:&lt;br /&gt;
2	GOTO creature%someVariable&lt;br /&gt;
3&lt;br /&gt;
4	creatureScorpion:&lt;br /&gt;
5	GOTO fight&lt;br /&gt;
6&lt;br /&gt;
7	creatureSpider:&lt;br /&gt;
8	GOTO runAway&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This would allow you to set your script to fight scorpions, but run away if spiders arrive.&lt;br /&gt;
&lt;br /&gt;
====Labelerror====&lt;br /&gt;
There is a special use for the special errorlabel label. Recall that errorlabel will catch any GOTO or MATCH that attempts to go to a label that doesn&#039;t exist.&lt;br /&gt;
&lt;br /&gt;
This label can be used with Label/Variable pairs to handle all cases which do not have a section for them. This doesn&#039;t happen with variable labels that are set inside the script as you can be sure to set all options, but can be useful in the case of a label that uses a command line. Since it is impossible to be account for all possible things that might be entered by the user, this is a good catchall for &amp;quot;everything else.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO punch%1&lt;br /&gt;
2&lt;br /&gt;
3	punchBob:&lt;br /&gt;
4	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you were to use this, and the user enters anything other than &amp;quot;bob&amp;quot; then the script aborts with an error about the label not existing.&lt;br /&gt;
&lt;br /&gt;
Not that this can be a problematic process to use, as this label will catch ALL nonexistent labels, including all labels that are typoed or otherwise bugged, and this can make troubleshooting difficult.&lt;br /&gt;
&lt;br /&gt;
====Partial Matching====&lt;br /&gt;
While there is no built in way to partially match an incomplete command line variable, there is brute force trick to save yourself some typing,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	GOTO %1&lt;br /&gt;
2&lt;br /&gt;
3	swo:&lt;br /&gt;
4	swor:&lt;br /&gt;
5	sword:&lt;br /&gt;
6	swords:&lt;br /&gt;
7	blah blah blah blah&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
As you can see by that, it will match even a partial piece of &amp;quot;swords.&amp;quot; This often best used when a command line variable is used to activate a small piece of a program, for example, to activate the pounding section of a forging script.&lt;br /&gt;
&lt;br /&gt;
==Regular Expressions==&lt;br /&gt;
Both the MATCHRE and WAITFORRE functions support regular expressions, a way of setting conditions that can match several options. They are incredibly useful for keeping the amount of lines your code is down to a minimum.&lt;br /&gt;
&lt;br /&gt;
It functions exactly the same as a MATCH/WAITFOR, except that a pipe ( &amp;lt;code&amp;gt;|&amp;lt;/code&amp;gt; ) separates each of the regular expressions, and that it must start and end with forward slashes ( &amp;lt;code&amp;gt;/&amp;lt;/code&amp;gt; ).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	putAway:&lt;br /&gt;
2	MATCH putAway ...wait&lt;br /&gt;
3	MATCHRE cycle / (Stow what?|You are already wearing that.|But that is already in your inventory.|You) /&lt;br /&gt;
4	PUT stow my pickle&lt;br /&gt;
5	MATCHWAIT&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will goto cycle if &amp;quot;Stow what?&amp;quot; &amp;quot;You are already wearing that.&amp;quot; &amp;quot;But that is already in your inventory.&amp;quot; or even just plain &amp;quot;You&amp;quot; occurs.&lt;br /&gt;
&lt;br /&gt;
The /s are used to set the area, the ( and ) sets the area that will vary, and the | will separate the possibilities. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match either &amp;quot;blue ball bounces by&amp;quot; or &amp;quot;green ball bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
If the line is ended in /i rather then /, then it will ignore the case of the letters, otherwise it is case sensitive. For example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;1	PUT pull lever&lt;br /&gt;
2	MATCH ball /(blue|green) ball bounces by/i&lt;br /&gt;
3	PUT get ball&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will match &amp;quot;blue ball bounces by&amp;quot;, &amp;quot;green ball bounces by&amp;quot;, or even &amp;quot;BlUE baLL bounces by&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A list of additional regex syntax options can be found here: [https://msdn.microsoft.com/en-us/library/az24scfc(v=vs.110).aspx#character_classes]&lt;br /&gt;
&lt;br /&gt;
==Roundtime Handling==&lt;br /&gt;
StormFront, in general, will not proceed to the next action until the previous action&#039;s roundtime has ended. This is a function not shared by other front ends, but is not always effective.&lt;br /&gt;
&lt;br /&gt;
Thus, while it is not always needed, it is useful to add a MATCH for &amp;quot;...wait&amp;quot; to catch failures.&lt;/div&gt;</summary>
		<author><name>DSETHK93</name></author>
	</entry>
</feed>