Implementing Java Scripting

I have been looking on how to implement Scripting into a text game I am making to easily expand it how would I do this.

I have implemented the ScriptEngine but how would I make an api that would interface with the script.

Don’t waste your time with a JavaScript Engine that was removed in Java 15.

Instead, use BeanShell. It’s like writing Java code rather than scripting.

1 Like

Who, why and how- will use your “scripting API”? I’ve created mechanism of injecting content in my game (in case of internal game content) based on runtime compiling and classloading Scala code. I’ve also implemented in-game hotswap so development is much faster. But…

I wouldn’t do such thing if it had to be used to compile untrusted sources (its not sandboxed). So, why do you need something like this?

I wanted script mung for my game and I couldn’t find resources that should how to scripting that wasn’t the scripting api