Integrating scripting into an application...

Started by
2 comments, last by Name_Unknown 18 years, 8 months ago
First off, have many people used Ruby for scripting in a game before? It was suggested to me to try out by a friend, and it was a choice between Ruby, Python or Lua. Haven't used any of the three myself, but scripting is a definate must for my game, will pretty much simplify writing the game itself. Anyways, how easy is it to actually integrate Ruby, Python, whatever into a game engine? For example, say in Ruby I want to access functions within my game, how would I go about giving Ruby access to calls within my engine? Such as having a function to add a model to the render list, or having a class to control the camera? Also, what advantages are there of using scripting instead of having an external DLL to the engine to control and coordinate everything? Sorry for the n00bishness here, this is the first time i've looked at scripting.
Adventures of a Pro & Hobby Games Programmer - http://neilo-gd.blogspot.com/Twitter - http://twitter.com/neilogd
Advertisement
Hi there!
I am in the same situation as you are. I need to integrate a some kind of scripting language into my game. However, i have choosen Python. Still i haven't implemented it in my game, but using python scripts is pure fun. You just simple do the same things as in C++ but in much much fewer lines.
Now about the integration, i have heard that Python integration is harder than Lua. Also i have heard that Python is more powerfull scripting lanuage.
(Havent heard alot about Ruby)
Quote:
Also, what advantages are there of using scripting instead of having an external DLL to the engine to control and coordinate everything?

Well, the advantage is that you dont need to use C\C++ to code your AI,game logic,whatever..., you can use scripting language, which is more suited for such tasks.
Also you dont have to recompile your exe each time you change something.
I can't speak about Ruby, but getting the project settings just right to embed Python can be annoying, but isn't actually difficult. Actually exposing things to Python is straightforward using boost::python, assuming that the C++ code you wish to expost to Python is sane. With boost::python you can usually just build Python bindings that closely resemble the C++ class/function interfaces.

The primary advantage of a scripting language is being ablt to modify the runtime behavior of your application without recompilation. This can include entering commands at a console or just modifying the behavior of a subsystem, such as how AI reacts without needing to go and recompile your application or DLL.
I'd go with Lua as a first script language. Dead simple to use and integrate. If you are experienced it is an afternoon worths of work to get it integrated.

Python, well, that is a matter of religion... needless to say I am an agnostic of the Python faith.
"It's such a useful tool for living in the city!"

This topic is closed to new replies.

Advertisement