The scripting language that Shakti and I devised is completely message-based. Variables are handled through specific functions which operate on variables or variable slot's - AKA elements in an array.
Messages are then sent to the target object ID's ScriptProc function. The message is then handled (or not handled) by the object. The engine also has a ScriptProc function where it can respond to specific messages as well.
The goal was to make the game completely controllable and modifiable from the script. It also supports user commands through set macros we've come up with. Overall it's very powerful but definitely not up to par with a major scripting language.
Script->Script processor->Object->Action
Script->Script processor->Engine->Action
Script->Script processor->GUI->Action
There are a few more details involved in order to get everyone working on the same page but overall it's quite simple.
Everyone one of our script commands utilizes this structure:
Code:
struct ScriptFunc
{
DWORD dwMessage;
DWORD dwParam1;
DWORD dwParam2;
DWORD dwParam3;
}
- dwMessage is the message ID
- dwParam1 is the first param, usually the object being acted on
- dwParam2 is the second param, usually the target object of the command (IE: aIDAttack (1,2) - object 1 attacks object 2
- dwParam3 is the third param and it is rarely, if ever, used in our system. When used it usually acts as a modifier for the messageID. Say you wanted object 1 to move to object 2 at a speed of 4: aIDMoveToAtSpd(1,2,4)
A simple script to make object 1 attack object 2 until it is dead.
Code:
//Check if object 2 is dead, if true, set variable 1 to 1
if (aIDIsDead(2))
aVarSET(1,1)
endif
//If variable 1 is 0, we know object 2 is still alive so attack it
if (aVarEQ(1,0))
//1 out of 100 times we will attack with special move 5
if (Random(100))
aIDAttackWithMove(1,2,5)
else
aIDAttack(1,2)
endif
endif
There several ways to accomplish this in our script but I showed what I think is the easiest.
User commands are added like this:
Code:
USER_COMMAND3 "uAttackObjectWith"
//Param1 - object
//Param2 - target
//Param3 - weapon
//Check if object doing action is alive, if target is alive, and
//if action object even has the weapon
if (aIDIsAlive(PARAM1) AND aIDIsAlive(PARAM2) AND
aIDHasWeapon(PARAM1,PARAM3))
aIDAttackUsing(PARAM2,PARAM3))
endif
END_USER_COMMAND3
//Object 1 attack object 2 with weapon 20
if (Random(500))
uAttackObjectWith(1,2,20)
endif
Params are determined by how the user passes them to the function. We cannot test to see whether the user is using their command correctly, but we can provide a mechanism so they can build up complicated commands and then execute them with one line of script. The number following the macros is an indicator the script how many params it requires. All standard script commands start with "a" and all user commands start with "u"
Interesting to see how you approached your script. I'd like to see some samples of it.