<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://avendar.net/index.php?action=history&amp;feed=atom&amp;title=Avendar%3AProg_Section_2</id>
	<title>Avendar:Prog Section 2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://avendar.net/index.php?action=history&amp;feed=atom&amp;title=Avendar%3AProg_Section_2"/>
	<link rel="alternate" type="text/html" href="https://avendar.net/index.php?title=Avendar:Prog_Section_2&amp;action=history"/>
	<updated>2026-04-17T23:40:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.4</generator>
	<entry>
		<id>https://avendar.net/index.php?title=Avendar:Prog_Section_2&amp;diff=2668&amp;oldid=prev</id>
		<title>Elanthe: Created page with &quot;&#039;&#039;&quot;Moods are for cattle and loveplay, not for fighting!&quot;&#039;&#039; :&#039;&#039;-- Gurney Halleck, Dune&#039;&#039;  More often than not, you will want to reference the persons, mobs, or things associated  with progs. Furthermore, you will not, a priori, know the names of the persons, mobs, or  items which trigger or are acted on by the progs. The solution to this is a system of  variables.   &#039;&#039;&#039;Variable Syntax:&#039;&#039;&#039;  ==1. The $ symbol==  :The $ symbol prefaces every non-local variable. It is equival...&quot;</title>
		<link rel="alternate" type="text/html" href="https://avendar.net/index.php?title=Avendar:Prog_Section_2&amp;diff=2668&amp;oldid=prev"/>
		<updated>2025-01-19T03:07:32Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;&amp;#039;&amp;#039;&amp;quot;Moods are for cattle and loveplay, not for fighting!&amp;quot;&amp;#039;&amp;#039; :&amp;#039;&amp;#039;-- Gurney Halleck, Dune&amp;#039;&amp;#039;  More often than not, you will want to reference the persons, mobs, or things associated  with progs. Furthermore, you will not, a priori, know the names of the persons, mobs, or  items which trigger or are acted on by the progs. The solution to this is a system of  variables.   &amp;#039;&amp;#039;&amp;#039;Variable Syntax:&amp;#039;&amp;#039;&amp;#039;  ==1. The $ symbol==  :The $ symbol prefaces every non-local variable. It is equival...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;#039;&amp;#039;&amp;quot;Moods are for cattle and loveplay, not for fighting!&amp;quot;&amp;#039;&amp;#039;&lt;br /&gt;
