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

Re: Scripting in games.



Chris wrote:

> Event queries are possibly a bad idea - you could end up with all
> manner of odd timing behaviours. One method you may want to try is to
> let scripted objects register handlers that are called by the engine
> when specific events are detected. So say that when a scripted object
> hits a wall, its "on_scene_collision()" function is called. When it is
> hit by a projectile its "on_projectile_hit()" is called... 

How about sending messages to the script - with a single mechanism
to enable it to read messages of all kinds and ignore the ones it's
not interested in?

>>* How does the scripting interface deal with telling the script the
>>position
>>   of the player and other creatures?
> 
> 
> One method you could use is to have a set of query functions 
> 
> get_named_object()
> get_enemy_list()
> 
> or the like and give each object in the game a unique name. you could
> use this to at least partially prevent rogue scripts mucking up your
> enemy data. Or maybe just expose the object list and let the script deal
> with looking at it - that's a grubbier option though.

I was hoping to wind up with a fairly direct correspondance between
objects and the scripts that control them - I wasn't anticipating
allowing scripts to mess with objects they didn't create.

>>* Should scripts be able to communicate with each other?
> 
> 
> If you have named objects, you could have a
> 
> send_message(object_name, message)
> 
> function. Give each object a queue of messages and send_message() adds
> messages to the end of that queue. You could then use
> a get_next_message() function to pull messages off the queue, or if
> you're implementing engine-triggered events for collisions you could
> even allow objects to register an "on_new_message()" event handler.
> Or provide a get_next_message() function that is called from within an
> on_new_message() handler to go through all the new messages in the
> queue...

Yes...I'm pretty familiar with message handling systems.

One thing that's nice about them is that they are fairly network-friendly.

Thanks for the pointers to Thief and others.  I'll see what I can find out.

One system that looks pretty good from reports I've read is the system
used in "The Sims" - does anyone have any comments on how their system
works?   Seems like it must be *amazingly* flexible.

----------------------------- 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