Beginner's Guide to AlcScript

Revision as of 07:15, 14 January 2008 by Trylon (Talk | contribs) (Lists)

Alcscript?

AlcScript is a way to set more complex properties on objects than you can with simple blender logic proprties.

In the basics, AlcScript is just a text file that is read and parsed by the plugin. It is located inside blender - blender has its built-in text editor.

Adding your first AlcScript file

To add a default AlcScript file to your blender file, use "Scripts->Add->PyPRP->Add Default AlcScript" in a script window.

Make one window into a text window. Now on the text-windows-menu bar click the leftmost button with the double arrows on it, and select the file named "AlcScript".

Now you can start adding code to it.

AlcScript structure

Alcscript has a hierarchical formatting structure that allows us to group settings together, and nest group of settings in other groups of settings. Check the example below:

Ladder1_Top:
    type: region
    region:
        type: ladder
        ladder:
            direction: down
            style: twofeet
            loops: 7

Ladder1_Bot:
    type: region
    region:
        type: ladder
        ladder:
            direction: up
            style: twofeet
            loops: 7

Now you may notice a couple of things from this example:

  • There is a structure of keys and values much like this: <key>: <value>
  • A value can also be a group of other keys and values - we call this a "dictionary"
  • You indicate a nested dictionary level by indenting it - tis can be don with tab-key in your blender file.
  • There can be nested dictionaries in dictionaries
  • The first key is always the name of the object, and object-specific settings are located below that.

In the example above, the two objects (ladder regions) - have two keys, "type" and "region". Now "type" is a simple setting - it corresponds to the "type" logic property (which was the "alctype" property) and just has a simple string as input. (You can either use the logic property "type", or the AlcScript property "type" at your leisure). The key "region" however, contains another set of keys and values inside of it. Those are at another indentation level to indicate that those values belong to the dictionary under the "region" key

That is why in the AlcScript reference, we refer to these settings as "region.type" or "region.ladder.style". the dot in the middle indicates a level of nesting.

You can see that there is a key "ladder" under the "region" key that also has another set of values. This can go on indefinitely, and is used to specify dictionaries within dictionaries, to make location of settings very specific.


Lists

In AlcScript you can also have lists of parameters - ans lists of dictionaries

Below is an example of AlcScript using lists:

LadderCamera:
    camera:
        brain:
            type: simple
            poa: 0,0,6
            flags:
              - followlocalavatar
            circleflags:
              - farthest
              - circlelocalavatar                

In this case, you can see that under camera.brain.circleflags there is a list of flag names. Here, there are two flags specified, "farthest" and "circlelocalavatar" Under camera.brain.flags you see a list of one flag ("followlocalavatar") that is also perfectly legal - it is just a list with one entry.

These lists are lists of values (strings in this case), because you have not specified a key.

When you start to enter key: value pairs, they get to be assembled into a dictionary, wich is placed under the object

Take the following (fictional) example:

Cam1Rgn:
    region:
        type: camera
        messages:
         - type: normal
           target: Camera1
         - type: deactivate
           target: Cam2
         - type: activate
           tartget: DefaultCam

Now under this (fictional) key region.messages there is a list containing three dictionaries. These dictionaries each represent one message.

The first dictionary has key "type" with value "normal" and key "target" with value "Camera1". The second and third dictionaries have the same keys, but with different values.

In alcscript this principle is used to enable you to specify a number of messages, or actions, each with different values.