The ingame script will control NPC/AI logic.
If I were to implement ingame scripting feature which language should it support?
- JavaScript (builtin browser support)
- TCL (interpreter in java)
- Lua (popular)
- Squirrel
- CSI
- Other
Keep in mind my implementation will run on multiple platforms like , flash, javascript and java.
What are the pro's and con's of the listed possibilities? How long will it take to implement the interpreter?
What features are ingame scripters looking for? What are other games implementing?
I am thinking to vote for javascript due to the fact that everybody can read and write it.
What are your thoughts?
The ingame script will control NPC/AI logic.
If I were to implement ingame scripting feature which language should it support?
- JavaScript (builtin browser support)
- TCL (interpreter in java)
- Lua (popular)
- Squirrel
- CSI
- Other
Keep in mind my implementation will run on multiple platforms like , flash, javascript and java.
What are the pro's and con's of the listed possibilities? How long will it take to implement the interpreter?
What features are ingame scripters looking for? What are other games implementing?
I am thinking to vote for javascript due to the fact that everybody can read and write it.
What are your thoughts?
Share Improve this question edited Jan 7, 2010 at 12:34 zproxy asked Sep 16, 2009 at 7:20 zproxyzproxy 3,5593 gold badges41 silver badges47 bronze badges 4- Embedding Javascript is orders of magnitude more plex than embedding Python or Lua (well, at least before V8 I don't know how it is with it) – Vinko Vrsalovic Commented Sep 16, 2009 at 7:54
- @Vinko Vrsalovic: JavaScriptCore (the JS engine in WebKit) has had a standard stable C API (and ABI) for around 3 or 4 years (it's a system framework on MacOS even) – olliej Commented Sep 16, 2009 at 8:20
- See this similar question: stackoverflow./questions/1406836 – Colin Macleod Commented Sep 16, 2009 at 8:20
- V8 is easy, at least building the library and running simple JavaScript from a C application is easy. JIT only though, ARM and X86 backends. If you want to target X360 or PS3 there's no PPC support. I'm confused by OP's platforms, generally multiplatform means "written in C and piled for PC, XBOX, etc. using platform specific code where necessary." Sounds like you will be targeting multiple programming languages, which significantly plicates things. What exactly do you mean? What is your implementation language? Are you writing a library in C and providing bindings for other languages? – Whatever Commented Sep 16, 2009 at 8:26
7 Answers
Reset to default 5I'd use Lua, because it's terribly easy to embed. Embedding Python appeared to be plicated and I haven't really pursued that.
This link may be of further use if you want to know more about embedding Lua and its advantages/disadvantages.
Use Lua. It is a beautiful language, widely adopted in game industry.
There are Lua bindings for most of your platforms:
- .Net: LuaInterface
- Flash: Lua Alchemy
- Java: Kahlua (alternative implementation)
There is also llvm-lua project, which may be helpful for porting Lua to other platforms.
As for JavaScript as a host platform... This subject recurrently appears in the Lua mailing list, but no serious solution were published yet. If you really need to host Lua in JS, please ask in the Lua mailing list, perhaps some people could share their experience on the subject.
I would prefer Python for its bindings in many languages.
I think you mean "integrate" the interpreter, and not "implement" it. Depending on your skills, creating an interpreter for a scripting language could take a lot of time.
I know for sure that Python and Lua have bindings for .NET and Java -- you can embed the interpreters. Don't know whether there are any bindings for Javascript and Flash.
The problem with Python is that there are three variants all made by different people.
- IronPython for .NET
- Jython for Java
- and the regular CPython
I haven't worked on Jython so I won't ment about it. But there are certain portability issues between IronPython and CPython. For example: IronPython doesn't support native C extensions. If there are scripts written in CPython which use these, you will have a hard time porting them to IronPython. Also, if the IronPython scripts use any .NET libraries, you will have a hard time porting them to CPython.
Implementations of Lua, on the other hand, e from a single place and I don't expect such problems.
That depends on how plex your code will be (how plicated the behavior of NPCs can bee). Tcl, Lua and JavaScript are for simple tasks. Writing large pieces of code in these languages quickly tends to bee unmaintainable (especially for casual users).
Squirrel uses a C-like syntax which most people will be fortable with but how about tooling support? If you have to write everything with Notepad, that will severely limit you, too.
Python is a mature language that is easy to learn (just pare the Lua "tutorial" to the one which es with Python). While the various Python versions might seem intimidating (see Rohit's answer), the Python code in your game will be the same for all of them. It es with an IDE (IDLE) and there are other IDEs which support Python which gives you code pletion, debugging, running test cases, etc.
If you want to use Python consider using Stackless as it is rather better at threading than stock CPython. It's used in some MMORPGs (EVE Online, IIRC) so it's got some track record in games. Plus, it is very good for continuations (part of the reason it was developed in the first place), which is quite a good model for 'simulation' type logic that one use in games.