Scripting Systems

"Dan Thompson" <[email protected]>
Newsgroups gmane.games.devel.general
Message-ID <004d01c3dfa7$ca9c4fc0$6400a8c0@gunvulture>
I've looked around and implemented a few systems, but I thought I'd get
everyone's opinion on how scripting should be incorporated into a game. Note
that I'm *not* talking about what language to use, or what the scripting
should be used for, nessesarily. Also note that the archives search on
sourceforge is the worst search engine ever known to mankind. If this has
been covered already, I apologize.

The best way I've seen so far is every game object has a script running
behind it that is essentially in an infinite loop. It spins on a check for
messages call into the engine. Then when it gets a message it does stuff.
e.g. Move Forward Was Pressed This Frame message. Then the controlling
script does some trig, comes up with an appropriate force, and calls into
the physics engine to add the force for the object. Also, these scripts run
in a user level thread, where the script manager throttles the script
timeslice based on current game performance, and the scripts call a Yeild()
function when there are no messages to process. (btw, the scripts are
effectively preemtive because we altered the lua execution engine to stop
the stack for a given thread when a certain instruction count is hit. That
way we get many threads, with throttling , and no synchronization issues to
speak of. We also get the ability to limit all scripts to a certain % of
frame time.) The primary downside is with a lot of game objects out there,
you run into some pretty serious dividing of the time you have. Under
release mode, we were getting about 200k lua instructions/second executed in
the time given to the script manager. You get 100 objects in the game, and
you are down to 1k instructions, with isn't a whole lot. This is mediated by
the fact that scripts call a Yeild when they aren't doing anything (so you
get 2 instructions, though both are C calls).

This method is vs. just running a script and creating the stack when the
message comes in. This seemed far too expensive, as you could be creating
script stacks all over the place, and it also runs into the problem where
the game locks because the scripts are being run in the same thread.


These are just the ways I've come up with, and I'd really appreciate some
ideas shot at me on how people think it should be done.

Thanks!
Dan



-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Gamedevlists-general mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gamedevlists-general
Archives:
http://sourceforge.net/mailarchive/forum.php?forum_id=557
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.