Last active
August 2, 2016 05:42
-
-
Save lachlandcp/ce90e42bea033213a232b648779d87e9 to your computer and use it in GitHub Desktop.
This file contains 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
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