Galaxia, Games, MPOGs, PHP

User scripting in Galaxia Reborn

<![CDATA[Something I've wanted to put into Galaxia for a long time is user scripting. i.e. allowing users to attach scripts to objects that are triggered by certain events. Ultimately this could lead to interesting computer players (but that's a long way off).

Well I've been playing around with it a little and the easiest complex data to parse seems to be XML. So the scripting engine will be XML based. The following is how a script will (hopefully) look:

<onFleetEnterSector>
  <IsEnemy target="$fleet">
    <ExectureOrder order="attack" target="$fleet" />
  </IsEnemy>
</onFleetEnterSector>

Just in case you can’t tell what it does, when a fleet enters the same sector as your own it checks to see if is an enemy and if is, attacks it.

Firstly a bunch of variables the script can read are passed to it. After that all the processing works using callbacks. When each tag is encountered, it just calls some specified function with the attributes passed as arguments (probably as an associative array to easily handle a variable number). If it’s a conditional (like “IsEnemy”) the function must return true or false. If it’s an action (like “ExecuteOrder”) then it returns nothing. There is also another type – one that returns an arbitrary value (i.e. a function – but I’ve used the word function too much already).

I’ll put the code up once it’s tested a bit more.]]>

Advertisements

One thought on “User scripting in Galaxia Reborn

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s