Skip to content

Pre-release 0.4

Pre-release
Pre-release
Compare
Choose a tag to compare
@byxor byxor released this 03 Dec 16:49
· 43 commits to master since this release
     __                    __           _       _
  /\ \ \_____   _____ _ __/ _\ ___ _ __(_)_ __ | |_
 /  \/ / _ \ \ / / _ \ '__\ \ / __| '__| | '_ \| __|
/ /\  /  __/\ V /  __/ |  _\ \ (__| |  | | |_) | |_
\_\ \/ \___| \_/ \___|_|  \__/\___|_|  |_| .__/ \__|
                                         |_|
           The QB programming language.
----------------------------------------------------

Release 0.4

Usage of ns:
  -c string
        Specify a file to compile (.ns).
  -decompileWithRoq
        Display output from roq decompiler (roq.exe must be in your PATH).
  -o string
        Specify the output file name.
  -showHexDump
        Display the compiled bytecode in hex format.


image

This build adds experimental shorthand syntax to return booleans from scripts that aren't registered as "member functions" within the engine:

When we have a script that returns true or false...
We can use @ before invoking it to use its return value as the condition of our if-statement.

Example 1

script YourCode {
    if @ YourBooleanScript {
        printf "Your script returned true"
    }
}

script YourBooleanScript {
    if Something {
        return true
    } else {
        return false
    }
}

Behind the scenes, this gets translated to:

script YourCode {
    YourBooleanScript
    if (<__boolean_value__> = 1) {
        printf "Your script returned true"
    }
}

script YourBooleanScript {
    if Something {
        return __boolean_value__ = 1
    } else {
        return __boolean_value__ = 0
    }
}

Example 2

if @(is_north) {
    printf "north"
} else if @(is_east) {
    printf "east"
} else if @(is_south) {
    printf "south"
} else if @(is_west) {
    printf "west"
}

Which gets translated to:

(is_north)
if (<__boolean_value__> = 1) {
    printf "north"
} else {
    (is_east)
    if (<__boolean_value__> = 1) {
        printf "east"
    } else {
        (is_south)
        if (<__boolean_value__> = 1) {
            printf "south"
        } else {
            (is_west)
            if (<__boolean_value__> = 1) {
                printf "west"
            }
        }
    }
}

Whatever the next expression after @ is, it will be moved to its own line before the if-statement.