Archived

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

HexDump

What is the best way to Use a scripting language.

Recommended Posts

Hello guys, I have been thinking in adding scripting capabilities to my engine. I would like to be able to add classes dinamically for example different classes of enemies, enemies logic, events, methods, etc... to the game without recompile it. After thinking of it during somedays I have reach to the conclusion that if I want to get this I need to write lot of code in thet scripting language (or this is what I think), but I don´t like the idea, because of speed. Another thing that should be pointed is who has the responsability of load this classes? and instantiate them?, I mean how should be all this mess setup to achieve what I´m looking for. So, I need someone to guide me in this labirynth and tell me if this is possible (it is because, Unreal and others do), and the best way to achive it. I will be really pleased if anyone could point me to any source code or something on inet to clear all this mess. Note: My prefered scripting language is Python. Thanks in advance, HexDump.

Share this post


Link to post
Share on other sites
I hope you realize your post got moved

I refer you to the last reply here http://gamedev.net/community/forums/topic.asp?topic_id=173746 for a brief summary of how I call python from c++.

To get you started, you should check out the python extending and embedding tutotial (http://www.python.org/doc/current/ext/ext.html), the python-c api reference (http://www.python.org/doc/current/api/api.html), the boost.python library (http://www.boost.org/libs/python/doc/index.html, download at http://www.boost.org/), and this great article on Python "weightless threads" (http://www-106.ibm.com/developerworks/linux/library/l-pythrd.html).

Personally, I reccommend using the Very-High-Level-Embeddning (its mentioned in the embedding tutorial) as much as possible. I found that everything I needed to do could be done through the high-level python interface. (Again, see that post I mentioned above). Python weightless threads can be used to great effect with this to avoid script-blocking-c++-execution problems.

As for source, you may wish to look at the CrystalSpace engine source - they have a python plugin. If you like, you can email me for some of my implementation.

Read up and you''ll start getting ideas.

Dustin

Share this post


Link to post
Share on other sites