defineFunction

abstract fun defineFunction(name: String, function: (List<Any?>) -> Any?)

Makes function callable from scripts under name, which may be a dotted path such as app.alert: missing objects on the way are created. Arguments arrive as Kotlin values (String, Double, Boolean, List, Map or null), and the return value goes back the same way.