NiM5 Scripting Language

Post new topic   Reply to topic Forum Index -> Coding
View previous topic :: View next topic  
Author Message

Joined: 05 Feb 2006
Posts: 4
Location: Pittsburgh, PA

PostPosted: Mon Feb 06, 2006 2:12 pm    Post subject: NiM5 Scripting Language Reply with quote

Hi all,

NiM5 comes with a script interpreter. A major bug was fixed in the script interpreter which causes memory leaks on servers running versions of the code before 2004. There are two noticable engineering questions left with the current interpreter:

1) The design of the language

The language could use the following structural improvements:

a) switch() statement (minor addition, with some functional limitations)
currently, switch() statements would be limited by max # of params
for a function, which I believe is 6, so 5 cases
b) trigger: clause
for automatic %astr% comparisons with strings for commands,
the easiest implementation would look something like this:


or this say trigger:

c) less-strict literals {,}
d) loose-functioning goto() statements
there are some odd restrictions using goto() and if()
e) intelligent object-manipulation and referencing features
me.variable, which includes object-structure links
so that settimer(1) would appear as %me.timer%=1;
(or appears as self.variable)

2) Precompilation of scripts

It would drastically improve performance if the scripts were precompiled in some way. Currently, no pre-compilation occurs but could occur to increase performance of the server. 4000+ scripts running at the same time can yield some performance lag. Scripts do not have even performance: most function at a single level, but lengthening the wait() state is a great way to improve performance when running multiple
scripts. Aside from extreme scripts (examples below) most solutions are not performance heavy.

Examples of "Extreme Scripts"

Aggression-like scripts
Scripts that generate a lot of new memory quickly without
destroying it (producers/dispensers)

There are over 200 functions in the current implementation. Functions can be implemented with simple code hooks, and the language itself
could be easily ported to other software such as Envy, Smaug, Diku,
Merc or ROM.

See reply to this thread for a "master" function list.


Back to top
View user's profile Send private message Visit poster's website
Author Message

Joined: 11 May 2005
Posts: 152
Location: Florida

PostPosted: Tue Feb 07, 2006 1:05 pm    Post subject: Reply with quote

If you want to talk about your scripting language, how about some information on the actual grammar, semantics, implementation design, etc? There's really no point in spamming the forum with a bunch of function prototypes. It doesn't tell anyone anything.
Back to top
View user's profile Send private message Visit poster's website
Author Message

Joined: 05 Feb 2006
Posts: 4
Location: Pittsburgh, PA

PostPosted: Thu Feb 09, 2006 1:21 am    Post subject: NiM5 Scripts Syntax Reply with quote

How to Bend Space

or : Using and Coding For The Script Interpreter



Scripts can be added to your favorite MUD software; all you have to do is copy the structures and functions from NiMUD's MUD.H

The files relevant to the scripting language are:


These files are the core of the routines for the language.

You will also need to add a new vnum hash table and copy appropriate commands for editing scripts from the oc.c and wiz_info.c files.

You may want to take a glance through the source code and find the calls for script_update(), which occur in various places throughout the source code.

It is these calls which tie the language into the mud parser.

You will also have to extract the saving and loading routines from the db.c


Making Scripts Simply

You can easily add new scripts to your existing mobiles with simple functionality. Set the trigger on the script to one of the appropriate
forms, then add statements such as :

do("this command");

This could keep you busy for hours, making what I refer to as the "headache" mobs, or the scripts that cause mobs to act, say or do

This is also useful for simulating spec_funs, or, rather, special functions that enable mobiles to perform extended combat commands,
queue events or assist particular mobiles (creating MUD politics).

Commands like these take advantage of MUD features like assist and track to carry out commands. Certain functions can allow a loop to occur within the script such as this:

do("this command");
if ( expression,
} );

This code, a function of NiMScripts, demonstrates two important syntactic features and one very important interpretive constraint.

Otherwise, the other features demonstrated are looping with goto() and label() as well as if-clause

IMPORTANT NOTE: YOU MUST USE BRACES to delineate a section of code is imperative and should be used whenever seperating code blocks.


You can use Brackets [ and ] in place of braces, if you don't want to think about how much your braces hurt. This is fine, just don't mix braces and brackets-- this is like crossing the streams in Ghostbusters -- a definite no-no.

If you do, expect unpredictable results..


do([say hello]);
if ( expression,
] );

Scripts Versus The World File
Tricks and Tips

Use duplicate mobs to fake changes.. use duplicate areas to fake major changes -- create group adventures with the use of moveall() --

Take a close look at the scripts in the area files and how they are arranged. The scripts are like books on a shelf -- or dominos -- each script or set of scripts functions together as a single unit. You may want to cut and paste from an external editor when making these things, and watch for the upward spam limit -- I've lost work this way.

To make a ferryman, for instance, you may need several dummy rooms. Start thinking of the MUD as a whole unit of manipulated databases -- create the workings behind the black curtain, for now you truly are
an empowered wizard.


Scripts can be used to make spells. Either using the event queue or incorperating scripts into your magick system. In its raw form, NiMUD produces a spell system that manipulates two spectrums of spells -- mixed reagent magic and mana-based spell craft with a combination of both player mana and object-based mana (gems).

The mix() and reagents() functions provide an overview of the inner workings of this system, and offer a great start for folks wanting to use
this system.

do_oload has been modified to produce components, so you can test the system.

It's taking a while to make this, I know, but I just haven't had the energy I had in the past.

Event queues

You can now add scripts to the event queue, tied to the "owner" of the event. This is useful for spellcasting and "triggering" other scripts
using the event() function.

See events.c

Script Awards 2003

Included in the area files are a series of scripts, to give you an idea of what "works" (since many aren't functioning properly) I've included this listing. I wrote all of these. User submissions welcome.

Working nimscripts:

- 2x examples
- bounty when killed
King and Magistrate
- crier
- reward
Tiktuan War
- berserker
- giant special attack

Words Scripts (that cause harm):

- this script causes lag, memory errors and dangerous liasons with infinity (nimscripts have a depth limit)

Best quest/infocom-like example:

- death scripts
- an enclosed "experience" (ends prematurely, though after you are incarcerated for war crimes)
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Forum Index -> Coding All times are GMT
Page 1 of 1

Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2001, 2002 phpBB Group
BBTech Template by © 2003-04 MDesign