Creating Scripts

Started by
3 comments, last by 5MinuteGaming 19 years, 8 months ago
I am creating a script for a Java based MUD Engine and I was wondering how I should structure the scripts that would enable me to make the most of them. I was thinking about creating a similar type of language to C/C++, &#106avascript, Java, and Visual Basic. Although only in syntax. I would have the following types of statments: -Logical (which would be evaluated to boolean values) -Assignment (which would create and store variables) -Loop (such as for and while loops) Does anyone have any suggestions? My engine currently has only a few built in command statements and I'm using the Composite Pattern to allow for sets of commands to be created from a script file. I am using a Builder Pattern to parse the script and create the Compsite Command.
Advertisement
Take a look at UnrealScript docs. It's similar to Java lang. and has built in features like states, etc. that relate to gaming logic. Google it or goto epicgames website for more info.
If you make something like unrealscript, make sure to fill in lots of gaps. For example, inside a state you can call the global version of a function or the super version of a function but you can't say "call the global version if this class has one or the super version if not".

It also lacks multiple inheritence, templates (or 'variant' type objects), etc that can make coding in it not only a real pain but also extremely inefficient.

The so-called 'automatic memory management' is extremely lacking in unrealscript as well, so it'd be good to do something new in that direction. Having circular references (or even just linear chains of references with the wrong types in the middle) or the like just about always crashes UT(even up to UT2004) on level change/exit/etc.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
Will the script be running the entire game, or will you have your game call the script at given event intervals? In other words, will the game essentially be a script loader which takes a main.script and calls main() on it, which in turn loads and handles the game logic within script.... or will the majority of the game core run in Java, calling the script at given event intevals (eg: level_update() called once per turn)? I think the type of approach you take to using the script will have a huge impact on how you design and structure your language.
Well the script will not be running the entire game and all the commands created by the script will be loaded on initialization of the server. The majority of the script will be for creating the entire world. The engine will simply hold all the information for every object and room in the MUD World and the commands will actually make everything interact. The World object right now executes every objects commands if it has any every given interval.

The way the commands are structured is that there are a few basic commands (i.e. Add [Object(.Property)], Remove [Object(.Property)], Set [Object(.Property)] ... ) Those commands are the only thing stored in memory after the commands are loaded. The script language that I will create simply tells the CommandBuilder object which command (Add,Remove,Set) and what variables to create the command with. For instance:

Creation Script: world.script
Object MorgulPass(10,10,1)
MorgulPass.type = "Room"
MorgulPass.items = {"Sting" "Orcist" "Glamdring"}

Command Script: moveNorth.script
parent.y += 1

The parent object would be the command object itself which would tell you what room, weapon, person, or material executed it. The '{' and '}' is indicating that each individual item should be parsed into a List whose elements are seperated by a space. (All of the syntax are subject to change.)

And then these files would be loaded by the WorldBuilder and the CommandBuilder at the beginning of the server or at runtime.

My question is how should the language be structured such as the above. Which are just examples of possible script files. I was wondering how strongly typed would you make it or how generic. What commands statments should I have? I want to keep the commands very basic such as adding objects, adding properties to those objects, and with the script files I want to be able to change the logic such as what happens when you pick up a sword or shoot a bow. I was wondering if anyone could think of possible commands for a MUD command script structure in this way.

This topic is closed to new replies.

Advertisement