:&amp;#039;&amp;#039;-- Gurney Halleck, Dune&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
More often than not, you will want to reference the persons, mobs, or things associated &lt;br /&gt;
with progs. Furthermore, you will not, a priori, know the names of the persons, mobs, or &lt;br /&gt;
items which trigger or are acted on by the progs. The solution to this is a system of &lt;br /&gt;
variables. &lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Variable Syntax:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
==1. The $ symbol==&lt;br /&gt;
&lt;br /&gt;
:The $ symbol prefaces every non-local variable. It is equivalent to saying &amp;quot;the value which is &lt;br /&gt;
:stored in&amp;quot;. So, letâ€™s suppose we have a variable called n. nâ€™s current value is &amp;#039;Jolinn&amp;#039; &lt;br /&gt;
:(itâ€™s a character value). Every time the prog sees $n, the prog engine interprets that as&lt;br /&gt;
:&amp;#039;the value stored in n&amp;#039;, which means that every time the prog sees $n, it reads it as &amp;#039;Jolinn&amp;#039;.&lt;br /&gt;
:Additionally, it is possible to have multiple &amp;#039;$&amp;#039; characters iterated, defined recursively.&lt;br /&gt;
:I.e., suppose we have two variables, 3 and 4. &lt;br /&gt;
&lt;br /&gt;
:    If &lt;br /&gt;
:   $4 == 3&lt;br /&gt;
:    and&lt;br /&gt;
:    $3 == 5000&lt;br /&gt;
:    then $$4 == $(3) == $3 == 5000&lt;br /&gt;
&lt;br /&gt;
==2. List of variables==&lt;br /&gt;
&lt;br /&gt;
:The following table provides a summary of the most basic variables.&lt;br /&gt;
&lt;br /&gt;
 a:                                    A: &lt;br /&gt;
 b: short desc. of obj carrier         B: his/her of obj carrier&lt;br /&gt;
 c:                                    C: &lt;br /&gt;
 d: the current line of set data prog  D: &lt;br /&gt;
 e: he/she of actor                    E: he/she of focus &lt;br /&gt;
 f: name of focused on                 F: short desc. of focused on &lt;br /&gt;
 f0: name of focus 0.                  F0: short desc. of focus 0. &lt;br /&gt;
 f1: name of focus 1.                  F1: short desc. of focus 1. &lt;br /&gt;
 g:                                    G: &lt;br /&gt;
 h: Amount of damage done by a hit     H:&lt;br /&gt;
    (see hit prog)&lt;br /&gt;
 i: name of mob                        I: short desc. of mob &lt;br /&gt;
 j: he/she of mob                      J: he/she of random &lt;br /&gt;
 k: him/her of mob                     K: him/her of random &lt;br /&gt;
 l: his/her of mob                     L: his/her of random &lt;br /&gt;
 m: him/her of actor                   M: him/her of focus&lt;br /&gt;
                                       M0: him/her of focus slot 0&lt;br /&gt;
                                       M1: him/her of focus slot 1 &lt;br /&gt;
 n: name of actor                      N: short desc. of actor &lt;br /&gt;
 o: if on mob: name of obj             O: if on a mob: short desc. of obj &lt;br /&gt;
    if on on an object: name of owner  O: if on an object: short desc. of owner &lt;br /&gt;
 p:                                    P: &lt;br /&gt;
 q:                                    Q: &lt;br /&gt;
 r: name of random                     R: short desc. of random &lt;br /&gt;
 s: his/her of actor                   S: his/her of focus slot&lt;br /&gt;
                                       S0: his/her of focus slot 0&lt;br /&gt;
                                       S1: his/her of focus slot 1 &lt;br /&gt;
 t: name of vict                       T: short desc. of vict &lt;br /&gt;
 u:                                    U: &lt;br /&gt;
 v: loop value check:                  V:&lt;br /&gt;
  v1: loop value, depth 1&lt;br /&gt;
  v2: loop value, depth 2&lt;br /&gt;
  vn: loop value, depth n,&lt;br /&gt;
      n a positive integer &amp;gt;= 1&lt;br /&gt;
 w:                                    W: &lt;br /&gt;
 x: text of command (if appli.)        X: $x, with the first word excluded &lt;br /&gt;
 y: argument lookup (punc.)            Y: argument lookup (punc. sensitive)&lt;br /&gt;
 y1: First word of argument            Y1: First word of argument&lt;br /&gt;
 y2: Second word of argument           Y2: Second word of argument&lt;br /&gt;
 yn: nth word of argument              Yn: nth word of argument &lt;br /&gt;
 z: value from mpremember              Z: Long desc. of actor&lt;br /&gt;
&lt;br /&gt;
1,2,3,4,5,6,7,8,9: Value stored in corresponding mobile integer memory value&lt;br /&gt;
&lt;br /&gt;
: Now, this is all a bit much to digest at once, but letâ€™s define what some of &lt;br /&gt;
: these terms mean:&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;actor&amp;lt;/b&amp;gt; of a prog is the entity which triggers the prog.&lt;br /&gt;
 &lt;br /&gt;
   Ex:&lt;br /&gt;
   greet_prog 100&lt;br /&gt;
   say Hello, $n&lt;br /&gt;
&lt;br /&gt;
: And Jolinn enters the room, the room will see:&lt;br /&gt;
&lt;br /&gt;
   The mob says, â€˜Hello, Jolinnâ€™&lt;br /&gt;
&lt;br /&gt;
: This is because Jolinn is the person who triggers the prog. &lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;mobile&amp;lt;/b&amp;gt; of the prog is the entity which has the prog, be it a mob or&lt;br /&gt;
: object.&lt;br /&gt;
&lt;br /&gt;
   Ex:&lt;br /&gt;
   greet_prog 100&lt;br /&gt;
   say This prog is on $I.&lt;br /&gt;
&lt;br /&gt;
: Letâ€™s suppose this mob were on â€˜a henâ€™. Whenever someone entered the room, they&lt;br /&gt;
: would see:&lt;br /&gt;
&lt;br /&gt;
   A hen says, â€˜This prog is on a hen.â€™Notice that here we use the capital version&lt;br /&gt;
   of the variable, $I, since the name of a mob is not really what we want to say to&lt;br /&gt;
   the room (its name might be hen yellow feathered loud demon -- not something you &lt;br /&gt;
   want to echo to the room!).&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;random&amp;lt;/b&amp;gt; prog variable selects a random target in the room. The random variable,&lt;br /&gt;
