[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Scripting
Mark Collins wrote:
>
> On Wednesday 17 April 2002 10:52 am, you wrote:
> > Again, without instructions that can span frames, this cannot be a simple
> > script that's part of the game world.
>
> Python does support embedded scripts running in a seperate thread, so the
> arguments about scripts being run accross multiple frames are kinda
> opintless, as this can be remedied with a sungle call (I don't have the
> Python docs on this machine, so I can't tell you what the call is)
Is that a real OS-level thread or simply the (single-threaded) interpreter
jumping from interpreting one script to interpreting a different one?
If it's the latter then that's a useful thing and I should go back to using
it instead of my own byte-code interpreter for a home-made C subset.
If it's the former then it's not much use because the OS won't efficiently
support enough full-blown threads for the number of AI scripts and other
behaviours that I'd like to have.
I'd like things like:
behaviour_for_light_switch ()
{
while ( 1 )
{
sleep ( 10 frames ) ;
if ( someone_hit_the_light_switch )
{
toggle ( switch_graphic ) ;
toggle ( lightbulb_graphic ) ;
if ( lightbulb_graphic == ON )
{
sleep ( 10 seconds ) ;
signal ( security_system, INTRUSION_DETECTED ) ;
}
}
}
}
...and run one copy of this (or a slight variation of it) for every
light switch in a 100 room building, another for every creature, another
for every collectable...you name it, it has a short script for it.
Having a couple of thousand Linux threads (even if they are mostly
sleeping) isn't a good idea, but a bytecode interpreter (or perhaps
Python if it works the way I'd hope) handles this with ease.
----------------------------- 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
- References:
- Scripting
- From: Dmitry Samoyloff <dsamoyloff@yandex.ru>
- Re: Scripting
- From: Jorrit Tyberghein <Jorrit.Tyberghein@uz.kuleuven.ac.be>
- Re: Scripting
- From: Katie Lauren Lucas <katie@fysh.org>
- Re: Scripting
- From: Mark Collins <me@thisisnurgle.org.uk>