Implementing scripts

Started by
2 comments, last by Exorph 12 years, 10 months ago
I have come to a point in development, where I would to have things be simpler, instead of lengthy code segments, I would like to make a system of scripts that can be loaded in at any point, as needed.

Does anyone her, know of a tutorial, or any sort of thing that could help me create this sort of system?
Advertisement
You basically want to be looking at tying scripting languages like lua and python into C/C++ (assuming that's what you're using). I can't think of any tutorials off the top of my head, but once you've chosen your scripting language, you should be able to find it easily using google.

Basically you'll want a game object of some sort that will wrap a script and update it with the rest of the game in the game update loop. There will also be a way, no matter what scripting language you use, to bind (convert) a script call into a C/C++ call, so you'll be implementing those functions as well.

Basically, take a look on the forums about what scripting language to choose because, there have been many many people that have asked in the past, and it partially relies on what you'll be using it for and how you want to use it. When you've made a decision on language, then you can look at how to integrate it into your game.
[size="2"][size=2]Mort, Duke of Sto Helit: NON TIMETIS MESSOR -- Don't Fear The Reaper
If you have the time and think that it is fun, you can make your own programming language and your own virtual machine running it. It will not perform as good as LUA or Java but you will learn a lot and have a better integration with your game. Just have an array for the memory with the call stack, virtual machine code and dynamic allocations, an integer as the program pointer, another integer as the stack pointer and a compiler that translates into the virtual machine code.
The chapter on scripting in Game Coding Complete (3rd ed.) helped me out a lot. So if you can get a hold of it, I'd recommend it. It's a great book overall.

This topic is closed to new replies.

Advertisement