Kaelozim
09-29-2010, 12:14 AM
Ok, so I took Tillmen's npcpick script and modified it to use PC picker, and I know there is a few things that need to be done with the code but my problem is that I can't get the thing to run at all I've downloaded a variety of ruby editors to try and use some error-checking features but I can't seem to figure it out. All of my brackets are closed and I've ended all my evaluations. If someone could skim through this and maybe help me out it would be greatly appreciated. I've tried making various other scripts and it always seems to end this way. Anyway heres the code:
close_lootsack = false
junk_nouns = [ 'lockpick', 'doughnut', 'tart', 'cupcake', 'ribbon', 'cookie', 'horseshoe', 'muffin' ]
junk_regex = /^(?:scratched|corroded|polished|shiny|tarnished|de nted|rusty|bent) (?:ring|medallion|earring|anklet|bracelet|fork|spo on|plate|coin|cup|nail|doorknob)$|^smooth stone$|^steel shield$|^some tree bark$|^table leg$|^moldy bone$|^some tattered cloth$|^piece of iron$|^chipped brick$|^scratched steel helm$/
disk = GameObj.loot.find { |obj| obj.name =~ /#{Char.name} disk$/ }
if UserVars.lootsack.nil? or UserVars.lootsack.empty?
echo 'error: lootsack is not set (;set change lootsack <container>)'
exit
end
unless lootsack = GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.lootsack.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.lootsack).sub(' ', ' .*')}/i }
echo "error: unable to find your lootsack #{UserVars.lootsack} in your inventory"
exit
end
if lootsack.contents.nil?
open_result = dothis "open ##{lootsack.id}", /You open|already open/
close_lootsack = true if open_result =~ /You open/
if lootsack.contents.nil?
dothis "look in ##{lootsack.id}", /In the .* you see/
if lootsack.contents.nil?
echo 'fixme (1)'
exit
end
end
end
unless (GameObj.right_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/) or (GameObj.left_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/) or lootsack.contents.find { |obj| obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/ }
if disk and disk.contents.nil?
dothistimeout "look in ##{disk.id}", 2, /^In the|^There is nothing in there\.$/
end
unless disk.contents.any? { |obj| obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/ }
echo 'no boxes'
exit
end
end
start_script 'go2name', [ 'Ledron', '_disable_confirm_' ]
wait_while { running?('go2') }
empty_hands
unless trash = (GameObj.room_desc.to_a + GameObj.loot.to_a).find { |obj| obj.noun =~ /^(?:crate|barrel|wastebarrel|casket)$/ } || trash = (GameObj.room_desc.to_a + GameObj.loot.to_a).find { |obj| obj.noun == 'coffer' }
echo 'warning: failed to find a trash container'
end
open_box = proc { |box|
unless (GameObj.right_hand.id == box.id) or (GameObj.left_hand.id == box.id)
dothistimeout "get ##{box.id}", 3, /^You remove|^Get what\?$/
end
if (GameObj.right_hand.id == box.id) or (GameObj.left_hand.id == box.id)
put_result = dothistimeout "give ##{box.id} to Ledron", 5, /^You offer|^Your .*? won't fit on .*?\.$/
end
put_result = dothistimeout "give ##{box.id} to Ledron", 5, /^You put|^Your .*? won't fit on .*?\.$/
end
}
if GameObj.right_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(GameObj.right_hand)
end
if GameObj.left_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(GameObj.left_hand)
end
for obj in lootsack.contents
if obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(obj)
end
end
if disk
50.times { break if GameObj.loot.any? { |obj| obj.id == disk.id }; sleep 0.1 }
if GameObj.loot.any? { |obj| obj.id == disk.id }
if disk.contents.nil?
dothistimeout "look in ##{disk.id}", 2, /^In the|^There is nothing in there\.$/
end
for obj in disk.contents
if obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(obj)
end
end
end
end
fill_hands
fput "close ##{lootsack.id}" if close_lootsack
close_lootsack = false
junk_nouns = [ 'lockpick', 'doughnut', 'tart', 'cupcake', 'ribbon', 'cookie', 'horseshoe', 'muffin' ]
junk_regex = /^(?:scratched|corroded|polished|shiny|tarnished|de nted|rusty|bent) (?:ring|medallion|earring|anklet|bracelet|fork|spo on|plate|coin|cup|nail|doorknob)$|^smooth stone$|^steel shield$|^some tree bark$|^table leg$|^moldy bone$|^some tattered cloth$|^piece of iron$|^chipped brick$|^scratched steel helm$/
disk = GameObj.loot.find { |obj| obj.name =~ /#{Char.name} disk$/ }
if UserVars.lootsack.nil? or UserVars.lootsack.empty?
echo 'error: lootsack is not set (;set change lootsack <container>)'
exit
end
unless lootsack = GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.lootsack.strip)}/i } || GameObj.inv.find { |obj| obj.name =~ /#{Regexp.escape(UserVars.lootsack).sub(' ', ' .*')}/i }
echo "error: unable to find your lootsack #{UserVars.lootsack} in your inventory"
exit
end
if lootsack.contents.nil?
open_result = dothis "open ##{lootsack.id}", /You open|already open/
close_lootsack = true if open_result =~ /You open/
if lootsack.contents.nil?
dothis "look in ##{lootsack.id}", /In the .* you see/
if lootsack.contents.nil?
echo 'fixme (1)'
exit
end
end
end
unless (GameObj.right_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/) or (GameObj.left_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/) or lootsack.contents.find { |obj| obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/ }
if disk and disk.contents.nil?
dothistimeout "look in ##{disk.id}", 2, /^In the|^There is nothing in there\.$/
end
unless disk.contents.any? { |obj| obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/ }
echo 'no boxes'
exit
end
end
start_script 'go2name', [ 'Ledron', '_disable_confirm_' ]
wait_while { running?('go2') }
empty_hands
unless trash = (GameObj.room_desc.to_a + GameObj.loot.to_a).find { |obj| obj.noun =~ /^(?:crate|barrel|wastebarrel|casket)$/ } || trash = (GameObj.room_desc.to_a + GameObj.loot.to_a).find { |obj| obj.noun == 'coffer' }
echo 'warning: failed to find a trash container'
end
open_box = proc { |box|
unless (GameObj.right_hand.id == box.id) or (GameObj.left_hand.id == box.id)
dothistimeout "get ##{box.id}", 3, /^You remove|^Get what\?$/
end
if (GameObj.right_hand.id == box.id) or (GameObj.left_hand.id == box.id)
put_result = dothistimeout "give ##{box.id} to Ledron", 5, /^You offer|^Your .*? won't fit on .*?\.$/
end
put_result = dothistimeout "give ##{box.id} to Ledron", 5, /^You put|^Your .*? won't fit on .*?\.$/
end
}
if GameObj.right_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(GameObj.right_hand)
end
if GameObj.left_hand.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(GameObj.left_hand)
end
for obj in lootsack.contents
if obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(obj)
end
end
if disk
50.times { break if GameObj.loot.any? { |obj| obj.id == disk.id }; sleep 0.1 }
if GameObj.loot.any? { |obj| obj.id == disk.id }
if disk.contents.nil?
dothistimeout "look in ##{disk.id}", 2, /^In the|^There is nothing in there\.$/
end
for obj in disk.contents
if obj.noun =~ /^(?:box|strongbox|chest|coffer|trunk)$/
open_box.call(obj)
end
end
end
end
fill_hands
fput "close ##{lootsack.id}" if close_lootsack