Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


How to use Scripting

This topic is 5980 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve been trying to figure out how i''m going to design the engine for a game i''m writing. I know i want it to be as flexible and extendable as possible, and so i''ve decided to make scripting a very large part of it. Now, here''s the question... How do most games tie scripting into the engine it''s self? I was thinking about just providing an interface for scripts to access the game engine to do things such as drawing 3d models, loading maps etc. then writing the game content entirely in scripts. I see this as really the only way to do it. Isn''t this how Unreal does it with UnrealScript? Is there a better way to tie scripting into the game engine? Thanks in advance! -codebunny

Share this post

Link to post
Share on other sites
That sounds good way.

The way I''m doing it is writing the engine in a scripting language, and optimizing the fast parts as needed.

Using swig.org is pretty good for wrapping c code. It''s ok for c++, but doesn''t support some parts of c++(neither do compilers . It can wrap a number of different scripting languages.

I''m using pygame, and pyopengl with python.

That gives me all of the different sdl stuff(eg sound, input, image loading). With opengl doing graphics with arrays, there is very little overhead in using python to do the opengl calls. I''m doing some stuff with Numeric(a matrix/array package for python)

I''m using a different python library for networking(twistedmatrix.com).

The 3d file format loaders in python, and all other parts of the game too.

Now I''m writing a few things in c/asm for performance. Some parts of character animation, and parts of the particle system needed speeding up.

My game doesn''t need octrees, or bsp trees or anything like that( I use simpler culling) so I''m not doing those. They couldn''t be done in python very efficiently I think.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster
Check out the source to Nebula (RadonLabs - do a google search). There is a lot that I like about this implementation and a few things I am not so fond of. The one aspect that I find VERY slick is that it''s trivial to implement your engine with whatever language you prefer. This is nice in that you do not have to design your own uberLanguage to get things rolling. You can use lua, perl, java, etc.. and then once you have things where you want them you can either develop you own or work compiled scripts into the picture.

Their basic idea is to have everything packed into various dlls, the kernel, gfx, sound, etc.. Then the ''api'' is exposed and an additional interface provided for the script commands. This is nice in that you can write C++ using the linkage directly or have the script engine feed data back and forth from the engine to your virtual environment. This allows you to almost script the whole thing and then hard code the critical areas - IE rapid development. The only drawback is you have to build the infrastructure first but after that your work -vs- progress curve starts to flatten.

Good luck -


Share this post

Link to post
Share on other sites
Thanks guys. :D

I''ll take a look at Nebula. I saw it a while back but never gave it any thought, really.

I also thought about using Python to write my game content, but the native interface used to call C/C++ functions looks pretty slow. I guess, now that i think about it, it can''t possibly generate a large enough overhead to actually matter too much?

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!