Barrel full of Barrels "free barrels" smasher

somersaulter

New member
(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.
 

Attachments

  • ss_barrel.ash
    2.2 KB · Views: 87

Bale

Minion
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:

heeheehee

Developer
Staff member
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?
 

ckb

Minion
Staff member
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:
//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:
void UseAllItems(item it) {
	if (available_amount(it)>0) {
		print("using: "+available_amount(it)+" "+it,"blue");
		use(available_amount(it),it);
	}
}
 
Top