Functions

plain helper functions

function addTax(price, rate) {
    return price + (price * rate)
}

you can call them like anything else:

val total = addTax(100, 0.1) // 110

two special kinds of functions: commands and listeners

adding @Katton.command(...) or @Katton.listen(...) above a function changes what parameters it's allowed to have and makes it runnable/triggerable from outside the script:

@Katton.command(name = "heal", permission = "admin")
function healSender(sender, args) { // MUST be exactly (sender, args)
    sender.health = 20
}

@Katton.listen("player_death")
function onDeath(event) { // MUST be exactly (event)
    event.player.sendMessage("&cyou died!")
}