[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Scripting in games.




I don't have a lot of experience with making scripting systems for games...but
I want to learn - and I learn best by doing.

OK - so I've added a lightweight C-like scripting language to my 3D game engine
and it lets you run hundreds of tiny little interpreted C programs in parallel
without consuming too much CPU time.  (You can download it as a part of my PLIB
library suite - but you'll need to get it from CVS since it's not released yet
- the language is called 'PSL').

So now (in principle) I can write behaviors for all sorts of animate and
inanimate objects using *LOTS* of little scripts.  Woohoo!

Clearly there needs to be some set of procedures in the scripting language
that can make things happen in the game world - and functions to query
things from inside the game so that the script can react to events in the game.

My scripting language provides ways for the host application (the game) to expose
functions written in C++ so that the scripts can call them. But what functions
are needed in order to be able to write good scripts?

I can imagine what *some* of those functions might be - but since I don't have
much experience here, I'm not quite sure what set of functions would be useful
to the script writer - or at what level of sophistication they should usefully
operate.

* I could provide (for example) a function to position an object that 'belongs'
   to the script at a specified X,Y,Z,Heading,Pitch,Roll - but should I instead
   make the interface be Velocity+Direction and let the game do the integration
   down to positions - or perhaps the interface should just be a place to head
   towards and a choice of several 'modes' of getting there?

* How should the game handle collision detection for scripted objects?   Does
   the script make collision detection queries and do the business of stopping
   the motion when it hits something - or should the game engine deal with the
   consequences of a collision and just inform the script what happened?

* How does the scripting interface deal with telling the script the position
   of the player and other creatures?

* Should scripts be able to communicate with each other?

There seems to be a difficult balance between:

   1) Making the scripts easy to write - and relatively error-free (in terms
      of critters not walking though walls because the script forgot to do
      something).

   2) Giving the script the power it might need to achieve some kind of an
      effect that I didn't think of - thereby limiting the creativity of the
      script writers\.

How do existing games deal with this stuff?   Is there a 'classic' game
somewhere with a scripting interface that's known for having "Got It Right" ?
If so, where do I go to find out how it works?

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
        http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
        http://prettypoly.sf.net http://freeglut.sf.net
        http://toobular.sf.net   http://lodestone.sf.net