Skip to content

Instantly share code, notes, and snippets.

grammar Jsonnet;
jsonnet
: expr EOF
;
expr
: value=(NULL | TRUE | FALSE | SELF | DOLLAR | STRING | NUMBER ) # Value
| '(' expr ')' # Parens
| '{' objinside? '}' # Object
// Fill the empty space with the minimum number of rectangles.
// The grid size is 1 meter, but the smallest wall/floor tile is 4 meters.
// If you can do better than one rectangle for every tile, let us know!
// We'll help you find a programming job (if you want one).
// Check the guide for more info, and press Contact below to report success.
var ar = this.addRect;
var tileSize = 4;
function draw(x, y, w, h) {
@ironchefpython
ironchefpython / post-install.sh
Last active December 17, 2015 18:29
Cloud 9 Meteor post-install script
if ! grep meteor ~/.bashrc; then
echo export PATH=$PATH:~/.meteor >> ~/.bashrc
fi
for SCRIPT in meteor.js mongo_runner.js run.js server/server.js; do
chmod 644 ~/.meteor/tools/latest/tools/$SCRIPT
curl https://raw.github.com/ironchefpython/meteor/master/tools/$SCRIPT > ~/.meteor/tools/latest/tools/$SCRIPT
chmod 444 ~/.meteor/tools/latest/tools/$SCRIPT
done

Event Architecture

Events are the primary mechanism for initiating and handling actions in Terasology. Events can be generated by keyboard or mouse input, by console commands or interacting with UI elements, by the game world through collisions or npc actions, or on-demand by mods. When Systems register to handle events, they can access properties of the event, as well call methods to cancel or consume the event.

var factions = {}
var Faction = manager.registerPrototype({
"properties": {
"name": manager.StringType,
"description": manager.StringType(function() {return this =! "" && this.length <=25;}),
"members": manager.CollectionType(manager.getPrototype("player"))
}
"listeners" {
"load": function(event) {
var fallingDamageSpeedThreshold = 20;
var excessSpeedDamageMultiplier = 10;
var FULL_HEALTH_EVENT = manager.getEvent("full_health");
var NO_HEALTH_EVENT = manager.getEvent("no_health");
var applyDamage = function(entity, amount, instigator) {
if (this.currentHealth <= 0) {
return;
}
@ironchefpython
ironchefpython / mod.js
Created April 23, 2012 15:19
Sample tool definition
game.modManager.registerEvent({
"type": "custom",
"properties": {"foo": game.modManager.StringType }
});
game.addEventListener("custom", function(event) { console.log(event.get("foo")); });
game.eventManager.propogateEvent("custom", {"foo": "bar"});
var mm = game.modManager;
// Add a cubbyhole to represent the head equipment slot associated with the
// player
var headCub = game.createCubbyhole();
// adding the new cubbyhole to the player assigns the contents of the cubbyhole
// to the player for ownership purposes
player.addCubbyhole(headCub);
// Add an event handler that fires when an item is dropped into this cubbyhole
headCub.addEvent("drop", function(item) {
var mod = mm.defineMod("My Mod", {
description: "An awesome mod.",
author: "AlbireoX",
revision: 1,
url: "http://simplyian.com"
});
var ore = mod.addOre("main-ore", {
texture: "http://example.com/sampletexture.png",
itemtexture: "http://example.com/sampletexture-item.png"

###MockEngine.java

package org.terasology.rhinodemo;

import org.mozilla.javascript.*;
import org.w3c.dom.events.EventTarget;

public class MockEngine {
	Context cx;
	Scriptable scope;