# functions

### plain helper functions

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

you can call them like anything else:

```csharp
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:

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

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