Technical Documentation for how ScriptCraft works
kellyfj opened this issue ยท 4 comments
I have a few techy CoderDojo parents ask for details on how ScriptCraft works at a high level. It would be nice to have a small document with a few pictures to describe how Javascript gets reloaded and gets executed (as Java bytecode?) at runtime. What tools you use (Rhino?) etc.
I got a bit of information here
http://walterhiggins.net/blog/ScriptCraft
And I took a bit of a dive into the code but couldn't really figure it out
Best,
-Frank
A major eye opener for me was discovery of the tab completion:
Try the following in the Minecraft client command line: (where [tab] means press the tab key)
/js [tab]
/js global.[tab]
/js server.[tab]
/js self.[tab]
/js self.world.[tab]
/js Drone.[tab]
/js mydrone = new Drone(self) // no tab, prep for the next line
/js mydrone.[tab]
/js utils = require('utils') // no tab, prep for the next line
/js utils.[tab]
@kellyfj To partially answer your question, the Javascript engine bundled with Java is used.
The JS engine used to be called Rhino but the latest rewrite is called Nashorn.
http://www.infoq.com/articles/nashorn
@nixnax Yeah. Tab-completion is important from a discoverability point-of-view, esp. for beginning programmers.
What @nixnax said pretty much sums it up. ScriptCraft uses the JS engine bundled with Java (since Java 6.0) A pared-down version of Rhino was used in 6.0 and 7.0 and a new engine: Nashorn is used in Java 8.0