Home Articles Tutorials Resources About

Utility library to add C# scripting to your game


By Rim van Wersch, July 5 2007

Scripting is becoming ever more important in game development and application development in general, since it allows you to seperate bits and pieces of code from the main codebase of your project. This is a trend we're accustomed to for other resources, like images and data, enabling you to easily update such script components and it provides additional flexibility for (end)users of your software package.

For games scripting is especially useful, since it provides access to the game's functionality for non-technical users, like artists, designers and players. The success of scripting in games really shows in Bioware's NeverwinterNights, where the game's scripting ability contributed significantly to the release of numerous player created game modules.


About this game scripting library

This library provides various helper classes to easily set up scripting in your C# application, using C# as the scripting language as well. We created a ScriptEditorControl to allow for convenient editing of scripts, which is included in the library (see Figure 1). Aside from this rather nifty control, the library contains helper classes for easily compiling and running scripts and it comes with a demo application to show how to set this all up in a breeze.




   Figure 1. The demo application with an example script loaded, showing off syntax highlighting and our redumentary Intellisense


A game scripting library?

We keep calling it a game scripting library, so what's in it for games? Well, aside from making it a lot easier to add scripting, the library also provides the facility to easily restrict code permissions on scripts, so you can prevent them from doing things you don't want. This is generally good practice, but crucial if you want to allow endusers to create scripts themselves. How to set this up and how this works is demonstrated in the sample application.

Another point of interest in the library is the built-in support for script templates, which is also demonstrated in the sample. By using templates, you have more control over your script's structure and you can remove some complexity from the scripts, which makes writing scripts more accessible to non-technical staff or endusers.


Credits

This library reuses parts of the excellent syntax highlighting textbox by Patrik Svensson.



Files for this resource

Filename Size
  Scripting.zip 118.9 KB


Further reading

 
MDX info is an initiative by vector4. All content is copyright © 2005-2014 by its respective authors | About MDX info | Terms of Use | RSS feed
Coming soon!