In Game Scripting
BlitzMax Forums/BlitzMax Programming/In Game Scripting
| ||
Are there any in game scripting libraries for doing actions and events for Blitz? Thanks |
| ||
MicroC could be a solution Or if you want to use something "better known", create something basing on LUA (AXE has the needed core implementation) The ScriptEngine (ie the thing that connects Script VM to Ingame action) needs to be written by you anyway, as that part is project specific. |
| ||
Do I have to write the parser or is there a parser that I can use and integrate my custom actions with the parser? |
| ||
You don't need to write the Script VM (the parser is part of that) There is LUA and MicroC which already offers you that. All you need to do is write your own functionality which you add to it, so you can write scripts specific to your game. (for example trigger actions) |
| ||
Which would you recommend? I see a LUA post down in the forum. Do you have any links to libs that do this or samples in max? |
| ||
MicroC you can get from my website here - http://www.binaryphoenix.com/?action=software&step=view&id=11 I would suggest you use LUA though if you are going to be running anything time intensive (MicroC was designed with latency functions in mind. I'm going to be porting FusionScript (a scripting language I designed for one of my projects) over to BMax soon though which you may wish to wait for as FusionScript is far faster and more feature-full than MicroC (its actually over 400kb of C# code at the moment). |
| ||
I need a copy of MicroC. I used it in a project, and lost the machine that it was on. Does anyone have the archive? binaryphoenix.com doesn't seem to be functional. |
| ||
You could also look into Tiny C Compiler for a in memory C compiler. Its not realy a "scripting" language and is potentially unsafe, but still worth a look. |
| ||
I think if I can't get ahold of the MicroC module that Helios did I will end up rewriting the project to use Lua, which isn't going to be easy. I'll look at Tiny C too. |
| ||
Blueapples: Sorry I've been redesigning my site and haven't been on these forums in a while, you can get the module here - http://www.binaryphoenix.com/projects/Modules/MicroCModule110806.zip , I may update it in future (it needs it >.>) though so check out binaryphoenix.com for new details. |
| ||
No worries. I did eventually find it, and I'm slowly making a couple improvements. This version might be older than the one you just linked to, it's dated 2005. Anyway, one big thing (which I decided I just don't have time to do right now), is I'd like to have pass 1 track all tokens so that it can make accurate line error reports for things like invalid escape sequences. After looking at it, I decided it will just have to do the way it is. I did however fix line reporting for pass 2. It was incrementing TokenLine even when NextToken was called to get the lookahead token. This puts the line number reported for errors way too far out. My patch is simple, compiler.bmx, line 2556: If CurrentChar = "~n" Then TokenPosition = 0 If SetAsCurr Then TokenLine:+1 EndIf And then line 2844 was using NextToken() to get the current token's line number, changed to: If NextToken().id <> ID Then .. Error("Expecting token (~q" + TokenIDToMnemonic(ID) + .. "~q) but found (~q" + CurrentToken.Data +"~q) line " + .. CurrentToken.Line) The compiler seems a bit lengthy to me, but the module is a nice piece of code. |
| ||
I've gained a lot more compiler-design experiance since I did that module. I've been thinking of doing another version with a lot more powerfull features such as OOP, more speed and by god a more cleaned up and structured source file / structure, it really depends on if people would use it though. Also if its dated 2005, thats probably pretty far out of date - Might wish to use the later one. |
| ||
Well, Helios, I know I would use it. So far it's the easiest to use scripting module I've seen that doesn't have external dependencies. One feature I really like about it is the simulated multi threading. This has been critical for a project I'm working on (non-game), as I need to keep a GUI updated while a worker script is processing tasks in the background. This wouldn't have been possible with DLL based scripting languages as they aren't thread safe, from what I've read anyway. There's just somehting very nice about this: Repeat If Thread Then Try If Thread.IsActive Then ' Run all threads in the VM with an infinate timeslice ScriptVM.RunThreads(-1) ' Check if the thread is finished if so, change status 'If Not Thread.IsActive Then SetStatus("Script finished") End If Catch e:String SetError(e) End Try End If If bQuit Then Return False Forever Then I just have to have a function Exit added to the VM that sets the global bQuit to true, and I can do whatever I need to in the script while my GUI is nice and clean. |
| ||
Oh well you never know then, you might just see a new incarnation soon :). |
| ||
would be cool :-) |
| ||
This seems rather cool to me. I'm gonna have a go with it here in the up coming weeks. Scripting is something I've seriously wanted to do with my projects. It will be a nice thing to add to my 2D World Designer. I'm grabbing a copy just after this posts. I'm like Blueapples, I enjoy cleanliness in my code. I also don't like extra dependencies in my stuff. I also contemplated building my own scripting tool. If this one serves what I need, then I won't bother. Thanks for posting this out Helios! |