[MUD-Dev] PirateMUD and CSL

Chris Gray cg at ami-cg.GraySage.Edmonton.AB.CA
Tue Aug 5 19:12:02 CEST 1997


[Niklas E:]
:Greetings everyone,

Greetings!

:	 <room>
:	 .. (room data)
:	 <csl>
:	 <leave>
:	 if (is_env("north")) then {
:		 if (has_item("fraznium gloves") {
:			 tell_room("The portal glows as @the(i) enter at ve(i).")
:			 okay()
:		 }
:		 else {
:			 tell_room("The portal prevents @the(i) from entering."
:			 fail()
:		 }
:	 }
:	 </leave>
:	 </csl>
:	 </room>
:
:This worked tremendously well, and has allowed us to write some very nice
:puzzles and quests. However, there is one little problem with this approach:
:Since the MUD engine gets confirmation of an event from the CSL function,
:things may happen in the wrong order.

Been there. Noticed the problem. Don't really have a solution. :-)

However, what I did was to make up a datatype that is 3-valued, and have
many such routines return that type. I call the type "status", and it
is built into the language just like "int", "bool", etc. The three values
it has, and their common meanings are:

    success - the activity has completed successfully
    failure - the activity has failed
    continue - continue with the activity

In your example, the writer of the CSL could choose whether or not to
return 'success', having done everything related to the event, or return
'continue', indicating that the default activities should happen. Returning
'continue' doesn't mean that nothing special has been done, however.
Naturally, I then ran into cases where 3 values weren't enough, so I
fudged it. You could just return an integer, and predefine some values.

(I do note that your CSL doesn't actually return anything, but you could
replace the okay()/fail() calls with a status() call which takes an
integer argument.)

--
Chris Gray   cg at ami-cg.GraySage.Edmonton.AB.CA



More information about the mud-dev-archive mailing list