diff --git a/docs/api.md b/docs/api.md index 5013298..06a6447 100644 --- a/docs/api.md +++ b/docs/api.md @@ -1166,6 +1166,37 @@ To unregister a listener *outside* of the listener function... [buk2]: http://wiki.bukkit.org/Event_API_Reference [buk]: http://jd.bukkit.org/dev/apidocs/index.html?org/bukkit/event/Event.html +Fireworks Module +================ +The fireworks module makes it easy to create fireworks using +ScriptCraft. The module has a single function `firework` which takes +a `org.bukkit.Location` as its 1 and only parameter. + +Examples +-------- +The module also extends the `Drone` object adding a `firework` method +so that fireworks can be created as a part of a Drone chain. For +Example.... + + /js firework() + +... creates a single firework, while .... + + /js firework.fwd(3).times(5) + +... creates 5 fireworks in a row. Fireworks have also been added as a +possible option for the `arrow` module. To have a firework launch +where an arrow strikes... + + /js arrows.firework() + +To call the fireworks.firework() function directly, you must provide a +location. For example... + + /js fireworks.firework(self.location); + +![firework example][img/firework.png) + http.request() function ==================== The http.request() function will fetch a web address asynchronously (on a diff --git a/docs/img/firework.png b/docs/img/firework.png new file mode 100644 index 0000000..67a0a8c Binary files /dev/null and b/docs/img/firework.png differ diff --git a/src/main/javascript/fireworks/fireworks.js b/src/main/javascript/fireworks/fireworks.js index 67e531c..52abd9b 100644 --- a/src/main/javascript/fireworks/fireworks.js +++ b/src/main/javascript/fireworks/fireworks.js @@ -1,3 +1,36 @@ +/************************************************************************ +Fireworks Module +================ +The fireworks module makes it easy to create fireworks using +ScriptCraft. The module has a single function `firework` which takes +a `org.bukkit.Location` as its 1 and only parameter. + +Examples +-------- +The module also extends the `Drone` object adding a `firework` method +so that fireworks can be created as a part of a Drone chain. For +Example.... + + /js firework() + +... creates a single firework, while .... + + /js firework.fwd(3).times(5) + +... creates 5 fireworks in a row. Fireworks have also been added as a +possible option for the `arrow` module. To have a firework launch +where an arrow strikes... + + /js arrows.firework() + +To call the fireworks.firework() function directly, you must provide a +location. For example... + + /js fireworks.firework(self.location); + +![firework example][img/firework.png) + +***/ plugin("fireworks", { /* create a firework at the given location @@ -31,9 +64,9 @@ plugin("fireworks", { var c1 = getColor(r1i); var c2 = getColor(r2i); var effectBuilder = FireworkEffect.builder() - .flicker(true) + .flicker(Math.round(Math.random()==0) .withColor(c1) - .withFade(c2).trail(true); + .withFade(c2).trail(Math.round(Math.random()==0); effectBuilder['with'](type); var effect = effectBuilder.build(); fwm.addEffect(effect);