Advertisement

Scripting engines for games

Started by April 24, 2002 06:49 PM
26 comments, last by Apoch 22 years, 6 months ago
I''m curious to see how everyone prefers to implement their scripting engines. Personally I see no good reason to write an entire new parser, when you can use components like M$''s Script library, for example. Of course, these components require that your game is OOD based so they can interact with it, but IMHO, using OOD is a good design practice anyways as it gives you a lot of flexibility in an engine. What do you all think? Apoch Lead Developer The Freon Project
ApochLead DeveloperThe Freon Project
I''m planning to use Stackless Python, it can be embedded in C++ programs. And the game that inspired me to make my own also uses Stackless.

game: www.eve-online.com
Python: www.python.org
Stackless: www.stackless.com

my game: www.star-fortress.com
Advertisement
I''m using a full-on bytcode vm for my scripting stuff. It''s pretty cool, and, though I haven''t yet written a script compiler for it yet, it''s fun to make my little man walk around by writing in virtual machine language.

It works on the basis of reading an instruction at a time and executing the function based on that instruction, which is just an array of fn pointers, so for each step in the loop, I do this:

func [opcode[vm->ip]] (vm);

and it runs my function, which can be anything from your simple arithmetic ops to the old "move man" operation It''ll be fun to come up with that asm mnemonic .. movm or something

KB
__KB
Lua is a great choice for almost any kind of scripting. It''s what I''m using for all scripting in my current reusable engine.

The Spidermonkey java-script engine is also very good(find it at www.mozilla.org))...
I''ve written a c-style oop languague with a native code compiler. It compiles the classes in packages. These packages are dynamic loaded and linked at runtime.The best thing is that the classes are compatible with the delphi objects(no properties). So I can inherit a scripted object from a delphi class and I can call in both directions(stdcall and virtual methods only). The class packages contain also some symbol information so that saving and loading an object is generalized.


Advertisement
Besides that it''s real fun to develop your own bytecode compiler/vm (yeah,yeah.. I know I''m kinda perverted ) you might actually learn something from it.
I''ve considered using Python in games, but am unsure of its performance. Does anyone know of an article contrasting the performance of Python and other languages in such an environment?

I plan on using Lisp for my scripting. Yes it is interpretted instead of compiled most of the time, but it runs in time comparable to C or C++ and has memory usage on par with Java. Plus it''s very extensible. It''s very easy to use Guile and then register functions. This saves a lot of time from implementing your own lexer and parser. (Guile''s home page is http://www.gnu.org/software/guile/guile.html)
quote: Original post by Jivera
I plan on using Lisp for my scripting. Yes it is interpretted instead of compiled most of the time, but it runs in time comparable to C or C++ and has memory usage on par with Java. Plus it''s very extensible. It''s very easy to use Guile and then register functions. This saves a lot of time from implementing your own lexer and parser. (Guile''s home page is http://www.gnu.org/software/guile/guile.html)


The game Jax and Daxter for the PS2 used a custom LISP interpreter called GOAL for most of its code. While it allowed them to change behaviour while the game was running, most of the programmers hated it since they didnt know LISP. But whatever floats you boat.


University is a fountain of knowledge, and students go there to drink.

This topic is closed to new replies.

Advertisement