The scripts you load / run will execute within a"Context" (and you can make as many context objects as you want)
So the context object can expose methods that the scripts can call.
Its how IDE scripting works.
The IDE has a context that each of the scripts is loaded into & executed in - and that context exposes functions that the scripts can use. The functions listed in the IDE scripting documentation are all ones provided by the IDE Context object that scripts can use.
What have you looked at so far? XojoScript is covered in User Guide Book 3: Framework (Advanced chapter) and there are some examples in the Advanced folder.
Yeah I found that now, guess I go for F1 by habit.
I got most of it right by diving in…
I looked at the advanced/xojoscript projects but missed that I needed to set the context, so the methods I added and called from the script wasn’t getting called.