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

Re: Scripting



Quoting Jorrit Tyberghein <Jorrit.Tyberghein@uz.kuleuven.ac.be>:

> Steve Baker wrote:
> 
> > If (for example) you want a script for a critter in your game, you'd
> > probably want to write things (in scripting language) like:
> >
> >    while ( true )
> >    {
> >      walk_forwards ( 10 seconds )
> >      if ( player within 10 meters )
> >        turn_right ( 60 degrees )
> >      else
> >        turn_left ( 60 degrees )
> >    }
> >
> > ...then have 50 copies of this script running for your 50 monsters.
> 
> This is not the approach that I would follow. The 'while' loop should
> not
> be done in the script but in the main game driver. So the Python
> script
> only does the part within the 'while' and this script is fired
> regularly
> by the game engine. If you do it like you suggest above you are going
> to need as many threads as you have creatures and that's rather
> heavy I think. Or else you are going to have do implement threading
> on your own (i.e. by multiplexing instructions like you suggest) which
> means you cannot use any standard scripting language which is
> a big disadvantage IMHO.

If you can support actions in scripting systems that take >1 frame to execute, 
you can very easily script game events.

Suddenly, game animations turn into simple scripts:

  with actor Fred
    walk forwards 10m 10s
    say "Hi, I'm Fred."
    with actor Fred's arm
      point at Joe
    say "This is Joe, my sidekick."

You can't do all this in a single frame loop (easily).

You can also time things:

  sleep 600s
  check ( target1.isDestroyed && target2.isDestroyed )
    gosub wingame
  else
    gosub timeout

Again, without instructions that can span frames, this cannot be a simple 
script that's part of the game world.

> 
> > The alternative is to require each script to process exactly one
> > frame of decision-making and then return.  That's a fairly
> > unnatural way of working - you have to think in terms of
> state-machines.
> 
> I don't think that's an unnatural way of working. Personally I think
> it is more natural even.
> 
> Greetings,
> 
> --
> ==============================================================================
> Jorrit.Tyberghein@uz.kuleuven.ac.be, University Hospitals KU Leuven
> BELGIUM
> 
> Nanny Ogg quite liked cooking, provided there were other people around
> to
> do things like chop up the vegetables and wash the dishes afterwards.
>         -- Home Pragmatics
>            (Terry Pratchett, Witches Abroad)
> ==============================================================================
> 
> 
> 
> 



_______________________________________________________________________________
      Katie Lauren Lucas, Consultant Software Engineer, Parasol Solutions
katie@fysh.org katie.lucas@parasolsolutions.com http://www.parasolsolutions.com