From 3087845f1ee178376d1c2ffbf0e669ba407cdfdb Mon Sep 17 00:00:00 2001 From: bushtail Date: Mon, 14 Aug 2023 23:32:52 -0400 Subject: [PATCH] ValUAdd Plugin --- .../src/main/kotlin/ValUAdd/plugin.kt | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 plugin-playground/src/main/kotlin/ValUAdd/plugin.kt diff --git a/plugin-playground/src/main/kotlin/ValUAdd/plugin.kt b/plugin-playground/src/main/kotlin/ValUAdd/plugin.kt new file mode 100644 index 0000000..23fc614 --- /dev/null +++ b/plugin-playground/src/main/kotlin/ValUAdd/plugin.kt @@ -0,0 +1,31 @@ +package ValUAdd + +import plugin.Plugin +import plugin.annotations.PluginMeta +import plugin.api.API.SendMessage +import rt4.Inv +import rt4.ObjTypeList +import kotlin.math.round + +@PluginMeta ( + author = "bushtail", + description = "Quickly tally the value of your inventory with a command.", + version = 1.0 +) +class plugin : Plugin() { + override fun ProcessCommand(commandStr: String, args: Array?) { + when(commandStr.toLowerCase()) { + "::valuadd" -> { + var value = 0 + val inventory = Inv.objectContainerCache.get(93) as Inv + for(i in inventory.objectIds) { + if(i != -1) { + val obj = ObjTypeList.get(i) + value += round(obj.cost * 0.6).toInt() + } + } + SendMessage("Total HA value of inventory: $value GP") + } + } + } +} \ No newline at end of file