Skip to content

Instantly share code, notes, and snippets.

View cow-clicker.js
// 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)
View Pixenate-on-Ubuntu.md

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 Aug 29, 2015
A hypothetical server-side javascript blog-making file.
View make-blog.js
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 = [];
View node-auth.js
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 Aug 29, 2015
Trying to call an overloaded constructor with vararg parameters.
View varargs-overloaded-constructor.js
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 Apr 7, 2017
Tutorial World for ScriptCraft
View tutorial-world.js
// 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 Jan 31, 2015
Initialization file for use in modding workshop on student servers
View init.js
'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 Aug 29, 2015
Javascript Code to make Players bounce when they step on sponge
View boing.js
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 Aug 29, 2015
Updated arduino-light code
View arduino-light.js
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 Aug 29, 2015
A Minecraft Trampoline (Version 2)
View trampoline.js
/*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;