cmd_rlist.rb
znmud-0.0.1/cmd/zombie/cmd_rlist.rb · 966 B
From the archive znmud-minimal-0.0.1.tar.gz
Download the archive « Back to the archive contents
#
# file:: cmd_rlist.rb
# This source code copyright (C) 2009 Craig Smith
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#
module Cmd
# List rooms around player or in a certain range
def cmd_rlist(args)
low = 0
high = 100
case args
when /^(\d+)$/ # Around one number
low = $1.to_i - 100
high = $1.to_i + 100
low = 0 if low < 0
when /(\d+)-(\d+)/ # Range of IDs
low = $1.to_i
high = $2.to_i
when /(.*)/ # find a room with a set word in it
high = 0
rooms = world.find_rooms($1)
rooms.each do | r |
sendto(" [#{r.id}] - #{r.name}")
end
else
low = location - 100
high = location + 100
low = 0 if low < 0
end
if high > low
(low..high).each do |id|
begin
r = get_object(id)
if r
sendto(" [#{id}] - #{r.name}") if r.is_a? Room
end
end
end
end
end
end