Results 1 to 3 of 3

Thread: Gem hoarding script - help?

  1. Default Gem hoarding script - help?

    I have been working on writing a script that will put gems in jars that live in my locker.

    I have very little training, formal or informal, in any kind of language. I've just decided to learn something new. I understand the .each method, I just can't seem to make it work in this case.

    Any help would be appreciated.

    Annelie

    I'm have shortened this to deal with just two gems for brevity. I've also removed the sorting of the jars since that isn't an issue.

    This script works fine if the gem at the top of the gemsack is the gem you're looking for. Otherwise, it will change #{gem} to the first gem that it finds that belongs to the array.

    Code:
    gemarray = [ "black opal", "rhodochrosite stone"]
    
    
    result = dothis "get jar from my #{Lich.jarsack}", /^You remove/
    if gem = /jar containing (.*?)s from/.match(result).captures.first
    echo "#{gem}"
    
    
    sackscan = dothistimeout "look in my sack", 5, /In the .*? you see/
    contents = sackscan.scan(/\b(?:#{gemarray.join('|')})(?= and an? |,|\.)/)
    echo "#{gem}"
    end
    if contents.include?(gem)
    contents.each { |gem|
      echo "#{gem}"
      fput "get #{gem} from my sack"
      fput "put #{gem} in my jar"
    }
    end
    What I use currently is a convoluted script, and doesn't make good use of the power that is Ruby. It works, but I'd like to try and make it better.

    Code:
    fput "open locker"
    fput "get #{Lich.jarsack}"
    fput "wear my #{Lich.jarsack}"
    
    loop{
    result= dothis "get jar from my #{Lich.jarsack}", /^You remove|^Get what/
    if result =~ /^Get what/
      jar = ['jar']
        result = dothistimeout "look in my cloak", 5, /In the .*? you see/
          contents = result.scan(/\b(?:#{jar.join('|')})(?= and an? |,|\.)/)
            contents.each { |jar|
          fput "get jar from my cloak"
          fput "put jar in my #{Lich.jarsack}"
        }
        fput "remove my #{Lich.jarsack}"
        fput "put my #{Lich.jarsack} in locker"
        exit
    end
    if gem = /jar containing (.*?)?s from/.match(result).captures.first
      end
    if gem =~/radiant opalescent thunderstone/
      gem = "opalescent thunderstone"
    end
    if gem =~/swirling purple thunderstone/
      gem ="purple thunderstone"
    end
    
    result = dothis "get my #{gem} from my #{Lich.gemsack}", /^You remove|^Get what/
      if result =~ /^You remove/
        result = dothis "put my #{gem} in my jar", /is full|to the contents of the glass jar, filling it.|to the contents of the glass jar./
          if result =~/filling it/
            fput "put my jar in locker"
            
          end
          if result =~/is full/
            fput "put #{gem} in my cloak"
            fput "put jar in locker"
            
          end
          if result =~/contents of the glass jar./
            fput "put jar in my #{Lich.jarsack}"
            
          end
      end
      if result =~ /^Get what/
        fput "put jar in my cloak"
      end
    }
    Last edited by Anne; 02-19-2010 at 04:50 PM.

  2. #2

    Default

    at first glance, i would guess your reuse of the gem variable may be causing some issues

  3. Default

    I'm not sure which command is changing the gem. Just to make sure it wasn't "gemarray" (was pretty sure it wasn't), I changed that to just array. Wasn't it.

    Here's a snippet of what it's doing, along with the full code.

    --- Lich: jarwip active.
    [jarwip]>get jar from my backpack
    You remove an opalescent glass jar containing green aventurine stones from in your heavy backpack.
    >
    [jarwip: green aventurine stone]
    [jarwip]>look in my sack
    >
    In the ivy-stitched sack you see a large gold nugget, a piece of brown jade (2), some green ora-bloom, a piece of polished ivory, a gold nugget, a piece of white jade, a platinum nugget and the following:
    41 Gem: a piece of blue ridge coral, a white opal (3), an aquamarine gem (3), a smoky topaz, a pink rhodochrosite stone (2), a snowflake zircon, a golden beryl gem (2), some polished red coral (4), a bright chrysoberyl gem (2), a red spinel, a pink topaz (2), a clear tourmaline, a green aventurine stone, a golden topaz, a pink tourmaline, some polished pink coral, a black tourmaline, a piece of golden amber (2), a turquoise stone, a green malachite stone (3), a piece of cat's-paw coral, a piece of flower coral, a violet spinel, a blue lace agate, a blue-white frost opal, a blood red garnet and a green tourmaline.
    (49 Total)
    >
    [jarwip: aventurine stone]
    [jarwip: white opal]
    [jarwip]>get white opal from my sack
    You remove a white opal from in your ivy-stitched sack.
    >
    [jarwip]>put white opal in my jar
    The glass jar already contains green aventurine stones, so you think better of mixing in your white opal.
    >
    [jarwip: aquamarine gem]

    Code:
    #!/usr/bin/env ruby
    
    
    array = [ "black opal", "blue spinel", "pink sapphire", "rhodochrosite stone", "mother-of-pearl", "white opal", "almadine garnet", "mottled agate", "black jasper", "yellow jasper", "pink topaz", "cordierite", "yellow sapphire", "star sapphire", "pink spinel", "aquamarine gem", "sardonyx stone", "labradorite stone", "bloodstone", "aventurine stone"]
    
    
    result = dothis "get jar from my #{Lich.jarsack}", /^You remove/
    if gem = /jar containing (.*?)s from/.match(result).captures.first
    echo "#{gem}"
    
    if gem =~/mother-of-pearl/
        gem = "mother-of-pearl"
      end
      if gem =~/golden amber/
        gem = "amber"
      end
      if gem =~ /labradorite stone/
        gem = "labradorite stone"
      end
      if gem =~ /rhodochrosite stone/
        gem = "rhodochrosite stone"
      end
      if gem =~ /sardonyx stone/
        gem ="sardonyx stone"
      end
      if gem =~/yellow jasper/
        gem = "yellow jasper"
      end
      if gem =~/black jasper/
        gem = "black jasper"
      end
      if gem =~ /aventurine stone/
        gem = "aventurine stone"
      end
      if gem =~ /bloodstone/
        gem = "bloodstone"
      end
    
    
    sackscan = dothistimeout "look in my sack", 5, /In the .*? you see/
    contents = sackscan.scan(/\b(?:#{array.join('|')})(?= and an? |,|\.)/)
    echo "#{gem}"
    end
    if contents.include?(gem)
    contents.each { |gem|
      echo "#{gem}"
      fput "get #{gem} from my sack"
      fput "put #{gem} in my jar"
    }
    else fput "put jar in bin"
    end
    I suppose I could do a 'sort cluster #{gem} as a work around, but I'm not sure that would do it either.

Similar Threads

  1. Gem hoarding set
    By nichelas in forum Auctions
    Replies: 14
    Last Post: 03-06-2021, 04:33 PM
  2. Bounty gem hoarding script recommendation?
    By Carsyn in forum Miscellaneous Scripts
    Replies: 4
    Last Post: 11-18-2015, 10:34 AM
  3. Gem Hoarding/Sorting Scripts
    By Viekn in forum The Lich Project
    Replies: 3
    Last Post: 09-10-2015, 11:09 AM
  4. My gem Hoarding collection...
    By ashronsjunky in forum Appraisals
    Replies: 0
    Last Post: 03-21-2013, 12:23 AM
  5. Wound hoarding
    By Leetahkin in forum Character Complaints
    Replies: 29
    Last Post: 05-25-2006, 02:36 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
  •