Game scripting?

Started by
3 comments, last by mirex 18 years, 8 months ago
I have been doing some design lately on a 2D game editor and I have stumbled one important part of the editor where I have no knowledge whasoever about and that's scripting. Now The way things are is that I am trying to hard code only the necessary parts that will not change during the game such as the 2D renderer and the Music player and stuff like that. I wanted to make up a "script editor" in which I could soft code the some of the game logics that could change during gameplay such as the the enemies behaviour/AI, Level events triggered by certain situtions such as a ship touching a bonus capsule giving it the bonus, changing the scrolling speed on the spot using events and stuff like that. I want these to be changeable through scripting in a way that I don't have to hard code recompile every time I make a single change to the game. I know about some scripting languages used by many of you such as Lua and Ruby and maybe Python but I think it's more than a scripting language. Now what I want to know about this is what kind of questions should I ask myself about what would be more "appropriate" for me. I do think any of them will serve my purpose right but my biggest concern is how it will work with the hard-coded program. How am I suposed to set it up so that my engine interprets the scripting languages to get it to affect the elements in the game I want to modify. The way I see things right now is that I will have to find a way to get the scripting language interpreter to run as a part of the engine. It will have to be able to load the script files made with the editor and run them at runtime without a need of recompilation if I was to change a simple value in one of the scripts. I don't know if my information is correct, partially correct or completely off track but I'm am looking for a little starting info so that I can start reading and working on the subject as fast as possible. This seems really exciting and powerful. By any means, if you can guide me on the actual process of such an idea and what book/tutorial/website I should look up on this subject, I would really appreciate it. Thank you very much for your time and replies [grin] [Edited by - Avenyr on August 6, 2005 1:03:53 AM]
Advertisement
Generally, scripting interfaces allow you to tell the interpreter about 'real' functions (meaning ones you coded in C/C++) and it will then allow scripts to call these functions. In this way, you interface the scripting language with your engine. While it sounds rather easy to use, it can become quite complicated because often you want to limit the scope of what scripts can do (to prevent cheating, viruses, etc) so you'll have to make a middle layer of functions that get called by scripts, verify everything is ok, and then passes the call onto the engine.

There is quite a bit of information on interfacing with Lua on the internet, and there is the boost::python library that helps you interface with python.
"Walk not the trodden path, for it has borne it's burden." -John, Flying Monk
So with that said do you recommend using scripting the way I see I would use it or would you recommend another method to achieve the same result ?

I have been told to hard-code everything tonight using a entity system like Half-Life does but I would need more information on that.

Up to now I am doing some research on this entity system but there doesn't seem to be much of a "things start here" tutorial about that. I'll keep looking for this tomorrow since it's getting late.

Thanks for your reply !
In my system I am using an entity system (w/ lua):

I got a few entities that executes level-specified lua code when it recieves events. such an entity can be a PositionEntity(executes the code when the player comes near it) or a ButtonEntity(if you use it it executes the script).
Enemies has a OnKill script that can be executed(when it dies).
I have registred lua functions that can enable enemies, destroy objects, set them(objects) moving in a predefined manner, create an explosion,launch movies or chage levels.
At the beginning of the level a lua-file is executed(if it exist).

Hope that this info helped ;)
In my game I'm creating my own inside-game script editor, because I think that there would be limitations if I would use some script-language. This way my scripts can do anything in the code; there is list of possible events (move creature, spawn creature, destroy object, change level, end level, loose life, delay script, play sound ...) and you can create a list of these actions which will form the scripts.

This topic is closed to new replies.

Advertisement