Results 1 to 8 of 8

Thread: How do you properly loop an action until a matching string is seen?

  1. #1

    Default How do you properly loop an action until a matching string is seen?

    So I'm not sure how to do do {} while (blah blah) loops in Ruby. I'm trying to make a script to use all my keys on a chest, until no more keys are found in my inventory:

    So, something like:

    until("Get what?")
    fput "get my key"
    fput "unlock chest with my key"
    fput "drop my key"
    end

    The above is not valid code, since until("Get what?") is just made up syntax. So how can I express this in loop properly?

  2. #2

    Default

    Maybe I'm not expressing myself well, I basically need to know two separate things:

    1. How to do loops in Ruby that repeat until a certain condition is true

    2. How to scan the output from the game for a specific string and then trigger a flag that would exit the loop above

  3. #3

    Default

    I don’t ruby, just stormfront, so I expect this won’t help but would I would do is

    KEY:
    Match END get what?
    Match GO you remove (or whatever your container verbiage is)
    Put get my key
    Matchwait

    GO:
    Put unlock chest with my key
    Put drop key
    Goto KEY

    END:
    Last edited by Ososis; 01-20-2018 at 09:28 PM.
    "Hi, my name is Ososis and I'm blaming my shitty life for being such a fragile, soy drinking, emotionally unstable loser. My triggers are: Red reputation, ANY mention of MacGuyver and being called a fragile, soy drinking, emotionally unstable loser."

  4. #4

    Default

    Code:
    loop do
    fput "get my key"
    result = waitfor "You remove","Get what"
    break if result =~ /Get what/
    fput "unlock chest with my key"
    fput "drop my key"
    end
    Last edited by Mogonis; 01-20-2018 at 09:49 PM.
    Looking for: krodera items, the gleaming krodera long knife, oldstyle katanas


    August 20, 2006
    >just ban
    You are currently banished from Wehnimer's Landing.

    >ask clerk about citizen
    The clerk says, "Hrrrm, Mogonis, you do seem to be eligible for full citizenship. Just WRITE your name in the book if you wish to make it official."

    >write book
    You sign your name into the citizenship registration book, fully agreeing to the duties and privileges full citizenship provides you.

  5. #5

    Default

    Quote Originally Posted by Mogonis View Post
    Code:
    loop do
    fput "get my key"
    result = waitfor "You remove","Get what"
    break if result =~ /Get what/
    fput "unlock chest with my key"
    fput "drop my key"
    end
    That worked perfectly, thanks.

  6. #6

    Default

    Out of curiosity, what keys are opening what chests? Is this something I never learned about warcamps!?

  7. #7

    Default

    crude keys open the one chest at the end, problem is I tend to accumulate dozens and dozens of them, so have to use them all before it clicks open sometimes

  8. #8

    Default

    Gotcha. It would be kind of neat if the crude keys would work on the boxes inside the chest, but using one would cause it to break. That would give value to collecting more than one key per warcamp.

Similar Threads

  1. how to properly UAC bard
    By Khelbaen in forum Bard
    Replies: 9
    Last Post: 09-10-2018, 03:31 PM
  2. Replies: 12
    Last Post: 12-21-2015, 01:04 AM
  3. error in Gtk.queue: comparison of String with String failed
    By Daerkstar in forum The Lich Project
    Replies: 4
    Last Post: 09-11-2011, 07:27 AM
  4. string rightOf(string source, string r)
    By Jonty in forum Bug Reporting
    Replies: 0
    Last Post: 09-10-2004, 03:12 PM
  5. string replace(string source, string s, string r)
    By Jonty in forum Bug Reporting
    Replies: 0
    Last Post: 09-09-2004, 10:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •