PDA

View Full Version : Waitfor Oddity



Danical
09-24-2008, 07:25 AM
WTF?!? All line matches for my containers are FUBAR'd!



fput "look in my cloak"
line = waitfor("In the (.+) you see", "nothing in there")
echo line
exit


--- Lich: test active.
[test]>look in my cloak
There is nothing in there.
>
[test: In the cloak: nothingThere is nothing in there.]
--- Lich: test has exited.





fput "wave"
line = waitfor("wave")
echo line
exit


--- Lich: test active.
[test]>wave
You wave.
>
[test: You wave.]
--- Lich: test has exited.

Celephais
09-24-2008, 08:27 AM
It probably has to do with the SF xml tags... when you look in a container this is what is sent:


<container id='135289295' title='Sheath' target='#135289295' location='right'/><clearContainer id="135289295"/><inv id='135289295'>In the <a exist="135289295" noun="sheath">sheath</a>:</inv><inv id='135289295'> nothing</inv>There is nothing in there.

Basically lich is ignoring the fact that <inv> tags are not streamed to your story window, they're streamed to an inventory window, so technically the echo of the single "line" sent to you when you type "Look in (container)" was correct.

Danical
09-24-2008, 03:07 PM
:(

This is problematic . . . HOW TO FIX?

Danical
09-24-2008, 03:22 PM
Wait, so, if I don't have my inventory window open will this fix ze problem?

Danical
09-24-2008, 03:23 PM
Also, you're never on AIM anymore so I can't get expert advice for a nooblet like me :(

OR ARE YOU GHOSTING?

Celephais
09-24-2008, 06:24 PM
Don't really use AIM anymore... that and I don't use Lich so I wouldn't really be able to provide too much help.

What is it you're trying to do with the variable that having that extra (albiet stupid looking) text attached? Can you check to see if it's in that format and work around it?

Danical
09-24-2008, 06:35 PM
I have the code at home but it would be something like this . . .

line = waitfor("In the (.+) you see", "nothing").gsup(/ and (:?an|a|some)|,/)
line.split(/,/).scan(/#{variable}/).times { fput "get #{variable} from #{container}" ; fput "sell #{variable}" }

If I try to split the string, the first element in the array is EVERYTHING in the container and everything else follows suit as expected. So, if I have 55 items in my container array[0] is all 55 with the actual first item coming at the very last instance of the string and array[1] is the second item in the container.

I tried to add a .delete_at(0) so it would get rid of that retarded huge first element but it's not working properly.

When I get home, I can be more precise if need be.

Shaelun
09-26-2008, 02:55 PM
I hate dealing with the inconsistencies between SF and Wizard... try this:



line = matchafter("In the [^,]+ you see", "There is nothing in there.")
if line.empty? or line.nil?
# There's nothing in it... the "matchafter" command returned an empty string, meaning it saw the second option and there's nothing on the line after "There is nothing in there."
exit
end

array_of_items = parse_list(line)
echo array_of_items


Should put an array of all the items in "array_of_items" with no weirdness being part of it, but it's off-the-cuff and untested, so take it with a grain of salt. If you're not familiar with it, the "matchafter" function just returns whatever came after the matching portion of the line.

Danical
09-29-2008, 03:44 AM
Thank You!

:heart: