Skip to content

Instantly share code, notes, and snippets.

@lachlandcp
Last active August 2, 2016 05:42
Show Gist options
  • Save lachlandcp/ce90e42bea033213a232b648779d87e9 to your computer and use it in GitHub Desktop.
Save lachlandcp/ce90e42bea033213a232b648779d87e9 to your computer and use it in GitHub Desktop.
function procCmd(cmd) {
if (cmd.toLowerCase() == "kill chicken") {
// 10 refers to the entity TYPE, not an actual entity. It works for spawning entities, but not for referencing them
// We need to cycle through every entity in the world, and kill it if it's a chicken.
var all_entities = Entity.getAll();
var i;
for (i = 0, i < all_entities.length, i++) {
if (Entity.getEntityTypeId(all_entities[i]) == EntityType.CHICKEN) { // EntityType.CHICKEN is the same as 10
Entity.setHealth(all_entities[i], 0);
}
}
clientMessage("Killed " + i + " chickens.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment