Re: [GD-General] Scripting Systems
Brought to you by:
vexxed72
|
From: Jorrit T. <Jor...@uz...> - 2004-01-21 07:26:36
|
Dan Thompson wrote: >I've looked around and implemented a few systems, but I thought I'd get >everyone's opinion on how scripting should be incorporated into a game. Note >that I'm *not* talking about what language to use, or what the scripting >should be used for, nessesarily. Also note that the archives search on >sourceforge is the worst search engine ever known to mankind. If this has >been covered already, I apologize. > > I'm the project manager of CEL (Crystal Entity Layer) which is a game entity layer sitting on top of Crystal Space (see http://cel.sf.net for more info). In CEL we support scripting in various languages (currently C++, Python, and XML are being used but other languages are possible). The idea is that every entity gets a script associated with it (which we call a 'behaviour' in CEL). Every entity also gets a number of property classes which correspond to what that entity can do. For example, if you want to have a 'chest' entity in an adventure game you could have an entity with the following property classes: - pcmesh: for the actual 3D representation of the chest - pcinventory: representing the contents of the chest (containing other entities) - pcgravity: if you want the chest to react to gravity and fall down - pcmeshselect: so a user can select the mesh with his/her mouse - ... Property classes can be created dynamically and thus you can make entities by adding the appropriate functionality to it. Property classes communicate to the script or behaviour by sending messages. For example, the pcinventory property class will send the message 'pcinventory_addchild' when something is added to the inventory. The pcmeshselect property class will send the message 'pcmeshsel_down' if the mouse down button is pressed on the mesh. How the message is translated to the scripting language is up to the plugin that handles the particular scripting language. For example, in python the script is a python class and every message corresponds directly to a method in that class. So if the property class sends 'pcinventory_addchild' then that method will be called in the python script. I have found this system to be very flexible. Greetings, |