Skip to content

Instantly share code, notes, and snippets.

@ironchefpython
Created May 8, 2012 03:02
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 ironchefpython/2632233 to your computer and use it in GitHub Desktop.
Save ironchefpython/2632233 to your computer and use it in GitHub Desktop.
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) {
factions[this.name] = this;
},
"init": function(event) {
newFaction = game.createEntity(Faction, {
name: "TheForgotten",
description: "The forgotten people of middle earth.",
members: [game.getPlayer("tim")]
});
var otherFaction = factions["Blah"];
newFaction.name = "Foo" ;
game.deleteEntity(newFaction);
},
"console": function(event) {
if (event.command.indexOf("list") === 0) {
console.log("listing factions");
} else if (event.command.indexOf("add") === 0) {
console.log("adding faction");
<code to parse command and make a new faction>
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment