From 92f4c7daf5da525b27d946b65108a7ea6d3fa2c6 Mon Sep 17 00:00:00 2001 From: Major- Date: Thu, 6 Mar 2014 18:26:58 +0000 Subject: [PATCH] Add an ::objectinfo command. --- data/plugins/cmd-lookup/lookup.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/data/plugins/cmd-lookup/lookup.rb b/data/plugins/cmd-lookup/lookup.rb index fed1c6ef..48d0fc21 100644 --- a/data/plugins/cmd-lookup/lookup.rb +++ b/data/plugins/cmd-lookup/lookup.rb @@ -1,6 +1,8 @@ require 'java' +java_import 'org.apollo.game.model.Entity' java_import 'org.apollo.game.model.Player' +java_import 'org.apollo.game.model.World' java_import 'org.apollo.game.model.def.ItemDefinition' java_import 'org.apollo.game.model.def.NpcDefinition' java_import 'org.apollo.game.model.def.ObjectDefinition' @@ -13,6 +15,7 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command| end type = args.shift.downcase + limit = args.first.to_i != 0 ? args.shift.to_i : 5 name = args.join(' ').downcase if ['npc', 'object', 'item'].index(type) == nil @@ -20,7 +23,7 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command| next end - ids = locate_entity(type, name).join(', ') + ids = locate_entity(type, name, limit).join(', ') message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids}." player.send_message(message) @@ -56,4 +59,17 @@ on :command, :npcinfo, RIGHTS_ADMIN do |player, command| is_combative = definition.has_combat_level ? "has a combat level of #{definition.combat_level}" : "does not have a combat level" player.send_message("Npc #{id} is called #{definition.name} and #{is_combative}.") player.send_message("Its description is \"#{definition.description}\".") +end + +# Sends the user a message with information about the object with the specified id. +on :command, :objectinfo, RIGHTS_ADMIN do |player, command| + args = command.arguments + unless args.length == 1 + player.send_message('Invalid syntax - ::objectinfo [npc id]') + next + end + + id = args[0].to_i + definition = ObjectDefinition.lookup(id) + player.send_message("Object #{id} is called #{definition.name} and its description is \"#{definition.description}\".") end \ No newline at end of file