Game logic scripting: Android vs PC

Interested to know more about this. Can you please provide a link to an example/doc?

You can load java classes at runtime. Modern Java even makes it easier to compile .java into .class at runtime.

…but you still don’t get the nice groovy goodies.

1 Like

you can try something like this

I have my own groove-interpreter that can also read java, but it’s still too buggy to advertise it


I actually got around this by using Javascript, courtesy of the j2v8 library. In my test setup, I just keep a V8 instance on a separate thread on the server that can be accessed by the game system. Then, from the client, I can send in commands via the console and the V8 runtime will execute them and send the results back. Its been awhile since I’ve touched it, but I feel like I remember it working well on Android as well.

Granted, integration isn’t as smooth as using Kotlin or Groovy, but it works pretty well (and the lack of instant integration does give me the chance to limit what the scripting engine can do so it doesn’t access the file system or something).


As far as I know , You donot need an external library to get data from js or html on android , usually this is done easily using a Javascript interface built in API , I have tried it on one of my android projects , it was fast concerning UI update but the data was Json ,but seems you are talking about something else , I think at the final point it’s better to stay as far as simple because multiple calls somehow may lead to multiple failures .

I can handle JSON and XML easily enough. It is game scripting that I need, in a way that works the same on both Android and PC.

My goal is to get a similar interface on both Android and PC. The default Rhino engine on PC Java apparently has severe performance problems, while J2V8 works on both and runs quite quickly.


@pspeed are you doing DSLs in a similar fashion used in this example?

Using groovy classes and DelegatesTo annotation to define DSL with the help of closure delegation mechanism. (looks like the annotation part is optional and used as a hint for IDE)

This sounds pretty powerful than the regular Builder pattern. What do you think?

That would be nice to be able to do a similar thing with Java’s Lambda as well :slightly_smiling_face:

I haven’t looked at it but I will when I get back to scripting-related stuff.

I believe I’ve used DelegatesTo in unit test mock objects before and in that case it was definitely required.