Open roblabla opened 12 years ago
OK, thanks for the pointer. Currently I have no time to work on this, but I will look at it when I do have more time. However ... one caveat is that the architecture of Scalatron is what it is because Scala requires compilation. For a proper scripting language, I guess a purely web-hosted format would really be better. If you feel like working on this, fork the project and give it a try. If you get it to work (well :-) and there aren't too many new dependencies, I'll be happy to merge your code!
I never coded anything serious in scala (All my scalatron bots are written in java), so I don't know if I'll get anything done, but I'll give it a try ^^.
I have no experience with Java scripting, but a lightweight option to make this available (without requiring full integration and testing in the whole Scalatron package) would be to simply provide a gist with (Java/Scala) wrapper code that handles scripts embedded as a string (I know, not ideal, but easy to test). A player that wants to use a scripting language can then just paste the wrapper into the browser editor and get going. If this proves stable/worthwhile you (or someone else) could then integrate it into Scalatron at the source level.
That's probably the easiest way indeed. After some google-ing, it seems Java only comes with JavaScript scripting capabilities at first. For additional languages, the classpath of the jvm scalatron runs in would need to include the respective library (eg: to add python script, you need to put jython.jar in the classpath).
Anyhow, will work on it when i have time and post a gist here
Scalatron notifications@github.com a écrit :
I have no experience with Java scripting, but a lightweight option to make this available (without requiring full integration and testing in the whole Scalatron package) would be to simply provide a gist with (Java/Scala) wrapper code that handles scripts embedded as a string (I know, not ideal, but easy to test). A player that wants to use a scripting language can then just paste the wrapper into the browser editor and get going. If this proves stable/worthwhile you (or someone else) could then integrate it into Scalatron at the source level.
Reply to this email directly or view it on GitHub: https://github.com/scalatron/scalatron/issues/55#issuecomment-8798425
Been playing around for a while, and I have a working javascript engine (i'll port it to other languages when I'm done with this one, shouldn't be too hard) : https://gist.github.com/3778994
Note that I'll be updating this as I go. The goal is to finish the tutorial bot (the 10th one) with as much javascript as possible (in theory, only the ControlFunctionFactory will stay in scala). Another note, not all of the javax.script-supported language supports Invocable (in which case, calling engine.invokeMethod is not possible). I'll create another file to cover those possibilities at one point or another.
Another point, it seems that Rhino(JavaScript's engine) doesn't support exception handling. Sucks, but can't do much about it.
Oh also, I'd like to say that the browser highlighting does not support scala heredocs ("""multi- line string""") and that's a bit of a pain, cuz then it highlights the javascript wrongly (I'd prefer plain green than funky blue/black).
Now, I would really like if you could give me a pointer into where is the entry point for plugins ? Like where are the .jar loaded and executed ? Cuz I've been looking around your source, but the separation between BotWar, ScalatronCore and Scalatron makes it a bit hard to find what I want. From there, I should be able to build something directly into Scalatron without adding too much boiler-plate.
PS : Going from scala to javascript is extremely mind-fucky §_§
Very cool! Let me know if you want me to post something to the Scalatron Twitter stream!
Regarding an entry point: the best thing is probably to start with a search for Plugin or PluginLoader and work forward from there. The invocations are done in Dynamics/AugmentedDynamics. Hope this helps!
Date: Mon, 24 Sep 2012 16:05:52 -0700 From: notifications@github.com To: scalatron@noreply.github.com CC: scalatron@hotmail.com Subject: Re: [scalatron] Support javax.script for bots (#55)
Been playing around for a while, and I have a working javascript engine (i'll port it to other languages when I'm done with this one, shouldn't be too hard) : https://gist.github.com/3778994
Note that I'll be updating this as I go. The goal is to finish the tutorial bot (#10) with as much javascript as possible.
Another note, not all of the javax.script-supported language supports Invocable (in which case, calling engine.invokeMethod is not possible). I'll create another file to cover those possibilities at one point or another.
Oh also, I'd like to say that the browser does not support scala heredocs ("""multi-
line
string""") and that's a bit of a pain.
Now, I would really like if you could give me a pointer into where is the entry point for plugins ? Like where are the .jar loaded and executed ? Cuz I've been looking around your source, but the separation between BotWar, ScalatronCore and Scalatron makes it a bit hard to find what I want. From there, I should be able to build something directly into Scalatron without adding too much boiler-plate.
—
Reply to this email directly or view it on GitHub.
Thanks a lot ! Will check out the source code, I should be able to find my way through with your pointers. I am currently converting the reference bot to JavaScript (I felt like the example 10 bot wasn't complex enough). I wonder if the secure mode prevents using javax.script . Wouldnt be very surprising...
Scalatron notifications@github.com a écrit :
Very cool! Let me know if you want me to post something to the Scalatron Twitter stream!
Regarding an entry point: the best thing is probably to start with a search for Plugin or PluginLoader and work forward from there. The invocations are done in Dynamics/AugmentedDynamics. Hope this helps!
Date: Mon, 24 Sep 2012 16:05:52 -0700 From: notifications@github.com To: scalatron@noreply.github.com CC: scalatron@hotmail.com Subject: Re: [scalatron] Support javax.script for bots (#55)
Been playing around for a while, and I have a working javascript engine (i'll port it to other languages when I'm done with this one, shouldn't be too hard) : https://gist.github.com/3778994
Note that I'll be updating this as I go. The goal is to finish the tutorial bot (#10) with as much javascript as possible.
Another note, not all of the javax.script-supported language supports Invocable (in which case, calling engine.invokeMethod is not possible). I'll create another file to cover those possibilities at one point or another.
Oh also, I'd like to say that the browser does not support scala heredocs ("""multi-
line
string""") and that's a bit of a pain.
Now, I would really like if you could give me a pointer into where is the entry point for plugins ? Like where are the .jar loaded and executed ? Cuz I've been looking around your source, but the separation between BotWar, ScalatronCore and Scalatron makes it a bit hard to find what I want. From there, I should be able to build something directly into Scalatron without adding too much boiler-plate.
— Reply to this email directly or view it on GitHub.
Reply to this email directly or view it on GitHub: https://github.com/scalatron/scalatron/issues/55#issuecomment-8970426
This would unlock the use of many, many programming languages to write bots in, such as JRuby, Jython, Groovy or even JavaScript. This would be extremely useful in teaching environment, as you could then use scalatron as a base to teach other programming languages through the game.
http://littletutorials.com/2008/06/12/script-your-scala-application/