Results 1 to 3 of 3

Thread: Universal herb buying/healing script

  1. Default Universal herb buying/healing script

    Alright. Big thanks to Vulvamancer/Danical first off, since most of the code is originally his code. Also thanks to Tillmen for helping me figure out the shortest route to a certain location using Go2.

    As stated above, when complete this script will determine your current location, find the shortest route or eta to a herb cache (bench/whatever) look for the herb, if it cant find it there go to the nearest herbalist store, order the herb, eat it, etc etc. until you're healed.

    Here's my issue.

    I cant for the life of me figure out how we're pulling the order number from this line.

    herb = herbs['majorwounds'][area][$times]

    When later all that gets called on it to actually purchase the damn herb is:

    fput "order #{herb}"

    Here's the code for Vulva/Danical's version, Sixbits/Psighs altered it to work for with Tillmens lich. I know its looking at the array defined in herbs =
    and I want to set up a table that says, okay, if my current room is foo then order number for this herbalist is $foo_herb_order_number. That I can take care of. But just where the FUCK would I put #{$foo_herb_order_number} in the herb = herbs['majorwounds'][area][$times] line...... heres the code.

    Code:
    =begin
    Auto Teras Herb Healer v1.1
    This is a little script Gnimble threw together for those in need of Teras herb consumption.
    Modified by Sixbits/Psighs to work with Tillmen's version of lich.
    ABSOLUTELY DO NOT RUN THIS WITH ANYTHING IN YOUR HANDS
    =end
    
    herbs = {
    	'minorwounds' => {
    		'head' => [ 'rose-marrow potion', 'semak\'s ale', '7' ],
    		'neck' => [ 'rose-marrow potion', 'semak\'s ale', '7' ],
    		'back' => [ 'basal moss', 'mama ale', '9' ],
    		'abs' => [ 'basal moss', 'mama ale', '9' ],
    		'chest' => [ 'basal moss', 'mama ale', '9' ],
    		'leye' => [ 'basal moss', 'mama ale', '9' ],
    		'reye' => [ 'basal moss', 'mama ale', '9' ],
    		'rarm' => [ 'ambrominas leaf', 'lost ale', '3' ],
    		'rhand' => [ 'ambrominas leaf', 'lost ale', '3' ],
    		'rleg' => [ 'ambrominas leaf', 'lost ale', '3' ],
    		'larm' => [ 'ambrominas leaf', 'lost ale', '3' ],
    		'lhand' => [ 'ambrominas leaf', 'lost ale', '3' ],
    		'lleg' => [ 'ambrominas leaf', 'lost ale', '3' ],
    		'nerves' => [ 'wolifrew lichen', 'orc\'s ale', '5' ]
    	},
    	'majorwounds' => {
    		'head' => [ 'aloeas stem', 'dark ale', '17' ],
    		'neck' => [ 'aloeas stem', 'dark ale', '17' ],
    		'back' => [ 'pothinir grass', 'aged ale', '19' ],
    		'abs' => [ 'pothinir grass', 'aged ale', '19' ],
    		'chest' => [ 'pothinir grass', 'aged ale', '19' ],
    		'reye' => [ 'pothinir grass', 'aged ale', '19' ],
    		'leye' => [ 'pothinir grass', 'aged ale', '19' ],
    		'rarm' => [ 'ephlox moss', 'golden ale', '13' ],
    		'rhand' => [ 'ephlox moss', 'golden ale', '13' ],
    		'rleg' => [ 'ephlox moss', 'golden ale', '13' ],
    		'larm' => [ 'ephlox moss', 'golden ale', '13' ],
    		'lhand' => [ 'ephlox moss', 'golden ale', '13' ],
    		'lleg' => [ 'ephlox moss', 'golden ale', '13' ],
    		'nerves' => [ 'bolmara potion', 'kenar\'s ale', '15' ]
    	},
    	'minorscars' => {
    		'head' => [ 'haphip root', 'agrak\'s ale', '25' ],
    		'neck' => [ 'haphip root', 'agrak\'s ale', '25' ],
    		'back' => [ 'talneo potion', 'gert\'s ale', '27' ],
    		'abs' => [ 'talneo potion', 'gert\'s ale', '27' ],
    		'chest' => [ 'talneo potion', 'gert\'s ale', '27' ],
    		'reye' => [ 'talneo potion', 'gert\'s ale', '27' ],
    		'leye' => [ 'talneo potion', 'gert\'s ale', '27' ],
    		'rarm' => [ 'cactacae spine', 'bearded ale', '21' ],
    		'rhand' => [ 'cactacae spine', 'bearded ale', '21' ],
    		'rleg' => [ 'cactacae spine', 'bearded ale', '21' ],
    		'larm' => [ 'cactacae spine', 'bearded ale', '21' ],
    		'lhand' => [ 'cactacae spine', 'bearded ale', '21' ],
    		'lleg' => [ 'cactacae spine', 'bearded ale', '21' ],
    		'nerves' => [ 'torban leaf', 'miner\'s ale', '23' ]
    	},
    	'majorscars' => {
    		'head' => [ 'brostheras potion', 'reaper\'s ale', '33' ],
    		'neck' => [ 'brostheras potion', 'reaper\'s ale', '33' ],
    		'back' => [ 'wingstem potion', 'wort\'s ale', '35' ],
    		'abs' => [ 'wingstem potion', 'wort\'s ale', '35' ],
    		'chest' => [ 'wingstem potion', 'wort\'s ale', '35' ],
    		'reye' => [ 'wingstem potion', 'wort\'s ale', '35' ],
    		'leye' => [ 'wingstem potion', 'wort\'s ale', '35' ],
    		'rarm' => [ 'calamia fruit', 'mad ale', '29' ],
    		'rhand' => [ 'calamia fruit', 'mad ale', '29' ],
    		'rleg' => [ 'calamia fruit', 'mad ale', '29' ],
    		'larm' => [ 'calamia fruit', 'mad ale', '29' ],
    		'lhand' => [ 'calamia fruit', 'mad ale', '29' ],
    		'lleg' => [ 'calamia fruit', 'mad ale', '29' ],
    		'nerves' => [ 'woth flower', 'draco\'s ale', '31' ]
    	},
    	'missing' => {
    		'reye' => [ 'cur-clover potion', 'Volcano vision ale', '37' ],
    		'leye' => [ 'cur-clover potion', 'Volcano vision ale', '37' ],
    		'rarm' => [ 'sovyn clove', 'Capt ale', '39' ],
    		'rhand' => [ 'sovyn clove', 'Capt ale', '39' ],
    		'rleg' => [ 'sovyn clove', 'Capt ale', '39' ],
    		'larm' => [ 'sovyn clove', 'Capt ale', '39' ],
    		'lhand' => [ 'sovyn clove', 'Capt ale', '39' ],
    		'lleg' => [ 'sovyn clove', 'Capt ale', '39' ]
    	}
    }
    
    def nomnom(herb)
    	fput "put #{checkright} on bench" if checkright !~ /#{herb.split.last}/ && checkright
    	fput "get #{herb}" if herb =~ /tincture|potion|ale/ && checkright !~ /#{herb.split.last}/
    	#herb =~ /tincture|potion|ale/ ? fput "drink my #{herb}" : fput "eat #{herb}"
    	if herb =~ /tincture|potion|ale/ then fput "drink my #{herb}" else fput "eat #{herb}" end
    	waitrt?
    	line = waitfor("You (remove|manage|take)", "not find", "were you referring", "Get what")
    	return $times += 1 if line =~ /not find|were you referring|Get what/
    end
    
    def purchase(herb)
    	start_script 'go2', [ '1838', '_disable_confirm_' ]
    	wait_while{running?('go2')}
    	fput "withdraw 2000 silver"
    	start_script 'go2', [ '1851', '_disable_confirm_' ]
    	wait_while{running?('go2')}
    	fput "order #{herb}"
    	fput "buy"
    	start_script 'go2', [ '1838', '_disable_confirm_' ]
    	wait_while{running?('go2')}
    	fput "depo all"
    	start_script 'go2', [ '1932', '_disable_confirm_' ]
    	wait_while{running?('go2')}
    	$times -= 1
    end
    
    unless checkroom("Dragonspine and Krodera")
    	fput "stand" if checksitting
    	start_script 'go2', [ '1932', '_disable_confirm_' ]
    	wait_while{running?('go2')}
    end
    
    for area in %w[head neck back abs chest reye leye rarm rhand rleg larm lhand lleg]
    	herb = [] ; $times = 0
    	while Wounds.send(area) >= 2
    		until Wounds.send(area) == 1 || herbs['majorwounds'][area][$times] =~ /\d+/
    			herb = herbs['majorwounds'][area][$times]
    			nomnom(herb)
    		end
    		fput "put #{checkright} on bench" if checkright
    		if Wounds.send(area) >= 2 && herbs['majorwounds'][area][$times] =~ /\d+/
    			herb = herbs['majorwounds'][area][$times]
    			purchase(herb)
    			next
    		end
    	end
    	$times = 0
    	while Wounds.send(area) == 1  && Scars.send(area) == 0
    		until Scars.send(area) >= 1 || herbs['minorwounds'][area][$times] =~ /\d+/
    			herb = herbs['minorwounds'][area][$times]
    			nomnom(herb)
    		end
    		fput "put #{checkright} on bench" if checkright
    		if Wounds.send(area) == 1 && Scars.send(area) == 0 && herbs['minorwounds'][area][$times] =~ /\d+/
    			herb = herbs['minorwounds'][area][$times]
    			purchase(herb)
    			next
    		end
    	end
    	$times = 0
    	while Scars.send(area) == 3 && area =~ /arm|leg|hand/
    		until Scars.send(area) < 3 || herbs['missing']['rarm'][$times] =~ /\d+/
    			herb = herbs['missing']['rarm'][$times]
    			nomnom(herb)
    		end
    		checkright if fput "put #{checkright} on bench"
    		if Scars.send(area) == 3 && area =~ /arm|leg|hand/ && herbs['missing']['rarm'][$times] =~ /\d+/
    			herb = herbs['missing']['rarm'][$times]
    			purchase(herb)
    			next
    		end
    	end
    	$times = 0
    	while Scars.send(area) == 3 && area =~ /eye/
    		until Scars.send(area) < 3 || herbs['missing']['reye'][$times] =~ /\d+/
    			herb = herbs['missing']['reye'][$times]
    			nomnom(herb)
    		end
    		checkright if fput "put #{checkright} on bench"
    		if Scars.send(area) == 3 && area =~ /eye/ && herbs['missing']['reye'][$times] =~ /\d+/
    			herb = herbs['missing']['reye'][$times]
    			purchase(herb)
    			next
    		end
    	end
    	$times = 0
    	while Scars.send(area) >= 2
    		until Scars.send(area) == 1 || herbs['majorscars'][area][$times] =~ /\d+/
    			herb = herbs['majorscars'][area][$times]
    			nomnom(herb)
    		end
    		checkright if fput "put #{checkright} on bench"
    		if Scars.send(area) >= 2 && herbs['majorscars'][area][$times] =~ /\d+/
    			herb = herbs['majorscars'][area][$times]
    			purchase(herb)
    			next
    		end
    	end
    	$times = 0
    	while Scars.send(area) == 1
    		until Scars.send(area) == 0 || herbs['minorscars'][area][$times] =~ /\d+/
    			herb = herbs['minorscars'][area][$times]
    			nomnom(herb)
    		end
    		checkright if fput "put #{checkright} on bench"
    		if Scars.send(area) == 1 && herbs['minorscars'][area][$times] =~ /\d+/
    			herb = herbs['minorscars'][area][$times]
    			purchase(herb)
    			next
    		end
    	end
    end
    
    unless checkroom("Golden Helm, Hearth Room")
    	start_script 'go2', [ '12506', '_disable_confirm_' ]
    	wait_while{running?('go2')}
    end

  2. #2
    Join Date
    Nov 2004
    Location
    Upstate NY
    Posts
    428

    Default

    I'm gonna be honest here and just say that I gave up trying to trace the script after 2-3 minutes. I'm assuming you're not sure what the herb = herbs['majorwounds'][area][$times] line is actually doing. Technically herbs isn't an array, it's a hash (if you aren't familiar with those, it's almost exactly like an array, but instead of only being able to refer to elements stored in the array by a number position, you can refer to them using words or whatever else you have a use for at the time.)

    The herbs hash is itself holding a whole bunch of additional hashes, each of which is holding a bunch of arrays. Sounds kind of confusing, huh... just picture the original herbs hash as one little box. Inside that box, you have a collection of other hashes -- in the way of an example, let's say we want to access the majorwounds hash inside the original herbs hash -- to do that, we just do the standard herbs['majorwounds']; but then we want to access something in that hash, which is the area in question. So let's say it's "chest" -- to access that, the line would have to be herbs['majorwounds']['chest'], but since the value of the area variable is the word "chest" (for the purposes of this example anyway), we just do herbs['majorwounds'][area] -- that will return the array stored in the "chest" hash, which is then referenced using the value of the $times variable. I have no clue what $times is going to be, but if you can figure out how that comes into it, you can figure out the rest.

    In the example above, the array being accessed is defined on the line reading
    Code:
    'chest' => [ 'wingstem potion', 'wort\'s ale', '35' ],
    -- if $times held the number 1, the return value of herbs['majorwounds'][area][$times] would be "wort's ale". With any luck, that's the piece you needed to know in order to answer the rest of your questions. Basically, every time another curly-brace opens up, you're dealing with another hash (that just happens to be contained in a separate hash, in this case.)
    Last edited by Shaelun; 07-10-2009 at 04:00 PM.
    I visualize a time when we will be to robots what dogs are to humans, and I'm rooting for the machines. -- Claude Shannon

  3. Default

    Actually I figured the hash out and yeah I understand how its pulling out multiple elements from the hash.

    I've actually got a universal herbhealer working now. It was on the repo but I took it off because I felt it ran to and fro too much. Im currently working on a system that will create a needed herb list, grab as many as it can from a bench/donation bin, subtract those from the array, then go to the store and buy the rest. Then much down on the rest until healed and empty the 'herbsack' back into the bin/bench.

Similar Threads

  1. Herb Healing in Illistim
    By Lodyn in forum Miscellaneous Scripts
    Replies: 1
    Last Post: 11-08-2011, 10:26 AM
  2. Automatic herb healing/buying script.
    By pabstblueribbon in forum The Lich Project
    Replies: 2
    Last Post: 01-11-2010, 09:31 AM
  3. Universal movement script?
    By Rolis in forum General Gemstone
    Replies: 5
    Last Post: 05-28-2008, 10:24 AM
  4. herb eating/healing script?
    By eridein in forum Scripting Discussion
    Replies: 17
    Last Post: 04-21-2008, 08:36 PM
  5. Universal Foraging Script
    By Celephais in forum Miscellaneous Scripts
    Replies: 0
    Last Post: 06-27-2007, 12:12 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
  •