Basically what the title says. I needed a simple way to execute game logic via our game’s dialogues and thought creating an interpreter could be fun. It don’t need it to be performant so I just used GDScript for the parser, and the amount of features is small, e.g., there are function calls, but not functions.
A script in Gompl could look like this:
x = 0 // initialise variable, otherwise it's "undefined"
while x < 10 do
some_func(x) // "some_func" is defined in GDScript
x = x + 1
end
if some_other_func("test") != 100 then // "some_other_func" also in GDScript defined
"success"
else
"fail"
end
// the last expression (either "success" or "fail" in this case)
// is returned by Gompl's eval() method
I updated the language a bit, for example if-then expressions can now have elifs. There are some thing I’d still like to change, e.g. removing bools and adding floats for numbers.
I improved the error messages (they show line numbers now), and also made Gompl interruptible. Either provide a maximum amount of execution steps, or use the interrupt keyword, or both.
I added functions, so now you can write something like this in Gompl:
// it doesn't matter where the function is defined
function sum() // parameters are not (yet?) supported
a + b // the last expression is the return value
end
a = 4
b = 8
c = sum() + sum() // c is 24
I added functions mostly because SmallBasic had them too, the language I really liked to use in Unity.