[MUD-Dev] (fwd) [DESIGN] Macro semi-language
J C Lawrence
claw at under.engr.sgi.com
Mon Apr 27 11:10:09 CEST 1998
From: Richard Woolcock <KaVir at dial.pipex.comNOSPAM>
Newsgroups: rec.games.mud.diku,rec.games.mud.admin,alt.mud.programming
Subject: [DESIGN] Macro semi-language
Date: Sat, 25 Apr 1998 04:22:00 -0700
Recently I was asked by a friend and fellow implementor if I could show
her how to code on the mud. She had used pascal before, but never used
C, and didn't really seem to have any grasp of the language. In order to
try and help her, on wednesday I threw together a set of macros to create
a sort of pseudo-language. I added a few more features on thursday, and
today got the chance to show her how it worked. Although she is still
having problems, she is finding this macro-based system far easier to use,
and I have started wondering if it might help a few other coder wannabe's.
Note that this system is designed for Merc, but could be easily adepted
to most other hard-coded systems.
The advantages and disadvantages as I see it are as follows:
* ADVANTAGES: More verbose and robust than direct C coding, as well
as requiring less actual code to be written. Compiles down almost
as efficiently as pure C, and can be mixed and matched.
* DISADVANTAGES: Excessive macros resulting in poor type checking,
severe limitations on what you can do, and doesn't really help
teach the user C. The hope is that as the user requires more and
more from the code, they will slowly begin to teach themselves,
rather being dropped in at the deep end and not knowing how to do
anything.
Any comments are welcome. Two examples of code follow.
KaVir.
-----
DO_FUNCTION(KICK)
/*********************************************************************
----------------------------------------------------------------------
Function : do_KICK
Author : KaVir
Date : 25th April 1998
----------------------------------------------------------------------
Description : Takes in a person as the first parameter. If no first
parameter is entered, then the player will attempt to
kick the person they are fighting, if any.
----------------------------------------------------------------------
*********************************************************************/
VARIABLES
NONE;
PARAMETERS
VICTIM_IN_ROOM(FIRST_PARAMETER);
BEGIN
IF EMPTY_PARAMETER(FIRST_PARAMETER)
THEN
IF PERSON_ME_FIGHTING IS FALSE
THEN
TEXT_TO_ME("Who do you want to kick?");
EXIT;
ELSE
SET VICTIM TO PERSON_ME_FIGHTING;
ENDIF
ENDIF
IF VICTIM_EXIST IS FALSE OR ME_SEE_VICTIM IS FALSE
THEN
TEXT_TO_ME("They are not here.");
EXIT;
ELSIF IS_SAFE IS FALSE
THEN
SET DAMAGE TO RANDOM_NUMBER(1,4) + ME_DAMROLL;
ME_HIT_VICTIM(KICK);
WAIT_STATE(ME,4);
ENDIF
END FUNCTION
DO_FUNCTION(TRANSPORT)
/*********************************************************************
----------------------------------------------------------------------
Function : do_TRANSPORT
Author : KaVir
Date : 25th April 1998
----------------------------------------------------------------------
Description : Takes in an object as the first parameter and a person
as the second parameter. The object is then transported
to the person.
----------------------------------------------------------------------
*********************************************************************/
VARIABLES
NONE;
PARAMETERS
OBJECT_IN_ROOM(FIRST_PARAMETER);
VICTIM_IN_WORLD(SECOND_PARAMETER);
BEGIN
IF EMPTY_PARAMETER(FIRST_PARAMETER) OR EMPTY_PARAMETER(SECOND_PARAMETER)
THEN
TEXT_TO_ME("Transport what object to whom?");
EXIT;
ENDIF
IF ME_SEE_OBJECT IS FALSE
THEN
TEXT_TO_ME("You cannot see that object.");
EXIT;
ENDIF
IF ME_CARRY_OBJECT IS FALSE
THEN
ACT_TO_ME_OBJ("You are not carrying $p.");
EXIT;
ENDIF
IF ME_SEE_VICTIM IS FALSE
THEN
TEXT_TO_ME("You cannot see that person.");
EXIT;
ENDIF
IF VICTIM_ROOM IS ME_ROOM
THEN
TEXT_TO_ME("They are already here!");
EXIT;
ENDIF
ACT_TO_ME_OBJ("$p vanishes from your hands in a swirl of smoke!");
ACT_TO_ROOM_OBJ("$p vanishes from $n's hands in a swirl of smoke!");
ACT_TO_VICTIM_OBJ("$p appears in your hands in a swirl of smoke!");
FULL_ACT_TO_ROOM(VICTIM,OBJECT,NONE,"$p appears in $n's hands!");
OBJECT_TO_VICTIM;
END FUNCTION
--
J C Lawrence Internet: claw at null.net
(Contractor) Internet: coder at ibm.net
---------(*) Internet: claw at under.engr.sgi.com
...Honourary Member of Clan McFud -- Teamer's Avenging Monolith...
--
MUD-Dev: Advancing an unrealised future.
More information about the mud-dev-archive
mailing list