Vote for MiT on TMC!


Add us on Google+
Please select by the first letter of the name or type in your search below:

- A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z -
Other


.:.


Mob programs allow the use of 'if-else' statements to allow performing different
actions based on whatever criteria you want.  The possible keywords are:

if [not]
and [not]
or [not]
   <block of code goes here>
endif

Mob programs also allow for a basic kind of loop, which iterates through each
player in the room.  The keyword to start this loop is the word 'for', and the
word to terminate the loop is 'loop'.  Example:

for
   nod $n
   say How do you do, $N?
loop

The above example would nod to each player in the room, and then ask them how
they are doing.

If statement examples:

To greet an Aiel differently than a Seafolk, you could do:

if clan $n AL
   say Greetings, my Aiel friend!
   giggle
endif
if clan $n SF
   say Greetings, Seafolk!
   salute
endif

The above example shows a very simple set of independent logical events.  If you
don't want the mob to greet someone twice if they happened to be in both the
Aiel and Seafolk guilds, you could do a dependent type if-else:

if clan $n AL
   say Greetings, my Aiel friend!
   giggle
elseif clan $n SF
   say Greetings, Seafolk!
   salute
endif

Notice the 'elseif' statement?  This is different from doing an 'else' and 'if'
in separate lines.  If you had else and if on separate lines like so:

if clan $n AL
   say Greetings, my Aiel friend!
   giggle
else
   if clan $n SF
      say Greetings, Seafolk!
      salute
   endif
endif

This requires multiple 'levels' of if statements.  In both cases the first if
must be false before the second if can execute (and so on if there are more
nested statements.)  If someone is both Aiel and Seafolk, they will
only be greeted as an Aiel.  However, using 'elseif' as one statement rather
than breaking it into separate statements prevents you from having to nest
multiple levels of if statements, you could do as many checks as you wanted
without having to keep nesting them further.

Now lets say you wanted to have a special case for someone who is both aiel and
seafolk:

if clan $n AL
and clan $n SF
   say Well aren't you unique?  We don't see many Aiel/Seafolk around here.
   chuckle
else
   if clan $n AL
      say Greetings, my Aiel friend!
      giggle
   endif      # Notice the use of endif here instead of else.  See below
   if clan $n SF
      say Greetings, Seafolk!
      salute
   endif
endif

You may notice that the nested if statement in the previous example contained
two independent if statements.  We could have used an 'else' statement and made
it dependent, however in this particular case it was unnecessary because we
know that the character can not be both Aiel and Seafolk, because if they were,
they would have matched the first if-statement (The one which contains the 'and'
condition).

You can also use the 'not' keyword to negate the matching.  For example:

if not clan $n AL
and not clan $n SF
   say You are not a member of either the SF or AL guild.
   shake
endif

The above example would only execute if they were -not- in the aiel guild,
-and- they were not in the seafolk guild.

New feature added July 10th:  You may now specify another function as the
right hand operand to an if-check.  For instance, to see if a drink container
is full, you could do:

if objval1 $o >= objval0 $o

On a drink container, objval0 stores the 'max' units of liquid a container may
hold.  objval1 stores how many units currently occupy that container.  The
above if-check checks to see if the number of units in the container is equal
(or greater) than the max allowed.  (Note:  Technically we should be able to
use == instead of >=, but it's safer to use >= in case an unforeseen bug allows
a container to be filled beyond it's limit.  For example, a container filled to
6 units with a -max- of 5 would show up as 'not full' if you used ==, where as
>= would catch this anomaly)

You don't have to specify the same function on each side either, you could also
do:

if ercount $n > trcount $n

This would tell you if the number of emotes in the room for player $n is
greater than the number of ticks spent in the room for the same player $n.

Another example:

if ercount $n > ercount $q

This would compare the number of emotes in the current room between player $n
and player $q.

See also:  MPEDIT, MOB FUNCTIONS, MOB COMMANDS, MOB TRIGGERS, MOB ACT CODES,
           MPROGADD, MOB PROGRAMS


:: Beginning

 
 Copyright © 2003 A Moment in Tyme
 Web Design by: Tannil and Guy
.:. Top of Page