Results 1 to 5 of 5

Thread: Barrel full of Barrels "free barrels" smasher

  1. #1

    Default Barrel full of Barrels "free barrels" smasher

    (apologies for the dumb title, not really sure what else to call it)

    This script will smash all non-mimic barrels in the Barrel full of Barrels, which should not take any adventures. As such, this requires the Shrine to the Barrel God so that His Holiness may guide the script away from mimics. As of now, the script does not check to see if the player worships His Rotundity (should be easy to add), so beware!

    First time trying to do anything with regex, critique is appreciated.
    Attached Files

  2. #2
    Minion Bale's Avatar
    Join Date
    Jun 2008
    Posts
    13,287

    Default

    For what it's worth I've been using a function to smash all my barrels after ascending. It's a bit... smaller...

    Anyway, I created a general regexp that applies to all barrels (without exclamation points) instead of individually matching each and every possibility for a barrel. That's the real advantage of using a regexp.

    Code:
    // If you've got a Shrine to the Barrel God, get free stuff from the barrel.
    void free_barrels() {
    	if(!in_bad_moon() && get_property("barrelShrineUnlocked") == "true") {
    		print("Seek free stuff from the Barrel full of Barrels since you have the Barrel god's blessing.", "blue");
    		matcher barrel = create_matcher('<div class="ex"><a class="spot" href="([^"]+)"><img title="A barrel"', visit_url("barrel.php"));
    		while(barrel.find())
    			visit_url(barrel.group(1));
    	}
    }
    That is an excerpt from my newLife script.
    Last edited by Bale; 01-20-2017 at 02:19 AM.
    If people like my scripts, please send me stuffed Hodgmen.
    Universal Recovery, OCD Inventory Control, CounterChecker, newLife, ChIT.


  3. #3
    Developer
    Join Date
    Aug 2009
    Posts
    2,824

    Default

    Hm, and I have cranks.ash, which expects to be called like a CLI command (with cranks == number of times you want to click the crank button, relevant if you're looking for clovers):
    Code:
    void main(int cranks) {
        matcher m = create_matcher('<div class="ex"><a class="spot" href="[^"]*&slot=(\\d+)"', '');
    
        repeat {
    		m.reset(visit_url('barrel.php'));
    		while (m.find()) {
    			visit_url("choice.php?whichchoice=1099&option=1&slot=" + m.group(1) + "&pwd=" + my_hash());
    		}
    		if (cranks > 0) {
    			visit_url("choice.php?whichchoice=1099&option=2&pwd=" + my_hash());
    		}
    		cranks -= 1;
        } until (cranks < 0);
    }
    I'm not entirely sure why I wrote the matcher the way I did. Maybe I thought I needed to specify the hash?

  4. #4
    Senior Member ckb's Avatar
    Join Date
    Mar 2006
    Posts
    833

    Default

    And because I use NewLife anyway, I take Bale's well written function and use it in my own to find a clover (turning the crank once and searching).

    PHP Code:
    //Turn the barrel crank and harvest all the barrels until we find a clover
    //uses Bale's newLife free_barrels() function
    void BarrelClover() {
        
    UseAllItems($item[ten-leaf clover]);
        if (
    item_amount($item[disassembled clover])==0) {
            print(
    "ckb-Std: Turning the barrel crank for 1 clover","maroon");
            while (
    item_amount($item[disassembled clover])==0) {
                
    visit_url("choice.php?whichchoice=1099&pwd=&option=2");
                
    free_barrels();
                
    UseAllItems($item[ten-leaf clover]);
            }
        }

    And that uses this too:
    PHP Code:
    void UseAllItems(item it) {
        if (
    available_amount(it)>0) {
            print(
    "using: "+available_amount(it)+" "+it,"blue");
            use(
    available_amount(it),it);
        }


  5. #5

    Default

    Oh, huh! Good to know there are more concise ways to do this, thanks for the insightful replies!

Posting Permissions

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