Question

The ingame script will control NPC/AI logic.

If I were to implement ingame scripting feature which language should it support?

Keep in mind my implementation will run on multiple platforms like .net, 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?

Was it helpful?

Solution

I'd use Lua, because it's terribly easy to embed. Embedding Python appeared to be complicated 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.

OTHER TIPS

Use Lua. It is a beautiful language, widely adopted in game industry.

There are Lua bindings for most of your platforms:

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 comment 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, come from a single place and I don't expect such problems.

That depends on how complex your code will be (how complicated the behavior of NPCs can become). Tcl, Lua and JavaScript are for simple tasks. Writing large pieces of code in these languages quickly tends to become unmaintainable (especially for casual users).

Squirrel uses a C-like syntax which most people will be comfortable 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 compare the Lua "tutorial" to the one which comes 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 comes with an IDE (IDLE) and there are other IDEs which support Python which gives you code completion, 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top