Skip to content

Instantly share code, notes, and snippets.

@jhuckaby
Last active January 1, 2016 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhuckaby/8175404 to your computer and use it in GitHub Desktop.
Save jhuckaby/8175404 to your computer and use it in GitHub Desktop.
Minecraft Bukkit ScriptCraft extension for setting sign text on already placed signs. Usage: /js setsigntext(X, Y, Z, ["Hello", "There", "Line 3", "Line 4"]); Install to the ScriptCraft drone/contrib/ folder and restart the server, or type /js refresh(); to reload.
/* Set sign text on an already placed sign. */
/* Specify sign block coordinates and array of strings. */
/* This will currently only work on the main overworld on a server. */
/* Usage: /js setsigntext(-847, 63, 107, ["Hello", "There"]); */
/* Author: Joseph Huckaby, December 29, 2013 */
/* License: Public Domain */
// For ScriptCraft 1.7, uncomment this, I think:
// var Drone = require('../drone').Drone;
Drone.extend("setsigntext", function(x, y, z, texts) {
var world = server.worlds.get(0);
var block = world.getBlockAt(x,y,z);
var state = block.state;
if (state instanceof org.bukkit.block.Sign){
for (var i = 0;i < texts.length; i++)
state.setLine(i%4,texts[i]);
state.update(true);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment