Sign in to follow this  
americaneseian

make your own scripting language?

Recommended Posts

I've been making my own RTS for a couple weeks now but it lacks models. Because I used OpenGL (which doesn't include an intrinsic model loader) I decided to make a model editor of my own. However, I was wondering, should I make a scripting language of my own? Or, would it be simpler to simply implement Lua or some other already created language. Any thoughts would be appreciated. p.s. a video of early gameplay is available at http://www.youtube.com/watch?v=351TfPBsowg if you want to see the game engine

Share this post


Link to post
Share on other sites
Integrating Lua would be an order of magnitude easier than trying to write your own scripting language, or at least a language of similar flexibility.

Share this post


Link to post
Share on other sites
but the language doesn't need to do much, only some model manipulations. to implement another scripting language i would have to go through the trouble of getting it to work with java. to make my own seems about the same work

Share this post


Link to post
Share on other sites
Not really. Jython is pretty damn simple to integrate. After all, it's just python...in java, and it can call back into your code with no effort, since all public methods are exposed to it (provided you import the appropriate packages)

Share this post


Link to post
Share on other sites
And when you write your scripting language you'll still need to have to go through the trouble of getting it to work with java.

Share this post


Link to post
Share on other sites
Nice video. That's one hell of a zerg rush! :D

I'm not sure how you made the jump from model editor/model loading to making a new scripting language. I think it's actually easier to just load your levels from, say, XML files, than to position everything in some scripting language. I'd first look into whether you actually need a scripting language / how you will benefit from it / what you plan to use it for. Chances are You Ain't Gonna Need It. If you do need one, then it would be best to look at all the ones out there (Lua, Python, Ruby, Tcl, javascript, Scheme, Lisp, Prolog, god knows what else you could integrate). If absolutely none of them fit your needs, then it's time to think about rolling your own.

Note (I missed the Java part, heh): For Java, you can look at Kawa, BeanShell, jScheme, Jython, jRuby, Pnuts, jLua. If you do not have any designers on the team, I can recommend BeanShell. It is exceedingly easy to integrate, it has no external dependencies, it has a tiny footprint, it can compile your scripts to Java bytecode so it is potentially very fast, and, best of all, you won't actually have to learn or invent a new language, since you'll be writing in Java.

Downside is of course that any development speed benefits from using a high-level language such as Python are immediately out the window. The other downside is that it's a bit too powerful - unless you're comfortable with giving scripts unlimited access to your system, you should look into working with it via a custom ClassLoader with a SecurityPolicy and possibly a whitelist for which classes are allowed to be loaded. But this is true in general for most of the Java-embeddable scripting languages.

Share this post


Link to post
Share on other sites
thanks for the comment on the video :)

I was thinking about a scripting language for actions the models would do. For instance, I think after I make the modeling program ill reuse it as often as possible. However, to get greater functionality out of it, the models would have to perform action specific to whatever game i used them in. Thus, if they had a simple scripting language allowing them to move joints, rotate themselves, fire their weapon, etc they could be easily implemented in any game.

All the language would need would be some key underlying commands for movement of the the vertices and then something for defining methods that make use of either other methods or the underlying intrinsic methods

o! by the way, I made another game that used user written files to command the AI units. I had a couple of my friends write AIs this way and it worked nicely. Everything was in java and I did use a custom class loader that i wrote to dynamically load everything that was necesary for the AI .class files to work. (the game was a compettive AI fight so that actual code for each AI was fairly secret (yes, i suppose they could have decompiled the .class files); that's we i decided on keeping them in the .class format, couldnt "accidentally" open it easily)

Share this post


Link to post
Share on other sites
It depends on what you need of course, but I'm not sure if exposing such a low-level interface at the scripting level is all that useful. When I think of scripted AI I think of it being at a higher level, more decision making and storing those decisions for processing. At the low level, things seem to depend a lot on how you handle physics and animation. Let's say you write that language to move joints, and tomorrow you introduce ragdolls or springs or mocapped animation or some such, then you can't use your language anymore since entities are not in direct control over their state but depend on the simulation.

The other thing is feature creep. When you start you'll be saying "I only want the language to do XYZ" but later you come up with a new idea and now you need it to support XYZZY too (for instance: continuations). Granted, I haven't written any language myself, but I imagine that without a lot of up-front planning this will eventually become complex enough that it will be about as much fun as shooting yourself in the leg :D

Share this post


Link to post
Share on other sites
Creating a language, even a "scripring" language isn't trivial. If you don't believe me, start looking at yacc and lex, or maybe bison. Start reading up on EBNF's (Extended Backaus Naur Form). Make sure you know your automata and compiler theory. For example, know the difference between lexers and parsers. Start reading up on different grammar types (for example, LALR), and it would also behoove you to understand recursive descent parsers.

At my last job, I was tasked with beginning to write a domain specific language for one of our embedded products. The only reason we went this route was because we couldn't get python to compile on our devices processor (which was actually an ADSP, not a CPU). If you can, you really want to use an existing scripting language.

And it's not just because it's easier than writing a language from scratch. Also think of all the thousands of programmers that already know some language like python, (jython, ironpython), ruby, (jruby, ironruby), lua, erlang, or some other of dozens of languages out there.

Share this post


Link to post
Share on other sites

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