• entries
743
1924
• views
579090

# Scripting update

95 views

The compiler for the scripting virtual machine is finished. It supports a very basic C-like syntax but with C++ reference parameters and C99-ish declare-local-variables-anywhere sort of thing.

The only flow-control supported at the moment are if/else and while statements and I haven't bothered with static local variables at the moment since I doubt they'll be needed.

You can do stuff like:

f(int&);int value(){    return 10;}proc 123{    int x=10;    f(x);    out x,"\n";}f(int &a){   a=a*value();}

The vm calles back an output function when you print with the out command, so unless you supply one nothing happens. It's there more for debugging the compiler.

As planned, you have service() and register() commands for interfacing with the owning application, so if, say, service 22 returned the player X position in register 3, you can wrap it in a script function and call it like:

int getplayerx(){    service(22); return register(3);}activate(int id){    register(0)=id; service(19);}proc 0{    if(getplayerx()>200)        {        activate(100);        activate(101);        }}

Actually, while typing this, I've just remembered that I haven't actually implemented the comparison or logical operators yet, so I best go get on with that really.

[EDIT] Sorted. Now just need to integrate it into Udo.

There are no comments to display.

## Create an account

Register a new account