[Release] BaSS v1.0

27 10 2010

Finally, here it is a polished, mastered, perfectioned, improved version of BaSS, Baro’s Script Compiler!

HERE IT GOES, A DOWNLOAD LINK
HEY AND THE SOURCE IS UNDER GPL LICENSE (I tried to do my best to make it legible)

In case you haven’t heard of it (It was already available as Beta), BaSS is a set of tools that let you define an script language and compile scripts with it. The most immediate use of this is to write event scripts, e.g.: what happens when you speak to someone. But, it can be used for anything you find it useful for.
BaSS currently consists of three tools:

Luthier: Lets you define and describe your language: a set of commands and constructs (premade script fragments) that your scripts will use, as well as other options concerning how the script is compiled (endianess, size of some things, etc).

Performer: Compiles the scripts you make, using the references you’ve defined with Luthier.

Technician: Decompiles a script compiled with Performer, in case you need to retrieve a valid source that, when compiled, produces the same script.

The final results, the compiled scripts, contain an array of bytes that can be read by your program to run the script.

The program comes with a manual where this is explained more deeply in the introduction, and then details of everything the tools are capable of. At the end of the manual, there’s a suggestion section which can help you designing your command set and writing your script running function.

(It is likely that I soon write a template language and a C function to read it, including if commands, etc)
(Changes from Beta version posted in first comment)



BaSS ~ Baro’s Scripting System – BETA

27 02 2010

Download BaSS Download

This is a tool I’ve made to develop Tanuki Tail, but decided to release because I’m so awesome and helpful.

BaSS is a script language toolkit I’ve made (and still work on from time to time). It lets you create script files that use a script language of your invention. For example, if you are making an RPG you may want to create scripts for your NPC events. For example, when you talk to someone make him face you, load a text, print the text, maybe give or take an item, etc. It also has other uses, like event animations (example: “walk two tiles up, then turn around, make the character jump…”) or anything that comes into mind. After all, the final result is an array of bytes with the meaning you gave to them.

The current toolkit consists of two tools, Luthier and Performer, both of which are command line text parsers. The toolkit comes with a manual that explains pretty much everything.

Luthier creates BaSS language files from text files. This is, the collection of commands you want to use to compile scripts with Performer. Read the manual and example to get a better idea, but, a quick one:
5 loadtext 1 2 textID
6 printloadedtext 0
X print 1 2 textID // loadtext textID \ printloadedtext

These three lines would put two commands and a construct in the language:

  • Command number 5, named “loadtext”, which receives one parameter of length two (bytes), called textID
  • Command number 6, named “printloadedtext”, which receives no parameters.
  • Construct “print”, which receives one parameter of length 2 (bytes) called textID. This gets translated into “loadtext textID” and “printloadedtext”
  • As you can see, this also implements constructs, which are something similar to macros in C. A construct is translated as one of more commands with parameters (constant or parameters of the construct), which is useful for common script lines, aliases (multiple names) of a command, or, with label references, jump commands.
    Presumably, loadtext would load a text reference into some buffer, printloadedtext would output it, and print would do both things.

    Luthier also lets you define things like maximum script file size, coordinate types size (each script has two coordinates: bank and script, and offset as an offset in the script file), endianess of data bigger than one byte, file extension, etc.

    The second tool is Performer, which is the actual script compiler. Given a text source file and a language file (created with BaSS), generates a file containing the array of bytes that represent such script. For example, with the previous commands, the script

    %TARGET 0 1
    loadtext 10
    printloadedtext
    print 11

    would generate a script with the bytes 5 10 6 5 11 6 (also, would save it in ./scripts/0/1.), which would, presumably, output texts number 10 and number 11. Constructs get translated into the commands they mean

    It is possible to #define things with a %DEFINE directive.
    It is also possible to insert labels. Labels are references to a script bank-script-offset coordinate, and can be added in a script to create a reference to that exact point of the script. You can create constructs that accept Label or Extlabel types, and then, when compiling, Performer looks up that label. If it’s a Label, it looks in the current script. If it is an Extlabel, it looks in a labels file, where all the labels from compiled scripts are stored.

    Once you have your language defined, you have to implement the commands into your game. The logical way to do this is sequentially, with jumps of needed, by creating a while loop that reads the whole array byte by byte and running each command depending on the byte read (with a switch statement, for example).

    This is a beta. There is a lot to improve and a lot of code to clean. Once the code is cleaned enough so it doesn’t embarrass me, I’ll release version 1, which will be open source.
    Feedback is welcomed, being it praise, bug reports, comments, questions…

    Download it right now.