mirror of
https://gitlab.com/2009scape/contributor-wiki.git
synced 2026-08-01 14:19:13 -06:00
Update ContentAPI
This commit is contained in:
parent
6c2fa226a7
commit
3100dfd7d9
1 changed files with 18 additions and 1 deletions
|
|
@ -10,4 +10,21 @@ import api.*
|
|||
|
||||
All of the methods are documented and globally accessible. You can use the methods by simply typing their name, e.g. `sendMessage(player, "Bababooey")`.
|
||||
|
||||
It's very important that you read the documentation for the methods you use and attempt to understand them.
|
||||
It's very important that you read the documentation for the methods you use and attempt to understand them.
|
||||
|
||||
Here's an example of a [listener](writing-listeners) that uses the ContentAPI:
|
||||
|
||||
```kt
|
||||
override fun defineListeners() {
|
||||
onUseWith(IntType.ITEM, evilTurnip, knife) { player, used, with ->
|
||||
if(removeItem(player, used.asItem())) {
|
||||
sendMessage(player, "You carve a scary face into the evil turnip.")
|
||||
sendMessage(player, "Wooo! It's enough to give you nightmares.")
|
||||
return@onUseWith addItem(player, carvedEvilTurnip)
|
||||
}
|
||||
return@onUseWith false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
In this example, `sendMessage`, `removeItem` are both ContentAPI methods.
|
||||
Loading…
Add table
Add a link
Reference in a new issue