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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
grammar Jsonnet; | |
jsonnet | |
: expr EOF | |
; | |
expr | |
: value=(NULL | TRUE | FALSE | SELF | DOLLAR | STRING | NUMBER ) # Value | |
| '(' expr ')' # Parens | |
| '{' objinside? '}' # Object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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;
NewerOlder