Jump to content
  • Advertisement
Sign in to follow this  

Scripting Language for a Game

This topic is 2179 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

My basic question is what is a good scripting language that already exists to use to make game scripting available to level designers that follows these requirements:

No code bloat. It needs flow control, math, events & timing and absolutely nothing else. The following code for example would be fired on a game event to control the flow of the game rules

on X:
y = y - 1
if y == 0:
timeout 5s game_fail()

Class based. Not so the level designer can write new classes, but so that they can override already existing classes with new members, new values for member properties. The following example will override Foo, which is possibly an entity, and changes it's max speed to 5. So what this will do is any instance of class Foo in this level will have it's maximum speed overridden to 5

class Foo:
max_speed = 5

Level focussed. A scripting language that allows just 1 script file for a level, and is designed not to be a programming language, but a scripting langugae, in that it's more like writing a script for a scene then it is coding a bunch of stuff.

Not compiled. Or can be recompiled at run-time. Run time editing is the goal here.

The reason we need these requirements is because the designer wants to be able to quickly iterate levels and I figure a scripting language to control level flow, although it comes with a learning curve, is the most productive fashion of doing this. Instead of what I've provided to people in the past for quick & dirty control like that which are data systems that are more like drag and drop coding than scripting. Which has ended in disaster, every time. I don't need a powerful scripting language, I need one that simply controls game flow, allows changing data the same way a reflection system would, and leaves everything else up to the compiled C++ code. For another example:

C++ Code
class Enemy {
struct Settings {
double health, damage, speed;
Texture sprite;
double health;

Scripting Class
class Level3Enemy(CPP::Enemy):
settings.health = 5
settings.damage = 9
settings.speed = 15
settings.sprite = "../textures/enemya.tex"
def OnDamage(self,amount):
self.health -= amount
if self.health <= 0:

def Die(self):
# etc

I do like python's syntax, but I don't know what scripting language can achieve the simplicity I want without requiring too much juggling to implement.

Thinking about it. The script basically needs to pull double duty:

As a property modifier for entities and as a flow controller & timer for levels. I have some scripts I wrote up to concept the idea of level control flow and I'll add those as follows:

Example 1: Satellite Uplink

// Survival Mission
timeout 1min self.spawnA()
timeout 5min self.uplink()

timeout 1min self.spawnB()

timeout 1min self.spawnC()

timeout 1min self.spawnA()

// mission successful


self.health = self.health - amount
if self.health == 0:

// Group instances : This will over write the default parameters of the object
// Make them tougher than before by setting their inbuilt parametrs to different values
health = 5
damage = 2
// Create a new value for this class
oldspeed = 0
// Freeze this enemy in place for 3 seconds when damaged
oldspeed = maxspeed
maxspeed = 0
timeout 3s self.resetSpeed()
// Allow the en
maxspeed = oldspeed

// Singular Item Instance
health=50 // Custom variable
ondamage(amount): // Called by system when this is hit by fire
self.health -= amount // Decrement
if self.health <= 0: // If test
global.failure() // Call failure in global.failure to tell the system to bring up retry

I'll probably replace the following with just entry & exit functions rather than having a global class

// Global item
onstart(): // Called by system at start of level
timeout 5min self.finish() // Call a script function in 5 minutes time to finish the level
finish(): // Called automatically after 5 minutes
Edited by Kyall

Share this post

Link to post
Share on other sites
Python and Lua are two popular options that hit all your criteria. Both are pretty straightforward to implement in a variety of hosting languages.

Share this post

Link to post
Share on other sites
As ApochPiQ said Lua and Python (among other languages) can be used to fulfill your requirements. I personally prefer Python over Lua for no technical reason, but because I feel more at ease while coding in python than in Lua.

Boost provides a quite powerful and easy-to-use classes for binding C++ and Python: http://www.boost.org...ibs/python/doc/ Edited by doeme

Share this post

Link to post
Share on other sites
Yuuuup, Python and Lua. Personally, anything that is likely to involve SQL I use Lua for, but in all other situations I default to Python.

Share this post

Link to post
Share on other sites
I've implemented a Python wrapper class from code project by Mindteck if you don't want to use Boost. The author is Vijay Mathew, and he's wrapper class I modded works wonders.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!