Implementing A Scripting Engine For My Game


benjymous said:
I'm planning on implementing some sort of scripting engine into my game, to simplify the scripting of events in levels, etc. Does anyone have any advice on any particular engines?

Depends on what language you want your scripts to be in, and how you want to expose your code to the scripting engine.

I'm currently writing a game in Scala that I don't want to make public yet, but it uses XML 'level files' with 'scripting code' in Java or Scala ('quotes' intentional), but that's just because that solution fits my game best and has very high performance on a JVM.
 
Last edited by a moderator:
I'd recommend Python (see www.linuxjournal.com/article/8497) or if you want things more 'limited' and secure (to prevent loading of external libraries etc), Javascript (SpiderMonkey).
 
Forth!!
Specifically FICL, although there are other solutions available.
CODE
http://ficl.sourceforge.net/

PS. Ignore me, I answer 'Forth' to every question about programming languages ;)
 
Last edited by a moderator:
'Count Tuxula' said:
This. Lua is used in many professional games, and is really designed for this. The game that I'm working on is going to hopefully have a Lua scripting engine, if I ever get there. I have a lot of stuff left to write before I get to the scripting engine...
 
Last edited by a moderator:
'Archaemic' said:
'Count Tuxula' said:
This. Lua is used in many professional games, and is really designed for this. The game that I'm working on is going to hopefully have a Lua scripting engine, if I ever get there. I have a lot of stuff left to write before I get to the scripting engine...


+1 for Lua. Used it in the past, and it's a nice language to script in, and is used in many commercial & non-commercial games (see spring.clan-sy.com for a nice open-source, lua extensible rts engine).
 
Last edited by a moderator:
lippy said:
'Archaemic' said:
'Count Tuxula' said:
This. Lua is used in many professional games, and is really designed for this. The game that I'm working on is going to hopefully have a Lua scripting engine, if I ever get there. I have a lot of stuff left to write before I get to the scripting engine...
+1 for Lua. Used it in the past, and it's a nice language to script in, and is used in many commercial & non-commercial games (see spring.clan-sy.com for a nice open-source, lua extensible rts engine).
Python would be good if you need a heap of features while still having an easy language. With Python, you can make things like web queries for your triggers (for multiplayer, or just very interactive items in the game) and other stuff (anything really) which are impossible in Lua.

But if you 'only' need a "logic" scripting language then go for Lua.
 
Last edited by a moderator:
Man, I wish somebody would have recommended Lua already, because it was purposefully designed to do exactly this.

http://www.lua.org/

Or, you could just go with what everybody else is saying and use Lua.
 
Thanks all, it does sound like Lua is the way to go (tbh I was already leaning that way myself, but was checking that nobody had any "oh god, keep away from Lua" type stories)

The next question is does anyone have any experience/advice on actually doing the integration? All the stuff I've seen on Lua seems to require me to explicitly expose functions, which feels a little icky (although, I guess, more secure)
 
Here's another vote for Lua ;)

I've bound it to engines easily enough and you can use things like Luabind, SWIK ( can use this with Python too if you want to go that way ) and toLua which'll help ease the pain a bit, though I still prefer straight forward bashing of the Lua stack myself!

I've been trying to clean up my engine and release source to it for a while now, but if you want to see an example of bashing Lua nearly directly ( using a template system called Lunar from the Lua users wiki ), you may be interested in this - stuckiegamez.co.uk/project/files/HonoursSource.7z - which is my 4th Year University Project where I bound Lua to my engine to abstract game logic ( and pretty much everything else. )

It's horribly old code, and I've been cleaning it up since November and fixing a mass of bugs.. and annoyingly, at the end of every month just when I think it's ready, I find another bug that requires partially rewriting a heap of stuff! That's the reason why it's not been released yet :(

That said, it may help you, so feel free to use and abuse it :)
 
Last edited by a moderator:
'benjymous' said:
The next question is does anyone have any experience/advice on actually doing the integration? All the stuff I've seen on Lua seems to require me to explicitly expose functions, which feels a little icky (although, I guess, more secure)
Would you prefer C/C++ support reflection? I wouldn't!
 
Last edited by a moderator:
In all of my recent game-projects I implemented my own scripting system which is something which you could almost call a clone of Rockstars SCM used for all older 3D GTAs.
Its really low level but that makes it easy to integrate it and keeps it minimalistic (which is in my case very important because I always kept 96k limits for future demoscene projects in mind). The only hard thing to do is writing an assembler / compiler for it but it shouldn't be too hard - not even for beginners.
I never had the patience to learn lua or phyton and always thought they are too big. My solution usually fits in not even 500 bytes and a single source file with about 300 lines with all featurs I need.
 
Last edited by a moderator:
I don't know what it's like in use or in its integration, but Squirrel seems like a possible alternative. It's used in all sorts of games and applications (even code::blocks uses it). I've had it bookmarked for a while and meant to look into it further. Lua of course was the alternative.

from the site:
QUOTE
Squirrel is inspired by languages like Python,Javascript and expecially Lua(The API is very similar and the table code is based on the Lua one)

CODE
http://squirrel-lang.org/
 
Last edited by a moderator:
Lua or Python, depending on your needs. Lua is easier to embed, Python has tons of features.

JavaScript could also be a choice, but integrating would be a bit harder.
 
Back
Top