ScriptCraft
ScriptCraft lets you create your own mods using Javascript. ScriptCraft uses the CommonJS module system (the same module loading system used by Node.js) so managing your code will be easier. You can also run Javascript code on the in-game command prompt or extend the game by writing plugins that use the Bukkit API in javascript.
Examples:
At the command prompt type:
/js 1 + 1
> 2
... Any javascript code can be evaluated at the in-game command prompt.
/js alert( 'Hello ' + self.name )
> Hello walterh
... Special bukkit variables are available via javascript , for example the server
object is the instance of org.bukkit.Server . Writing event handlers in ScriptCraft is relatively easy...
events.blockBreak( function( event ) {
echo(event.player, 'You broke a block!' );
});
events.playerJoin( function( event ) {
echo( event.player, 'Welcome to the server!' );
});
... Any bukkit event can be handled. The above code prints the name of any player who breaks a block in the game. ScriptCraft comes with some built-in functions to make building easier...
/js box( blocks.wool.black, 4, 9 , 1)
... creates a 2001 Monolith 4 blocks wide by 9 blocks high by 1 block long.
The full bukkit API can be used via javascript to write new mods. Yes - you can write bukkit plugins in javascript! See ScriptCraft on GitHub for more information. Full documentation is available on the github docs page.
A Youtube Video demonstrating Exploding Arrows in ScriptCraft A Youtube video demonstrating a mini-game (SnowBall Fight)
Nevermind I got it to work somehow, I edited something and it worked :)
One last thing though. How do I remove a block from a world?
@walterhiggins
Is there a way to make that script work in the .js files because it is still showing the same error. I still don't understand :P
@kevcraft
Hi @kevcraft,
There's a google group for ScriptCraft here ... https://groups.google.com/forum/?fromgroups#!forum/scriptcraft---scripting-minecraft
At the in-game console (not the server console), try this...
/js var block = self.world.getBlockAt( x, y, z)
Does ScriptCraft have a forum, if it doesn't it will be awesome to have one and have people share their scripts and get help :)
Scriptcraft is awesome and I'm new to javascript. I made a couple of function for my own server, but It takes me a long time for me to figure out how to get certain things. I follow this http:jd.bukkit.org/rb/doxygen/index.html and it helps me find good stuff. Right now I'm having trouble getting org.bukkit.world.getBlockAt(int x,int y,int z) to work it says in my console :
: this is probably a rookie error, but I want to know how to get those stuff. :D
P.S. Thanks really for the quick response on that other stuff I didn't think that you were still active :o
@kevcraft
Hi, The logging messages have been removed in the latest upload.
Walter
@kevcraft
Hi, Sorry about that logging message. I'll post an update later today.
Walter
How can I disable the automatic loading of the mods that are already there. I want to delete them because they are showing errors, a lot and the one that give you the coordinates of the block you broke is kind of annoying lol
Hi,
I just moved from mineos+ craftbukkit-1.5.1-R0.1 to freebsd running craftbukkit-1.5.2-R0.1 On the old server everything was working fine but now the plugin stopped working generating the following error right after creating the js-plugins folder with succes:
Freebsd does have a different file structure than mineos+ but the js-plugins folder is created in the right place and when restarting the server the plugin is not trying to create the js-plugins folder again.
Regards Werner
<<reply 1358689="">>
Hi Cherbert, I've added a http.request() function to ScriptCraft. See https://github.com/walterhiggins/ScriptCraft/blob/master/docs/api.md#httprequest-function
Perfect. Just the thing i'm looking for. Actually most plugin on bukkit could've been written in the javascript which way more flexible in writing and deploying. But debugging an embedded js is always a pain in the b.
Thanks for the fast replies but no offence, if I understood Java I wouldn't be using ScriptCraft. Can you possibly post a quick usage example in ScriptCraft/Javascript?
<<reply 1358608="">>
@cherbert, sure - use the java.net classes to post and request over HTTP. see http://docs.oracle.com/javase/tutorial/networking/urls/readingWriting.html
Since XMLHttpRequest isn't available is there any way you can make available functions to post and get data from a remote PHP server?
Unless there is another way that can be made to store and retrieve data from MySQL if we so desired? This would really open up huge possibilities for me.
Also there seems to be a problem using color codes using sendMessage(). The color change happens ok but I get a wierd Á character against every color change in the text output.
<<reply 1357555="">>
Hi ,
To add money to your own account...
/js self.performCommand("money -g {your-name} 100");
You can use the Player.performCommand() method to perform any command available to players. e.g. Assuming there's a player called 'JohnDoe' connected...
var johnDoe = server.getPlayer("JohnDoe");
johnDoe.performCommand("money -g {name-of-player-to-give-money-to} 50");
<<reply 1357555="">>
Good Question! I'll do some digging and see if iConomy has an API.
Is there any example anywhere of adding/deducting money from a players iConomy account? Is this even possible using ScriptCraft?
I have only just discovered this wonderful plugin!
@cadika_orade
Hi @cadika_oracle,
I'm not sure that dev.bukkit.org supports forum-type pages. There is a google group for this plugin ...
https://groups.google.com/forum/?fromgroups#!forum/scriptcraft---scripting-minecraft
If there's a way for plugin-authors to set up forums for their plugins here, I haven't found it. Any pointers?
Walter
Love this plugin. Could the Author add a forum page here so that users can exchange scripts and discuss the possibilities for new scripts?
Also, if it possible to make a terrain generator with this?
@victor2748
No, but you can probably use any in-game sound you need.
WoW *_*