Skip to content

Functions and If statements

Lawrence G edited this page May 24, 2016 · 1 revision

Functions

  • eatHook()
    • Called whenever a player eats a specific item
  • useItem()
    • Adds a function to any item/block.
      • Example: function useItem(x, y, z, itemId, blockId, side)
  • modTick()
    • Launches a specific function every second(20Ticks)
      • Example: `function modTick()

If Statements

Called after every function

Example:

if(operand0 == operand1){
  // code when the two operands are equal
}

Both Examples used together

var lowhealth = 0;
function modTick() {
  if(Player.getHealth() == 1 && lowhealth == 0) {
    lowhealth = 1;
    clientMessage("ur gonna die skrub");
  }
  else if(Player.getHealth() == 0 && lowhealth == 1) {
    lowhealth = 0;
    clientMessage("DID U EVEN LISTEN?!");
  }
}