filler

Golden Apple

Gives Regen 3 for 7 seconds and a 20 hp shield upon consumption

← Back to main

Code Block:


api.giveItem(myId, "Gold Watermelon Slice", 1, {
  customDisplayName: "Golden Apple"
});
function onPlayerFinishChargingItemGap(playerId, used, itemName, duration){
  if (used === true && itemName === "Gold Watermelon Slice"){
    api.applyHealthChange(playerId, 20)
    api.setShieldAmount(playerId, 20)
    api.removeEffect(playerId, "Jump Boost")
    if (api.getEffects(playerId).includes("Health Regen")){
      api.applyEffect(playerId, "Stackable Regen", 7000, {icon: "Red Concrete"})
    } else{
      api.applyEffect(playerId, "Health Regen", 7000, {inbuiltLevel: 2})
    }
  }
}
      

World Code:



onPlayerFinishChargingItem = (pId, use, item, dura) => {
  onPlayerFinishChargingItemGap(pId, use, item, dura)
}

let tickCounter = 0

tick = () => {
  tickCounter++

  if (tickCounter % 20 === 0) {
    let playerIds = api.getPlayerIds()

    for (let playerId of playerIds) {
      let health = api.getHealth(playerId)
      if (health === null) continue
      if (tickCounter % 20 === 0) {
        let effects = api.getEffects(playerId)
        if (effects.includes("Stackable Regen")) {
          api.applyHealthChange(playerId, 7, playerId)
        }
      }
    }
    if (tickCounter >= 20) tickCounter = 0
  }
}