Sign in to follow this  

Scripting Language for a Game

This topic is 1966 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

[CODE]on X:
y = y - 1
if y == 0:
timeout 5s game_fail()[/CODE]

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

[CODE]class Foo:
max_speed = 5[/CODE]

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 [CODE]
class Enemy {
struct Settings {
double health, damage, speed;
Texture sprite;
double health;

Scripting Class [CODE]
class Level3Enemy(CPP::Enemy): = 5
settings.damage = 9
settings.speed = 15
settings.sprite = "../textures/enemya.tex"
def OnDamage(self,amount): -= amount
if <= 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


ondamage(self,amount) = - amount
if == 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

[CODE]// Singular Item Instance
health=50 // Custom variable
ondamage(amount): // Called by system when this is hit by fire -= amount // Decrement
if <= 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
[/CODE] Edited by Kyall

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: [url=""][/url] Edited by doeme

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

This topic is 1966 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this