Advertisement

what scripting engine should I implement?

Started by July 13, 2004 11:19 AM
13 comments, last by Monder 20 years, 4 months ago
I'm interesting in creating an script engine for my game. I am currently reading and searching alot, and tries to design as much as possible(to avoid to many restarts which I have had before). I have a need of configure the engine, like creating and loading "objects", setting the graphic info, key and mouse setup, physics setup, etc etc ...this seems kinda ok, probably difficult, but using ini files of some sort will do. Like the ini coding in C&C Generals. But I could also have a need for creating a bit more advanced scripts with variables, loops etc etc. I could use it for AI, Story Handeling, and maybe a few other needs. Then you of course have the plugin stuff ... not sure if I need it quite yet, but if I would like to feed the renderer with new shaders and stuff ... maybe plugins are better than scripting? .. .not sure. I'm planning to look into that as well Then of course ... how do I create this script engine? One aproach is creating a JIT compiler or Vitual machine ... which looks very difficult. Thats the approach from several links and articles here. What other options do I have? And would I be able to deal with large scripts (like story stuff), that will have to be in their own threads? Then I could have a use of letting the scripting system be able to use stuff from plugins. I have seen many suggestions for languages, and thats ok... but I have to understand how I should implement this scripting before I choose language and stuff (a C like language would be nice) ... whats your opinions??
Lua is an excelent choice.

If your scripts will mainly fall into speed-critical areas, then you should look into "The Small" scripting language. (let me remind you that for speed critical areas, you should use plugins, not scripts...)
Advertisement
but lua and small runs pretty much as a jit compiler?+?? hmm... this might seems a lot of work
Quote: Then you of course have the plugin stuff ... not sure if I need it quite yet, but if I would like to feed the renderer with new shaders and stuff ... maybe plugins are better than scripting? .. .not sure. I'm planning to look into that as well


Have both plugins and scripting. You'd use a plugin for something speed critical such as a new rendering subsystem (e.g. you'd have one for OpenGL and one for DX), while scripts would be used for handling high level things.

Quote: but lua and small runs pretty much as a jit compiler?+?? hmm... this might seems a lot of work


The LUA API is pretty simple, you don't need to know anything about how they work internally to use them. Using LUA would certainly be less work than creating a new scripting language (as you seem to be wanting to do).
ok - I'll look into it. I am just afraid to either aim to high on a script system that will complicate a lot when creating the game engine, or developing something that ends up as a huge limit to the engine(i.e. have to rebuild and redesign the entire engine)
&#106avascript is my current choice.

There's also GameMonkey, which is a mix of Lua and C++-like syntax.

As well as AngelScript, the author of which is a resident of these fora.

There's plenty others too (Python, Ruby, Tcl, etc) or you could roll your own :)

As I said, my personal choice is &#106avascript and I'm finishing up a tutorial &#111;n using it in games - <a href="http://www.evolutional.co.uk/jsi">jsInvaders</a>.<br><br>Whichever &#111;ne you choose, make sure you base your choice &#111;n how you feel with the language and the implementation (ease of use for you is important) - not just because it's cool to go &#111;ne way.<br><br>[smile]
Advertisement
I have seen all the recommendation of languages to use in this forum, but I have not had a good look at them.

What syntax it is using is probably not the most important, I guess most languages will do. But my experience with scripting is kinda "extremly very low".

As I said. I am at a stage where I am trying to draw, and plan as much as possible, make choises over what kinda tech I want in my engine. Then my goal is to create some sort of a framework and a plan to work with. As you stated, ease of use and implementation is kinda important.

but I have to say ... I am very impressed with the fast response I get at this forum.

thx alot
Just embed Small. It's a great scripting language, with a JIT compiler (no, LUA doesn;t have a JIT, at least not AFAIK), so it's very fast. It's also C like, so if you already know C you won't need to learn a whole new syntax and grammar.
If learning to use and embed a range of script languages is your goal, one thing that you could consider is developing a form of abstraction layer for scripting. I've been toying with this idea myself, essentially building another interface layer on top of the scripts which totally shields the game developer from things like LUA stack manipulation, variable casting and the like. I've already started something similar, at least to some extent by splitting game code from specific script language code. For example, I don't want to have to worry about mixing JS_* calls with my internal system works, because what happens if I want to switch to LUA in the future? All I need to do with my current system is rewrite the scripting API component (which is game specific) to change from using JS_* calls to using lua_* calls. I was thinking, I could possibly abstract this further, so the game calls things like Script->SetVar(x,y) and the abstract plugin system will deal with such calls in it's own specific language. This is something I'll probably work on after jsInvaders has finished.
use python, it is not very hard to implement into C++, but it is quite slow so don't let the whole engine/game be executed from python's core
(probably you also could use BOOST)
When I was younger, I used to solve problems with my AK-47. Times have changed. I must use something much more effective, killing, percise, pernicious, efficient, lethal and operative. C++ is my choice.

This topic is closed to new replies.

Advertisement