Sign in to follow this  
NotTheCommonDose

My own scripting language

Recommended Posts

Hi. I have a public question. I have designed a world editor for my game so I can have outside help when developing the game. Before I go any further I want to put a lot of thought into the scripted event system. I am leaning towards being able to script the game, including "cutscenes" and small effect/events from within the level editor, both to make it quicker and easier for my once I am in the creative phase, as well as to, again, allow others to help. The game is written in Java, so is the engine. I am leaning towards creating a "conditional" class that can be instantiated on any map and will allow the game to wait for and react to conditional statements that anyone using the level editor can script. However, I have not fully thought the entire system through and as a result I will not begin programming until I do so. Any ideas would be great as to what kind of classes or tools I would want to give the level editors that I might not have thought of, as well as technical hints at how I would program something like this would be great. Thanks in advance!

Share this post


Link to post
Share on other sites
Maybe it's not obvious what I'm looking to develop. I'm trying to write a system of code that can be brought up from a menu in the level editor I have written that will allow the user (level designer) to script events in the game based on certain conditions.

For example, if the user has said item and steps in certain bounds set timer.
If timer finishes, open door.

Or, when player enters map and puzzle is not solved, reset object to original position.

I'm thinking of creating a conditional class, as well as having a queue of events that can be triggered if the conditional is met.

At the moment I don't see any flaws yet I know it isn't comprehensive enough to the point where I can just jump right in and start programming it.


Share this post


Link to post
Share on other sites
There really isnt much of an answer anyone can give, without doing much of the work for you. Its not that we're lazy, most people just have their own projects they'd love to see come to life as well.

You are on the right track though. Just need to think from a different angle (if that makes any sense).

Your first example, about the player having an item and entering a bound. How, in the code is your player represented? How would you go about giving the player the ability to have a certain item? The player need to be in a certain area, so how would you check if hes there? Setting a timer, well, youll need to figure out a way to have a timer, and then youll set it.

In trying to keep this general, just make a list of the kinds of conditions you might want to include, a list of events that trigger the checking of one of these conditions, and then a list of outcomes of these checks.

How this fits into your game is beyond us, as its fairly specific to what you have coded already. Once you have in mind how you want something haddled, if you're still stumped on the technical side of it, you should have some good specific questions to ask.

Share this post


Link to post
Share on other sites
LLVM ("Low Level Virtual Machine"), is a compiler backend that translates either to native opcodes (including JIT compiling) or lets its code run inside its own virtual machine. It has tons of optimisations, so if you're scripting language is supposed to be located somewhere at the performance frontline (e.g. a Shader in a software renderer of some kind), then I would read up some bits of http://llvm.org (I hear it sometimes performs even better then MSVCPP and gcc).

They have a great tutorial in which they implement a compiler for a language called "Kaleidoscope", and then jit-compile it with some optimisations.


Other ways to build the *parser* for your language might be yacc/bison (sometimes referred to as "Compiler compilers") or even boost::spirit, which lets you define a grammar inside C++, pretty much like "inline EBNF".


BUT: I would suggest you begin with more easy stuff before right jumping into writing a fully fledged compiler: Look at the Wikipedia Entries for Compiler [Construction], and download "Compiler Construction" of Niklaus Wirth, which is available for free (from Addison Wesley), and of course there is The Dragon Book ("Compilers: Principles and Practice")

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