Gompl, a very simple scripting language written in GDScript

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 didn’t need 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:

while x < 10 do // variables are initialised as 0 if used without prior assignment
    some_func(x) // functions are defined in GDScript, not in Gompl
    x = x + 1
end
if some_other_func("test") != 100 then
   "success"
else
   "fail"
end
// the last expression (either "success" or "fail" in this case)
// is returned by Gompl's eval() method

If this is interesting to some, here’s the code:

3 Likes

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 decided against removing bools (as they’re needed for calling GDScript methods), but added floats now.

Still struggling with the use-case for this… unless you want to build some Chaos-o-Matic 3000 gamestate machine… :sunglasses:

Wondering where this is going… :metal:

Dunno, what’s not clear about the second sentence in my first post?

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.