wizgem3
10-18-2011, 05:11 PM
Anyone know why i'm getting this error?
>;scrolls sack
--- Lich: scrolls active.
[scrolls]>open sack
That is already open.
>
[scrolls]>look in sack
--- Lich: DownstreamHook: wrong number of arguments (1 for 2)
scrolls:44:in `gsub!'
In the large sack you see a sheet of faded vellum, a piece of dark paper, a sheaf of light paper, a piece of dark paper, a tattered scroll, an aged scroll, a smeared scroll, a charred scroll, a charred scroll, an aged scroll, a burnt scroll, a neatly inked scroll, an obscure scroll, a scorched scroll, a golden scroll, a glowing scroll, a tattered palimpsest, a silvery palimpsest, a wrinkled scroll, an old scroll, a crumpled scroll, a glowing scroll, a scorched scroll, a torn parchment, a pure white parchment, a glowing scroll and a large leather tome.
=begin
Read all of the scrolls in the specified container and provide a summary of all
the spells on those scrolls. WARNING: Generates a lot of screen scroll.
Current revision: 2009.12.23.01
=end
# -----------------------------------------------------------------------------
# Author: Jymamon (gs4-jymamon@hotmail.com)
#
# History:
# 2009.12.23.01 Initial version.
# -----------------------------------------------------------------------------
script.want_downstream_xml = true # Raw input wanted as we parse it for IDs
# Remove the hook on shutdown.
before_dying {
DownstreamHook.remove('AnalyzeScrollsHook')
}
# -----------------------------------------------------------------------------
# Get the name of the container from the command line
# -----------------------------------------------------------------------------
script.vars.shift
lookin = script.vars.shift
# -----------------------------------------------------------------------------
# Setup some variabples
# -----------------------------------------------------------------------------
$scrolls = Array.new
$spells = Hash.new
$container = String.new
$spell_count = 0
$scroll_count = 0
# -----------------------------------------------------------------------------
# Hook to get IDs of all items inside the named container and to capture the
# container's ID for later use.
# -----------------------------------------------------------------------------
done = false
action = proc { |line|
if line =~ /In the <a exist="(\d+)" noun=.* you see/i
$container = $1.to_s
cp_line = line
cp_line.gsub!(/In the .* you see/i)
cp_line.split(/<a/).each { |entry|
entry =~ /exist="([0-9]+)"/i
$scrolls.push($1)
$scroll_count += 1
}
done = true
DownstreamHook.remove('AnalyzeScrollsHook')
end
line
}
fput "open " + lookin
# -----------------------------------------------------------------------------
# Use the hook and wait for it to finish
# -----------------------------------------------------------------------------
DownstreamHook.add('AnalyzeScrollsHook', action)
fput "look in " + lookin
wait_until { done }
# -----------------------------------------------------------------------------
# Hook to capture the spells on each scroll.
# -----------------------------------------------------------------------------
done = false
action = proc { |line|
matchstring = "You close .* exist=\"" + $container.to_s + "\""
if line =~ /\((\d+)\) .* exist=\"(\d+)\"/i
if $spells[$1.to_s].nil?
$spells[$1.to_s] = Array.new
end
$spells[$1.to_s].push($2.to_s)
$spell_count += 1
nil
elsif line =~ /#{matchstring}/i
DownstreamHook.remove('AnalyzeScrollsHook')
done = true
line
elsif line =~ /You pull your .* closed at the neck/i
DownstreamHook.remove('AnalyzeScrollsHook')
done = true
line
else
line
end
}
# -----------------------------------------------------------------------------
# Use the hook and wait for it to finish
# -----------------------------------------------------------------------------
DownstreamHook.add('AnalyzeScrollsHook', action)
$scrolls.each { |id|
fput "read #" + id.to_s if (id.nil!)
}
fput "close #" + $container.to_s
wait_until { done }
# -----------------------------------------------------------------------------
# Now, process the results.
# -----------------------------------------------------------------------------
$spells.keys.sort{|x,y| x.to_i <=> y.to_i}.index { |spell|
respond sprintf("%4d is on %d scrolls.", spell.to_i, $spells[spell].length.to_i)
}
respond $spell_count.to_s + " total spells on " + $scroll_count.to_s + " total scrolls."
>;scrolls sack
--- Lich: scrolls active.
[scrolls]>open sack
That is already open.
>
[scrolls]>look in sack
--- Lich: DownstreamHook: wrong number of arguments (1 for 2)
scrolls:44:in `gsub!'
In the large sack you see a sheet of faded vellum, a piece of dark paper, a sheaf of light paper, a piece of dark paper, a tattered scroll, an aged scroll, a smeared scroll, a charred scroll, a charred scroll, an aged scroll, a burnt scroll, a neatly inked scroll, an obscure scroll, a scorched scroll, a golden scroll, a glowing scroll, a tattered palimpsest, a silvery palimpsest, a wrinkled scroll, an old scroll, a crumpled scroll, a glowing scroll, a scorched scroll, a torn parchment, a pure white parchment, a glowing scroll and a large leather tome.
=begin
Read all of the scrolls in the specified container and provide a summary of all
the spells on those scrolls. WARNING: Generates a lot of screen scroll.
Current revision: 2009.12.23.01
=end
# -----------------------------------------------------------------------------
# Author: Jymamon (gs4-jymamon@hotmail.com)
#
# History:
# 2009.12.23.01 Initial version.
# -----------------------------------------------------------------------------
script.want_downstream_xml = true # Raw input wanted as we parse it for IDs
# Remove the hook on shutdown.
before_dying {
DownstreamHook.remove('AnalyzeScrollsHook')
}
# -----------------------------------------------------------------------------
# Get the name of the container from the command line
# -----------------------------------------------------------------------------
script.vars.shift
lookin = script.vars.shift
# -----------------------------------------------------------------------------
# Setup some variabples
# -----------------------------------------------------------------------------
$scrolls = Array.new
$spells = Hash.new
$container = String.new
$spell_count = 0
$scroll_count = 0
# -----------------------------------------------------------------------------
# Hook to get IDs of all items inside the named container and to capture the
# container's ID for later use.
# -----------------------------------------------------------------------------
done = false
action = proc { |line|
if line =~ /In the <a exist="(\d+)" noun=.* you see/i
$container = $1.to_s
cp_line = line
cp_line.gsub!(/In the .* you see/i)
cp_line.split(/<a/).each { |entry|
entry =~ /exist="([0-9]+)"/i
$scrolls.push($1)
$scroll_count += 1
}
done = true
DownstreamHook.remove('AnalyzeScrollsHook')
end
line
}
fput "open " + lookin
# -----------------------------------------------------------------------------
# Use the hook and wait for it to finish
# -----------------------------------------------------------------------------
DownstreamHook.add('AnalyzeScrollsHook', action)
fput "look in " + lookin
wait_until { done }
# -----------------------------------------------------------------------------
# Hook to capture the spells on each scroll.
# -----------------------------------------------------------------------------
done = false
action = proc { |line|
matchstring = "You close .* exist=\"" + $container.to_s + "\""
if line =~ /\((\d+)\) .* exist=\"(\d+)\"/i
if $spells[$1.to_s].nil?
$spells[$1.to_s] = Array.new
end
$spells[$1.to_s].push($2.to_s)
$spell_count += 1
nil
elsif line =~ /#{matchstring}/i
DownstreamHook.remove('AnalyzeScrollsHook')
done = true
line
elsif line =~ /You pull your .* closed at the neck/i
DownstreamHook.remove('AnalyzeScrollsHook')
done = true
line
else
line
end
}
# -----------------------------------------------------------------------------
# Use the hook and wait for it to finish
# -----------------------------------------------------------------------------
DownstreamHook.add('AnalyzeScrollsHook', action)
$scrolls.each { |id|
fput "read #" + id.to_s if (id.nil!)
}
fput "close #" + $container.to_s
wait_until { done }
# -----------------------------------------------------------------------------
# Now, process the results.
# -----------------------------------------------------------------------------
$spells.keys.sort{|x,y| x.to_i <=> y.to_i}.index { |spell|
respond sprintf("%4d is on %d scrolls.", spell.to_i, $spells[spell].length.to_i)
}
respond $spell_count.to_s + " total spells on " + $scroll_count.to_s + " total scrolls."