Sign in to follow this  

Scripting

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm looking for a way to implement a custom script interface into my game engine, but when I try and find tutorials for implementing a scripting engine I either get something about a pre-existing engine (Lua, Ruby, Python) or how to make a Mad-Lib engine. Mad-Lib engines are too restrictive, and a pre-existing engine won't work. I don't know how to build one from scratch. How do I design one? I'm looking for almost a hybrid of C++ and Basic. I have the Synatx and everything laid out, but now... how to I go about programmatically integrating that? Anyone know and decent tutorials on adding a scripting engine? I'm probably looking to code the entire game in the engine (as well as allow user-made content). I'm not sure how realistic it is, but it would be nice if it supported compiled and uncompiled scripts. For starters, I just want to enable object manipulation/creation/deletion.

Share this post


Link to post
Share on other sites
Quote:
I have the Synatx and everything laid out, but now


Do you?

Are you sure you've covered all the aspects of language design theory? I only ask because it takes a lot of work to design something like this.

Especially since you would need to know about AST, compiler compilers, FSM, and other related topics.


Script engines define some meta-code (byte-code, AST, interpreted) which they then execute. How you bind that to your language of choice depends on internal structure. You can pass commands by string, by stack, through function calls, via dll, inter-process communication, your script might possibly be even compiled into your target language, or it might use its own VM....

The tutorials for scripting engine start with Compiler compilers, or at very least with Lexer, Gramatical parser and AST. You then implement a parser or interpreter that traverses the AST and does something with it.

Alternatively, you create a compiler which generates byte-code, then write a processor that executes it (same way as Java or C# do it). Since this is a complex task, some languages compile into existing byte-code (to be executed in Java VM, for example).

I'm just pointing out that useful script languages are anything but trivial to develop. Even the most popular ones like Lua have years of development behind them, and are still struggling to meet the demands.

Unless you're looking into a several year project, use an existing one. If you're interested into language design, then there's theory first, then the practical work of compiler development.

But what you're asking for ("if it supported compiled and uncompiled") is a *very* large task.

Share this post


Link to post
Share on other sites
Well, when I say I have the Syntax laid out, I mean the user-syntax. Like what I want it to look like. I know that everything takes a great deal of development. I have already poured two years (approx) into my Engine, and it is far from finished.

I'm not looking for some quick little powerless script, but I am not looking for a super powered script either. I'm more looking to bind the script directly to the game engine.

I basically just want a set of abstractions to be able to access my Engines commands. If I use Meta-code to denote functions, how do you encapsulate control loops?

For the sake of options, how would I use an existing language with my Engine?

Share this post


Link to post
Share on other sites
Quote:
Original post by PlasmaroboFor the sake of options, how would I use an existing language with my Engine?


Start here

Once you've successfully embedded Lua into your engine, then you can start rolling your own scripting language.

Share this post


Link to post
Share on other sites
Well, whether or not you decide to embed Lua first, there are some nice tutorials here that you might find interesting.

If you need some more reading material, send me a PM, I've found pages that have information about designing a scripting language.

Hope that helps,
-Wynter Woods(aka zerotri)

Share this post


Link to post
Share on other sites

This topic is 3810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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