mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 16:51:37 +00:00
Format.
This commit is contained in:
@@ -20,12 +20,13 @@ on :command, :lookup, RIGHTS_ADMIN do |player, command|
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
ids = locate_entity(type, name)
|
ids = locate_entity(type, name).join(" ")
|
||||||
|
|
||||||
message = ids.length == 0 ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids.join(" ")}"
|
message = ids.empty? ? "Could not find an #{type} called #{name}." : "Possible ids are: #{ids}"
|
||||||
player.send_message(message)
|
player.send_message(message)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sends the user a message with information about the item with the specified id.
|
||||||
on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
|
on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
unless args.length == 1
|
||||||
@@ -41,6 +42,7 @@ on :command, :iteminfo, RIGHTS_ADMIN do |player, command|
|
|||||||
player.send_message("Its description is \"#{definition.description}\".")
|
player.send_message("Its description is \"#{definition.description}\".")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Sends the user a message with information about the npc with the specified id.
|
||||||
on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
|
on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
|
||||||
args = command.arguments
|
args = command.arguments
|
||||||
unless args.length == 1
|
unless args.length == 1
|
||||||
@@ -57,14 +59,12 @@ on :command, :npcinfo, RIGHTS_ADMIN do |player, command|
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Locates an entity with the specified type (e.g. npc) and name, returning possible ids as an array.
|
# Locates an entity with the specified type (e.g. npc) and name, returning possible ids as an array.
|
||||||
def locate_entity(type, name, immediate=false)
|
def locate_entity(type, name, limit=5)
|
||||||
ids = []
|
ids = []
|
||||||
name.downcase!
|
name.downcase!
|
||||||
Kernel.const_get("#{type.capitalize}Definition").definitions.each do |definition|
|
Kernel.const_get("#{type.capitalize}Definition").definitions.each do |definition|
|
||||||
if definition.name.to_s.downcase == name
|
break if ids.length == limit
|
||||||
ids << definition.id
|
ids << definition.id.to_i if definition.name.to_s.downcase == name
|
||||||
return ids[0] if immediate
|
|
||||||
return ids if ids.length == 10
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
return ids
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user