Skip to content

Instantly share code, notes, and snippets.

// cow-clicker is a minecraft mini-game written in javascript.
// depends on the ScriptCraft Bukkit plugin http://github.com/walterhiggins/ScriptCraft
// see http://www.bogost.com/games/cow_clicker.shtml
var Bukkit = org.bukkit.Bukkit;
var players = {};
var playerCount = 0;
var sb = function(cmd){
Bukkit.dispatchCommand(server.consoleSender, 'scoreboard ' + cmd)

Installing Pixenate on Ubuntu

sudo apt-get update   
sudo apt-get install make  
sudo apt-get install apache2  
sudo apt-get install imagemagick  
sudo apt-get install perlmagick   
sudo apt-get install emacs23  
sudo apt-get install libwww-perl  

sudo apt-get install dos2unix

@walterhiggins
walterhiggins / make-blog.js
Last active August 29, 2015 13:55
A hypothetical server-side javascript blog-making file.
var fs = require('fs'),
_ = require('underscore'),
markdown = require('markdown').markdown,
tinymake = require('tinymake');
// all posts are .md (markdown files)
var posts = _.filter(fs.readDirSync('posts'), function(name){
return name.match(/\.md$/)
});
var pages = [];
var username, password, creds;
var challenge = function( res ) {
res.writeHead( 401, { 'WWW-Authenticate': 'Basic realm="Acme Web Application"'} );
res.end();
};
if ( req.headers.authorization ) {
creds = new Buffer(req.headers.authorization.split(' ')[1], 'base64').toString('utf8').split(':');
username = creds[0];
password = creds[1];
// authenticate here
@walterhiggins
walterhiggins / varargs-overloaded-constructor.js
Last active August 29, 2015 14:07
Trying to call an overloaded constructor with vararg parameters.
var cmRecipe = Packages.net.canarymod.api.recipes.CraftingRecipe;
var cmRecipeRow = Packages.net.canarymod.api.recipes.RecipeRow;
// see https://ci.visualillusionsent.net/job/CanaryLib/javadoc/net/canarymod/api/inventory/recipes/CraftingRecipe.html
var rows = [
new cmRecipeRow("ESW", [ enderPearl, stick, string]),
new cmRecipeRow("SEW", [ stick, enderPearl, string]),
new cmRecipeRow("ESW", [ enderPearl, stick, string])
];
var signature = "(net.canarymod.api.inventory.Item, net.canarymod.api.inventory.recipes.RecipeRow[])";
var enderBowRecipe = new cmRecipe[signature]( enderBow, rows);
@walterhiggins
walterhiggins / tutorial-world.js
Last active April 7, 2017 00:20
Tutorial World for ScriptCraft
// scriptcraft/plugins/tutorial-world.js
/*global echo, require, isOp,setTimeout, persist */
var Drone = require('drone'),
utils = require('utils'),
_ = require('underscore'),
firework = require('fireworks').firework,
blocks = require('blocks');
/*
construct an array of colored blocks to make a
mario-cart-like rainbow road
@walterhiggins
walterhiggins / init.js
Created January 31, 2015 17:28
Initialization file for use in modding workshop on student servers
'use strict';
/*global require, events, server, Packages*/
var slash = require('slash');
slash([
'groupmod permission add visitors canary.world.build',
'groupmod permission add visitors scriptcraft.evaluate'
],server);
/*
WARNING: The following code makes all players ops.
Only use this for local servers .
@walterhiggins
walterhiggins / boing.js
Last active August 29, 2015 14:15
Javascript Code to make Players bounce when they step on sponge
function bounceOnSponge(event){
var player = event.player;
var location = player.location;
// need to convert coordinates to integers
var x = Math.floor(location.x);
var y = Math.floor(location.y - 1 ); // what's underfoot?
var z = Math.floor(location.z);
var block = location.world.getBlockAt(x, y, z);
if (block.typeId === blocks.sponge){
player.motionY = 2; // springs player high into air
@walterhiggins
walterhiggins / arduino-light.js
Last active August 29, 2015 14:15
Updated arduino-light code
var mqtt = require('sc-mqtt'),
slash = require('slash'),
client = mqtt.client('tcp://localhost:1883','sc-ard-light'),
preDawn = 22000,
JavaString = java.lang.String;
client.connect();
client.subscribe('arduino-light');
var max = 0;
function updateTime(topic, message){
@walterhiggins
walterhiggins / trampoline.js
Last active August 29, 2015 14:15
A Minecraft Trampoline (Version 2)
/*global require, events */
var blocks = require('blocks'),
sounds = require('sounds');
var bouncers = {};
function bounceOn___(event){
var player = event.player;
var id = player.ID;
var bounce = bouncers[id] || 0.75; // get bounciness (default 0.75)
var location = player.location;