: once invoked within a given prog, remains the same for the duration of the prog. (So, if &lt;br /&gt;
: you have two instances of $r in a prog, they will both refer to the same (random) entity.) &lt;br /&gt;
: The random variable will also never reference the mobile or object on which the prog exists.&lt;br /&gt;
&lt;br /&gt;
   Ex:&lt;br /&gt;
   greet_prog 100&lt;br /&gt;
   say $r is a random person in the room.&lt;br /&gt;
&lt;br /&gt;
: Suppose that this prog is on a mob in a room with Jolinn, Iandir, and Aeolis. If Arkhural&lt;br /&gt;
: enters the room, the mob might do any one of the following.&lt;br /&gt;
&lt;br /&gt;
   The mob says, â€˜Jolinn is a random person in the room.â€™&lt;br /&gt;
   The mob says, â€˜Iandir is a random person in the room.â€™&lt;br /&gt;
   The mob says, â€˜Aeolis is a random person in the room.â€™&lt;br /&gt;
   The mob says, â€˜Arkhural is a random person in the room.â€™&lt;br /&gt;
&lt;br /&gt;
: Each of these has an equal probability of occurring.&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;victim&amp;lt;/b&amp;gt; variable refers to the object of the actor&amp;#039;s action. This variable is &lt;br /&gt;
: less frequently used, but denotes the subject of the actor&amp;#039;s ($n) action. Since it is not&lt;br /&gt;
: valid in every prog type, you should research whether your prog trigger even allows the &lt;br /&gt;
: use of this variable.&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;object&amp;lt;/b&amp;gt; variable refers to EITHER:&lt;br /&gt;
&lt;br /&gt;
: (i) The object which triggers the prog (if the prog is on a mob)&lt;br /&gt;
: (ii) The owner of the object (if the prog is on an object)&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;focus&amp;lt;/b&amp;gt; variable refers to a pc stored in a mobile focus slot. Weâ€™ll learn more about &lt;br /&gt;
: focus slots when we cover mobile memory, but for right now, the key fact is that the &lt;br /&gt;
: variables which are listed above are how we reference focus slots from within a prog.&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;loop&amp;lt;/b&amp;gt; variable is a variable used in loops to identify what iteration, or &amp;quot;step&amp;quot; a&lt;br /&gt;
: loop is currently on. We will discuss this variable more in the section on control structures.&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;command text&amp;lt;/b&amp;gt; variable is used to reference the text of a given progâ€™s argument. &lt;br /&gt;
: Essentially, whenever there is an argument to a prog_trigger which is a player input, $x,&lt;br /&gt;
: the command text variable, can be used to reference this value.&lt;br /&gt;
&lt;br /&gt;
   Ex: &lt;br /&gt;
   speech_prog p &lt;br /&gt;
   tell $n You just said $x. &lt;br /&gt;
&lt;br /&gt;
: This prog is a prog which triggers on anything spoken, and when it does, it invokes $x.&lt;br /&gt;
: $x, here, represents the entire line that trigged the prog. So, if this prog were on a mob,&lt;br /&gt;
: and someone in the room were to say &amp;quot;I hear Jolinn has quite the taste for ethron trollops.&amp;quot;&lt;br /&gt;
: the prog would trigger, and you would see:&lt;br /&gt;
&lt;br /&gt;
   Mob tells you, â€˜You just said I hear Jolinn has quite the taste for ethron trollops.â€™&lt;br /&gt;
&lt;br /&gt;
: $x has other, more interesting uses, as we will see later. $X is identical to $x, except that&lt;br /&gt;
: the first word is stripped. [This functionality is rarely used.]&lt;br /&gt;
&lt;br /&gt;
: The &amp;lt;b&amp;gt;argument lookup&amp;lt;/b&amp;gt; variable is a variable that allows us to reference the content &lt;br /&gt;
: of a progâ€™s argument. Essentially, an argument lookup variable works like this: Suppose we&lt;br /&gt;
: have the prog trigger speech_prog, which triggers when a certain key word or phrase is said.&lt;br /&gt;
: So, maybe weâ€™d like the mob to respond to:&lt;br /&gt;
&lt;br /&gt;
   &amp;quot;I want you to threaten &amp;lt;person&amp;gt;&amp;quot; &lt;br /&gt;
&lt;br /&gt;
: with a tell to &amp;lt;person&amp;gt;, telling them, &amp;quot;Youâ€™d better watch yourself, &amp;lt;person&amp;gt;!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
: Now, we want a speech_prog for this, so we might use:&lt;br /&gt;
&lt;br /&gt;
   speech_prog p I want you to threaten &lt;br /&gt;
&lt;br /&gt;
: But then weâ€™re left with being unable to pass the information about the word after &lt;br /&gt;
: &amp;quot;threaten&amp;quot;, since itâ€™s going to going to be something variable, and therefore not&lt;br /&gt;
: something you can put in a speech_prog (unless you had a speech prog for every n &lt;br /&gt;
: letter player name!).&lt;br /&gt;
&lt;br /&gt;
: The $y variable is what allows us to reference the arguments of a prog directly.&lt;br /&gt;
: In general, any place where $yn (where &amp;quot;n&amp;quot; is an integer n &amp;gt;= 1) occurs, the prog &lt;br /&gt;
: interprets this as &amp;quot;the value of the nth word in the prog argument&amp;quot;. As an example, &lt;br /&gt;
: suppose we had the speech_prog:&lt;br /&gt;
&lt;br /&gt;
   speech_prog p I want you to threaten&lt;br /&gt;
   tell $y6 Youâ€™d better watch yourself, $y6!&lt;br /&gt;
&lt;br /&gt;
: Now, if you were to say aloud, in this room: &amp;quot;I want you to threaten Jolinn&amp;quot;, the &lt;br /&gt;
: mob would tell Jolinn: &amp;quot;Youâ€™d better watch yourself, Jolinn!&amp;quot; The reason being: &lt;br /&gt;
: Jolinn is the sixth entry in the argument, and hence it is referenced by $y6.&lt;br /&gt;
&lt;br /&gt;
: By default, $y will strip any punctuation from its argument target. The capital &lt;br /&gt;
: version, $Y will preserve punctuation (this is rarely needed). The argument lookup &lt;br /&gt;
: variable has many more uses, as we will see in later sections.&lt;br /&gt;
&lt;br /&gt;
==Local Variables==&lt;br /&gt;
&lt;br /&gt;
: Local variables, unlike the normal $0-$9 mobvalues, persist only for the duration&lt;br /&gt;
: of the prog in which they&amp;#039;re created.  They can hold numeric or string values. &lt;br /&gt;
: They are prefixed with a % (as opposed to $ for mobvalues) and can be given any&lt;br /&gt;
: alphanumeric name that is not a number.&lt;br /&gt;
&lt;br /&gt;
: They are otherwise used just like mobvalues, and work with:&lt;br /&gt;
 &lt;br /&gt;
:  mpvalueset        mpvaluerand&lt;br /&gt;
:  mpvalueup (*)     mpmath&lt;br /&gt;
:  mpvaluedown (*)   mpgetroomvnum&lt;br /&gt;
&lt;br /&gt;
: and with&lt;br /&gt;
&lt;br /&gt;
: if (mob/obj/room)value&lt;br /&gt;
&lt;br /&gt;
: NOTE!  You no longer (as of June 2003) need to use &amp;quot;mobvalue/objvalue/roomvalue&amp;quot; for&lt;br /&gt;
: any of your if checks.  Just &amp;quot;value&amp;quot; should suffice.&lt;br /&gt;
&lt;br /&gt;
: Here is an example of the local variables in action:&lt;br /&gt;
&lt;br /&gt;
 mpvalueset gstr Hello, I am a local variable.&lt;br /&gt;
 mpecho %gstr&lt;br /&gt;
 mpvaluerand apples 1 3&lt;br /&gt;
 mpecho I have %apples apples.&lt;br /&gt;
 if value(apples) == 3&lt;br /&gt;
   mpecho Wow, that&amp;#039;s a lot of apples!&lt;br /&gt;
 endif&lt;br /&gt;
 mpmath apples %apples * 2&lt;br /&gt;
 mpecho I now have %apples apples.  That&amp;#039;s twice as many as before!&lt;br /&gt;
&lt;br /&gt;
: I&amp;#039;m sure you can figure out what the above would do.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[category:Leviticus]]&lt;/div&gt;</summary>
		<author><name>Elanthe</name></author>
	</entry>
</feed>