dialogos-project / dialogos

The DialogOS dialog system.
https://www.dialogos.app
GNU General Public License v3.0
20 stars 7 forks source link

how do plugins provide script functions? #197

Closed timobaumann closed 4 years ago

timobaumann commented 4 years ago

I don't find an obvious way of adding a "semi-builtin" function to provide additional functionality from a plugin. Any hints? (not the groovy hint, please.)

alexanderkoller commented 4 years ago

I don't think this is possible, and it's not clear to me that we want this.

Any solution that I can think of seems quite brittle, and I'd be inclined to leave this to advanced users who use Groovy scripts and know what a classpath is.

timobaumann commented 4 years ago

I'm thinking there should be something similar to Node.registerNodeType for script functions that should become available in the language when the plugin is loaded. In fact, the present handling of the "DialogOS-Script-Functions" is beyond weird. I don't see how this would be britte.

I, for one, am a sort-of-advanced user who, lacking documentation on Groovy script, still uses the script language.

akoehn commented 4 years ago

lacking documentation on Groovy

https://groovy-lang.org :-)

timobaumann commented 4 years ago

plugins may now provide their own script functions by overriding Plugin#registerScriptFunctions() and returning ExecutableFunctionDescriptors that directly contain what's to be computed in eval(). An example of how a plugin might want to use this is given in 7240b67

alexanderkoller commented 4 years ago

Here is the documentation on Groovy nodes: https://github.com/dialogos-project/dialogos/wiki/Groovy-Functions