PDA

View Full Version : More help - funky gems



nunye
09-29-2016, 09:35 PM
Another random question:

I know that this doesn't work because of the modifier of the gem (snowy stone), but how do I get it to work using the name of the stone instead of the noun? Or better yet, the .id?

This works:

gem = ["stone"]

result = dothistimeout "look in my #{Vars.lootsack}", 5, /In the .*? you see/
contents = result.scan(/\b(?:#{gem.join('|')})(?= and an? |,|\.)/)
contents.each { |gem|
fput "get #{gem} from my #{Vars.lootsack}"
fput "open my #{Vars.gemsack}"
fput "put #{gem} in my #{Vars.gemsack}"
}

This does not:

gem = ["snowy white ice stone"]

result = dothistimeout "look in my #{Vars.lootsack}", 5, /In the .*? you see/
contents = result.scan(/\b(?:#{gem.join('|')})(?= and an? |,|\.)/)
contents.each { |gem|
fput "get #{gem} from my #{Vars.lootsack}"
fput "open my #{Vars.gemsack}"
fput "put #{gem} in my #{Vars.gemsack}"
}

Tillmen
09-30-2016, 07:19 AM
put_regex = /^You (?:attempt to shield .*? from view as you |discreetly |carefully |absent-mindedly )?(?:put|place|slip|tuck|add|hang|drop|untie your|find an incomplete bundle|wipe off .*? and sheathe)|^A sigh of grateful pleasure can be heard as you feed .*? to your|^As you place|^I could not find what you were referring to\.$|^Your bundle would be too large|^The .+ is too large to be bundled\.|^As you place your|^The .*? is already a bundle|^Your .*? won't fit in .*?\.$|^You can't .+ It's closed!$|^You need a free hand to pick that up\./
specifc_gems = /snowy white stone|star diopside of doom/
unless lootsack = (GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars.lootsack.strip)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars.lootsack).sub(' ', ' .*')}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars.lootsack).sub(' ', ' .*')}/i })
echo "can't find lootsack"
exit
end
unless gemsack = (GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars.gemsack.strip)}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars.gemsack).sub(' ', ' .*')}$/i } || GameObj.inv.find { |obj| obj.name =~ /\b#{Regexp.escape(Vars.gemsack).sub(' ', ' .*')}/i })
echo "can't find gemsack"
exit
end
close_lootsack = false
close_gemsack = false
if lootsack.contents.nil?
r = dothistimeout "open ##{lootsack.id}", 5, /^You open|^That is already open\./
if r =~ /^You open/
close_lootsack = true
end
if lootsack.contents.nil?
dothistimeout "look in ##{lootsack.id}", 5, /^In the|^That is closed|^I could not find/
if lootsack.contents.nil?
echo "can't find lootsack contents"
exit
end
end
end
if gemsack.contents.nil?
r = dothistimeout "open ##{gemsack.id}", 5, /^You open|^That is already open\./
if r =~ /^You open/
close_gemsack = true
end
if gemsack.contents.nil?
dothistimeout "look in ##{gemsack.id}", 5, /^In the|^That is closed|^I could not find/
if gemsack.contents.nil?
echo "can't find gemsack contents"
exit
end
end
end
# option 1
lootsack.contents.each { |obj|
if obj.type =~ /gem/
dothistimeout "_drag ##{obj.id} ##{gemsack.id}", 5, put_regex
end
}
# option 2
lootsack.contents.each { |obj|
if obj.name =~ specific_gems
dothistimeout "_drag ##{obj.id} ##{gemsack.id}", 5, put_regex
end
}
fput "close ##{lootsack.id}" if close_lootsack
fput "close ##{gemsack.id}" if close_gemsack

nunye
09-30-2016, 07:44 AM
Yeah, that's totally how I thought you would do it! (Not!). I'll analyze that and make myself understand it.

I really appreciate your help.