<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2180" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff background="">
<DIV><FONT size=2>Par Winzell wrote:<BR>> It's not interpreted in LPC. Merry
is compiled into actual LPC. There<BR>> is no significant speed loss. The
benefits are not so much in the<BR>> language itself but in the fact that it
allows little snippets of<BR>> code to be sent around as data, which is a
natural way for us to hook<BR>> logic onto events.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>The name Merry comes from "Mediated Execution Registry
Involving A Dialect Of C" -- which although somewhat a joke because it is the
successor of Bilbo "Built In Language Between Object", but the acronym that
Merry stands for actually does describe it well.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>The key is the the "mediated" part -- this means that
Merry is somewhat</FONT><FONT size=3> sandboxed -- not to the scale
that Java is, but helpful. For instance, in Merry code we try to ensure
that Merry scripts inside game objects only interact with objects that
involve the virtual game world, not random other objects it has no business
with. Only a limited number of functions can be called from Merry, and even
then they are only allowed implicitly, like fetching/setting properties,
Act(), etc. File system access is completely disabled, as well as things like
</FONT><FONT><FONT color=#000000>starting things up or shutting down processes,
and some communications functions.</FONT><BR><BR>In addition, the langage is run
through a complex parse_string() grammar, which gives us the ability to add some
useful synatactic sugar additions: constants, per-thread global $variables,
$foo: <expr> function-parameters, you can directly access the
property database for values through ${someobject}.property:name, and a few
other useful things like the ability to do inline SAM (Skotos Active Markup)
with $"{oneof:one|two|three}".</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV>Independent of the Merry language itself, there are a large
variety of useful game specific functions, such as EmitTo(), EmitIn(), Set(),
etc.<BR><BR>Here is a small code example. A simple torch, which responds (i.e.
the "react-") to the signal (what might be called an event) named
"react-post:light-dob". This signal is sent to a direct object (i.e. -dob)
immediately after (i.e. -post) a verb is used that might turn on a light in an
object (such as the verbs light, ignite, etc.):</DIV><!--StartFragment --><PRE><FONT color=red>/* Standard Flame Scripts */</FONT>
<FONT color=red>/* react-post:light-dob */</FONT>
<FONT color=red>/* Example by ChristopherA */</FONT>
<FONT color=red>/* If flame-on was set during the reaction, turn trait:flame on */</FONT>
<FONT color=red>/* and let setprop-post:trait:flame handle cleaning things up. */</FONT>
<FONT color=red>/* Note: we do this in react-post so that things look clean */</FONT>
<FONT color=red>/* during normal processing of the react:light-dob signal, */</FONT>
<FONT color=red>/* e.g. you don't get the result "You light the flaming torch." */</FONT>
<FONT color=red>/* when it isn't actually flaming yet. */</FONT></PRE><PRE> <FONT color=purple>if</FONT> ( Get(this,<FONT color=green>"trait:flame-on"</FONT>) ){
Set( this, <FONT color=green>"trait:flame"</FONT>, TRUE);
Set( this, <FONT color=green>"trait:flame-on"</FONT>, FALSE);
<FONT color=red>/* Now show everyone that a flame has appeared. */</FONT>
EmitTo ($actor, <FONT color=green>"The top of "</FONT> + Describe($this, $actor, $actor) + <FONT color=green>" crackles alight.\n"</FONT>);
EmitIn(Get($actor, <FONT color=green>"base:environment"</FONT>), <FONT color=green>"The top of "</FONT> + Describe($this) + <FONT color=green>" crackles alight.\n"</FONT>, $actor);
}
<FONT color=red>/* This is a react-post, so no need to return TRUE; */</FONT></PRE>
<DIV>Note the $actor, $this -- these are per-thread global variables passed to
this script. They will be the same for all the signals that were initially
caused by the first "light my torch" verb.</DIV>
<DIV> </DIV>
<DIV>Next we have a signal that is sent to objects if a property is changed,
called setprop-post. An example of use is when the torch is lit -- either
someone interacted with the torch directly (for instance "light my torch" above)
or something else lit it (put my torch in fireplace) -- either way, the
trait:flame property is set to true and setprop-post:trait:flame is sent to the
object.<BR><!--StartFragment --><PRE><FONT color=red>/* Standard Flame Scripts */</FONT>
<FONT color=red>/* setprop-post:trait:flame */</FONT>
<FONT color=red>/* Example by ChristopherA */</FONT>
<FONT color=purple>if</FONT> ($(hook-property) != <FONT color=green>"trait:flame"</FONT>) <FONT color=purple>return</FONT> TRUE;
<FONT color=red>/* If a flame exists... */</FONT>
<FONT color=purple>if</FONT> ( Get(this,<FONT color=green>"trait:flame"</FONT>) ){
<FONT color=red>/* reveal the flame and change adjectives on the prime detail */</FONT>
Set( this, <FONT color=green>"details:flame:hidden"</FONT>, FALSE);
Set( this, <FONT color=green>"details:smoke:hidden"</FONT>, FALSE);
Set( this, <FONT color=green>"details:default:adjectives:flaming"</FONT>, TRUE);
Set( this, <FONT color=green>"details:default:adjectives:lit"</FONT>, TRUE);
Set( this, <FONT color=green>"details:default:adjectives:unlit"</FONT>, FALSE);
<FONT color=red>/* if the torch has never been flamed before, scorch it. */</FONT>
<FONT color=purple>if</FONT> ( ! (Get(this,<FONT color=green>"trait:flame:remains"</FONT>)) ) {
Set(this, <FONT color=green>"trait:flame:remains"</FONT>, <FONT color=green>"It is slightly scorched."</FONT>);
}
<FONT color=red>/* Now start the timer which will tick ever 90 seconds */</FONT>
Set(this, <FONT color=green>"trait:flame:tick_id"</FONT>, Every(<FONT color=green>"tick"</FONT>, 90));
}
<FONT color=red>/* ... if a flame does not exist, then hide the flame and */</FONT>
<FONT color=red>/* change adjectives on the prime detail. */</FONT>
<FONT color=purple>else</FONT> {
Set( this, <FONT color=green>"details:flame:hidden"</FONT>, TRUE);
Set( this, <FONT color=green>"details:smoke:hidden"</FONT>, TRUE);
Set( this, <FONT color=green>"details:default:adjectives:flaming"</FONT>, FALSE);
Set( this, <FONT color=green>"details:default:adjectives:lit"</FONT>, FALSE);
Set( this, <FONT color=green>"details:default:adjectives:unlit"</FONT>, TRUE);
<FONT color=red>/* Now turn of the timer, so it will not tick. */</FONT>
Stop(Get(this, <FONT color=green>"trait:flame:tick_id"</FONT>));
}
<FONT color=red>/* This is a setprop-post, so no need to return TRUE; */</FONT></PRE></DIV>
<DIV>Finally, we need a way to emit messages periodically as the torch is
burning, and to destroy the torch when it is used up:</DIV>
<DIV> </DIV>
<DIV><!--StartFragment --><FONT color=red>/* Standard Flame
Scripts */</FONT> <BR><FONT color=red>/*
timer:tick
*/</FONT> <BR><FONT color=red>/* Example by ChristopherA */</FONT>
<BR> <BR> <FONT color=red>/* timer:tick is called every X seconds
(typically 60 or */</FONT> <BR> <FONT color=red>/* 90 seconds) as
set up in the Every() function in */</FONT>
<BR> <FONT color=red>/* the setprop-post:trait:flame merry
script.
*/</FONT> <BR> <BR> <FONT color=green>object</FONT> env; <FONT
color=green>object</FONT> act; <FONT color=green>int</FONT> tick; <BR>
<BR> <FONT color=red>/* We've been triggered, so increment our tick
count */</FONT> <BR> tick = Get(this, <FONT
color=green>"trait:flame:tick_cnt"</FONT>) + 1; <BR> Set(this, <FONT
color=green>"trait:flame:tick_cnt"</FONT>, tick); <BR> <BR> <FONT
color=red>/* set some variables because timer:tick exists in
an */</FONT> <BR> <FONT color=red>/* an
environment where there are very few arguments */</FONT>
<BR> <FONT color=red>/* and you can't rely on where the item. It
could be */</FONT> <BR> <FONT color=red>/*
on the floor, in someones bag in the nil, or
in */</FONT> <BR> <FONT
color=red>/* the hands of the person who lit
it.
*/</FONT> <BR> <BR> <FONT color=red>/* If we are being held, we want
our environment output */</FONT> <BR> <FONT color=red>/* to be
in the room of the person who is holding us.
*/</FONT></DIV><FONT color=#ff0000></FONT>
<DIV><BR> <FONT color=purple>if</FONT> (env = Get(this, <FONT
color=green>"base:environment"</FONT>)) { <BR> env = Get(env,
<FONT color=green>"base:environment"</FONT>); <BR> } <BR>
<BR> <FONT color=red>/* If we are being held, we want our actor
output */</FONT> <BR>
<FONT color=red>/* to be the person holding us, or the room if the item
*/</FONT> <BR> <FONT color=red>/* has been
dropped.
*/</FONT></DIV>
<DIV><FONT color=#ff0000></FONT><BR> act = this.<FONT
color=green>"base:environment"</FONT>; <BR> <FONT
color=purple>if</FONT> (act.<FONT color=green>"base:environment"</FONT>) {
<BR> <FONT color=red>/* actor has an environment,
all is well */</FONT> <BR> env = act.<FONT
color=green>"base:environment"</FONT>; <BR> } <FONT
color=purple>else</FONT> { <BR> <FONT color=red>/*
if act has no environment, we've been dropped and act = env! */</FONT>
<BR> env = act; <BR>
act = <FONT color=purple>nil</FONT>; <BR> } <BR> <BR>
<FONT color=red>/* For each tick, do different
things...
*/</FONT> <BR> <BR> <FONT color=red>/* ...partially burn out the
item
*/</FONT> <BR> <FONT color=purple>if</FONT> (tick == 5) {
<BR> Set(this, <FONT
color=green>"trait:flame:remains"</FONT>, <FONT color=green>"It is about half
burned out"</FONT>); <BR> } <BR> <FONT color=red>/*
...mostly burn out the
item
*/</FONT> <BR> <FONT color=purple>if</FONT> (tick == 10) {
<BR> Set(this, <FONT
color=green>"trait:flame:remains"</FONT>, <FONT color=green>"It is almost burned
out."</FONT>); <BR> } <BR> <FONT color=red>/*
...complete burn out the
item
*/</FONT> <BR> <FONT color=purple>if</FONT> (tick >= 12) {
<BR> <FONT color=purple>if</FONT> ( act != <FONT
color=purple>nil</FONT> ) {
<BR> EmitTo(act,
Describe(this, <FONT color=purple>nil</FONT>, act) + <FONT color=green>"
sputters out.\n"</FONT>); <BR> }
<BR> <FONT color=purple>if</FONT>(this.<FONT
color=green>"base:environment"</FONT>) {
<BR> EmitIn(env, Describe(this,
<FONT color=purple>nil</FONT>, <FONT color=purple>nil</FONT>) + <FONT
color=green>" sputters out.\n"</FONT>, act); <BR>
} <BR> Set(this, <FONT
color=green>"trait:flame"</FONT>, FALSE); <BR>
Set(this, <FONT color=green>"trait:flame:flammable"</FONT>, FALSE);
<BR> Set(this, <FONT
color=green>"trait:flame:remains"</FONT>, <FONT color=green>"It is completely
burned out."</FONT>); <BR> Set( this, <FONT
color=green>"details:default:adjectives:spent"</FONT>, TRUE);
<BR> <FONT color=red>/* stop us from ticking
anymore
*/</FONT> <BR> Stop(Get(this, <FONT
color=green>"trait:flame:tick_id"</FONT>)); <BR>
<BR> <FONT color=red>/* Now return false, but set
up a delay so that */</FONT>
<BR> <FONT color=red>/* this object can decay in
86400 seconds (1 day) */</FONT>
<BR> $delay(86400, FALSE, <FONT
color=green>"4a8d"</FONT>); <BR> <BR> <FONT
color=red>/* We have to re-establish our local variables, as
*/</FONT> <BR> <FONT color=red>/* they are
incorrect after a
delay.
*/</FONT> <BR> Set(this, <FONT
color=green>"trait:flame:tick_cnt"</FONT>, tick);
<BR> <FONT color=purple>if</FONT> (env = Get(this,
<FONT color=green>"base:environment"</FONT>)) { <BR> env =
Get(env, <FONT color=green>"base:environment"</FONT>);
<BR> } <BR> act =
this.<FONT color=green>"base:environment"</FONT>;
<BR> <FONT color=purple>if</FONT> (act.<FONT
color=green>"base:environment"</FONT>) {
<BR> env = act.<FONT
color=green>"base:environment"</FONT>; <BR> }
<FONT color=purple>else</FONT> {
<BR> env = act;
<BR> act = <FONT
color=purple>nil</FONT>; <BR> } <BR>
<BR> <FONT color=red>/* If we are not in the nil,
then tell people that */</FONT>
<BR> <FONT color=red>/* we are
disintegrating...
*/</FONT> <BR> <FONT color=purple>if</FONT> ( act
!= <FONT color=purple>nil</FONT> ) {
<BR> EmitTo(act, Describe(this, <FONT
color=purple>nil</FONT>, act) + <FONT color=green>" disintegrates from
age.\n"</FONT>); <BR> }
<BR> <FONT color=purple>if</FONT> (this.<FONT
color=green>"base:environment"</FONT>) {
<BR> EmitIn(env, Describe(this,
<FONT color=purple>nil</FONT>, <FONT color=purple>nil</FONT>) + <FONT
color=green>" disintegrates from age.\n"</FONT>, act);
<BR> } <BR> <FONT color=red>/* Ok, we
are done.
Bye.
*/</FONT> <BR> Slay(this);
<BR> <FONT color=purple>return</FONT> FALSE;
<BR> } <BR> <BR> <FONT color=red>/* For every tick,
there is a 30% chance of a random emit*/</FONT> <BR> <FONT
color=purple>switch</FONT>(<FONT color=purple>random</FONT>(10)) {
<BR> <FONT color=red>/* Again, if we are not in
the nil, do the emits */</FONT>
<BR> <FONT color=purple>case</FONT> 0: {
<BR> <FONT
color=purple>if</FONT> ( act != <FONT color=purple>nil</FONT> ) {
<BR>
EmitTo(act, <FONT color=green>"A trail of smoke wisps upwards through the air
from "</FONT> + Describe(this, <FONT color=purple>nil</FONT>, act) + <FONT
color=green>".\n"</FONT>);
<BR> }
<BR> <FONT
color=purple>if</FONT>(this.<FONT color=green>"base:environment"</FONT>) {
<BR>
EmitIn(env, <FONT color=green>"A trail of smoke wisps upwards through the air
from "</FONT> + Describe(this, <FONT color=purple>nil</FONT>, <FONT
color=purple>nil</FONT>) + <FONT color=green>".\n"</FONT>, act);
<BR> }
<BR> } <FONT color=purple>break</FONT>; <BR>
<FONT color=purple>case</FONT> 1: {
<BR> <FONT
color=purple>if</FONT>(this.<FONT color=green>"base:environment"</FONT>) {
<BR>
EmitTo(act, <FONT color=green>"There is a quiet fizzle of hot oil from "</FONT>
+ Describe(this, <FONT color=purple>nil</FONT>, act) + <FONT
color=green>".\n"</FONT>);
<BR> }
<BR> <FONT
color=purple>if</FONT>(this.<FONT color=green>"base:environment"</FONT>) {
<BR>
EmitIn(env, <FONT color=green>"There is a quiet fizzle of hot oil from "</FONT>
+ Describe(this, <FONT color=purple>nil</FONT>, <FONT color=purple>nil</FONT>) +
<FONT color=green>".\n"</FONT>, act);
<BR> }
<BR> } <FONT color=purple>break</FONT>; <BR>
<FONT color=purple>case</FONT> 2: {
<BR> <FONT
color=purple>if</FONT>(this.<FONT color=green>"base:environment"</FONT>) {
<BR>
EmitTo(act, capitalize(Describe(this, <FONT color=purple>nil</FONT>, act) +
<FONT color=green>" flickers.\n"</FONT>));
<BR> }
<BR> <FONT
color=purple>if</FONT>(this.<FONT color=green>"base:environment"</FONT>) {
<BR>
EmitIn(env, capitalize(Describe(this, <FONT color=purple>nil</FONT>, <FONT
color=purple>nil</FONT>) + <FONT color=green>" flickers.\n"</FONT>), act);
<BR> }
<BR> } <FONT color=purple>break</FONT>;<BR>
<FONT color=purple>default</FONT>: <FONT
color=purple>break</FONT>;<BR> }</DIV>
<DIV> </DIV>
<DIV><FONT size=2>The above is only three of about 8 different Merry
scripts used by torches.</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT size=2>-- Christopher Allen</FONT></DIV>
<DIV><FONT size=2></FONT> </DIV>
<DIV><FONT
size=2>------------------------------------------------------------------------<BR>..
Christopher Allen <<A
href="mailto:ChristopherA@skotos.net">ChristopherA@skotos.net</A>>
Skotos Tech Inc.
..<BR>..
2342 Shattuck Ave Ste #512, Berkeley, CA 94704-1517 ..<BR>.. <A
href="http://www.skotos.net">www.skotos.net</A> <A
href="http://www.rpg.net">www.rpg.net</A>
o510/647-2760 f510/849-1717 ..<BR></FONT></DIV>
<DIV> </DIV></BODY></HTML>