First (real) attempt to make an ash script: Sewer.ash

me259259

Member
Hey everyone! I'm somewhat new to ash scripting. I've made some scripts for mafia before... but they all exclusively used "cli_execute" before it did anything. This is my first attempt to use ash commands, as well as make the script think for itself a little.

This script is designed to get me through the sewer, and only the sewer. First it gets the items to make the run as short as possible. Then it equips the outfit, mood, and familiar I want. Then it adventures in the sewers. Then it takes the items dropped and does stuff with them. And finally it switches back to my standard outfit, mood, and familiar. Here's what I have so far:

Code:
// This is my first attempt to make a somewhat complicated script.
// If there are better ways to do the below, please let me know!

void main ()

{

// get items
if (item_amount( $item[gatorskin umbrella] ) < 10)
	retrieve_item (10, $item[gatorskin umbrella]);
if (item_amount ( $item[unfortunate dumplings] ) < 10)
	retrieve_item (10, $item[unfortunate dumplings]);
if (item_amount ($item[sewer wad] ) < 10)
	retrieve_item (10, $item[sewer wad]);
if (item_amount ($item[bottle of ooze-o] ) <10)
	retrieve_item (10, $item[bottle of ooze-o]);
if (item_amount ($item[Oil of oiliness] ) < 30)
	retrieve_item (30, $item[Oil of oiliness]);

// put on some pants, change your attitude, and bring a friend	

outfit ("Sewer");
// I can't seem to find the ash equivalent of these next two things.  Anyone know what they are?
cli_execute ("mood +ml-combat");
cli_execute ("familiar animated macaroni duck");


	
// will this next line cause the script to break if it finishes in less than 100 turns?
adventure(100 , $location[a maze of sewer tunnels] );

// You got some items!  What to do?

// make gatorskin umbrellas

if ( have_skill ($skill[armorcraftiness])) 
	{
	int gatorskins = item_amount( $item[gator skin] );
	retrieve_item (gatorskins, $item[titanium assault umbrella]);
	create (gatorskins, $item[gatorskin umbrella]);
	}

// make unfortunate dumplings.  [B]This next part is line 45[/B]
	
if (( have_skill ($skill[transcendental noodlecraft])) && (((if my_class() == ($class[pastamancer])) || if (my_class() == ($class[sauceror])))))
	{
	int chums = item_amount ($item[C.H.U.M. chum]);
	retrieve_item (chums, $item[MSG]);
	retrieve_item (chums, $item[dry noodles]);
	create (chums, $item[Unfortunate dumplings]);
	}	
	
// make oil of oiliness
	
if ( have_skill ($skill[advanced saucecrafting]) )
	{
	int livers = item_amount ($item[decaying goldfish liver]);
	retrieve_item (livers, $item[scrumptious reagent]);
	create (livers, $item[oil of oiliness]);
	}
	
// Oh boy!  Time for Schnapps!

int stills_available;
int schnapps = item_amount ($item[bottle of sewage schnapps]);

if  (stills_available > 0 && schnapps > 0)
	{
	if stills_available < schnapps
		create (stills_available, $item[bottle of ooze-o]);
	if stills_available > schnapps
		create (schnapps, $item[bottle of ooze-o]);
	}

// and last but not least...
	
cli_execute ("send * sewer nuggets to smashbot");
	
// if I lack the skills, send the items to sellbot, let him deal with my crap
// is there an ash equivolent?

cli_execute ("send * gator skin, * decaying goldfish liver, * bottle of sewage schnapps, * C.H.U.M. chum to sellbot");

// Ok, back to normal

outfit ("DA");
cli_execute ("mood +ml");
cli_execute ("familiar jumpsuited hound dog");
}

After spending a great deal of time debugging, I've run into a problem that I don't know how to solve. I keep getting the following error:

"Unknown variable 'if' (Sewer.ash, line 45)"

I have no idea what this means. What makes it think that 'if' is a variable, and not the start of an if statement?

Also, there are probably a fair amount of bugs after line 45, as I've only been discovering the bugs as mafia tells me there's a problem. If you guys can, please don't tell me about any of the bugs after line 45. I think I found all the bugs before line 45 thanks to mafia (if I'm wrong about this, please let me know). But for every line after line 45, please don't tell me about any bugs. I'm still learning to script, and I'll learn faster if the debugging process is as reasonably painful as possible (so I'll be extra motivated to not make common bugs).

I ask for help on line 45 because I've spent a fair amount of time trying to figure it out myself... but it's getting kind of ridiculous, and the solution is probably really easy, and I'm missing it because I'm spending too much time on it.
 

Veracity

Developer
Staff member
You have
Code:
if (( have_skill ($skill[transcendental noodlecraft])) &&
    (((if my_class() == ($class[pastamancer])) || if (my_class() == ($class[sauceror])))))
You need
Code:
if ( have_skill ($skill[transcendental noodlecraft]) && 
     ( my_class() == $class[pastamancer] || my_class() == $class[sauceror]) )
 

icon315

Member
instead of
PHP:
if (item_amount( $item[gatorskin umbrella] ) < 10)
	retrieve_item (10, $item[gatorskin umbrella]);
if (item_amount ( $item[unfortunate dumplings] ) < 10)
	retrieve_item (10, $item[unfortunate dumplings]);
if (item_amount ($item[sewer wad] ) < 10)
	retrieve_item (10, $item[sewer wad]);
if (item_amount ($item[bottle of ooze-o] ) <10)
	retrieve_item (10, $item[bottle of ooze-o]);
if (item_amount ($item[Oil of oiliness] ) < 30)
	retrieve_item (30, $item[Oil of oiliness]);
use
PHP:
int [item] Sewer_Items;
Sewer_Items[$item[sewer wad]] = 1;
Sewer_Items[$item[unfortunate dumplings]] = 1;
Sewer_Items[$item[bottle of Ooze-O]] = 1;
Sewer_Items[$item[oil of oiliness]] = 3;
Sewer_Items[$item[gatorskin umbrella]] = 1;

foreach itm, qty in Sewer_Items {
    if ( itm == $item[gatorskin umbrella] && have_equipped(itm) )
        qty = qty - 1;
    if ( item_amount(itm) < qty )
        if( !retrieve_item( qty, itm ) )
            abort( "Couldn't acquire enough "+ to_plural(itm) +"." );
}

instead of
PHP:
cli_execute ("familiar animated macaroni duck");
you could use
PHP:
use_familiar( $familiar [animated macaroni duck]);
 

me259259

Member
Sweet! Thank you Veracity! Without all those "if"s running around, I was able to debug the rest, and it works!

Icon315, thank you for the ash equivalent for getting a familiar!

And Icon, at the start of this post, I had no idea what on earth your first suggestion was doing. I made this elaborate post translating what you wrote into English to ask if I was reading it right. It made me look up several things in the wiki, and in the process, not only did I wind up understanding almost everything in that suggestion, but now I know a whole lot more about ash scripting than I did an hour ago. Thank you for your suggestion! I just have one question, the script will keep checking the map to make sure that it maintains the qty at all times right? Or do I need to do something fancy?
 

Winterbay

Active member
It seems to me that it won't be called more than at the start of the script and since you go through 100 turns 1 set of things might be a bit too small. I would set your old ones back (10 and 30 instead of 1 and 3) in the map in order for it to retain that functionality, but there might be another solution as well.
 

Winterbay

Active member
Yep, fewer lines is often more efficient (bu tnot always). You can thus get the same functionality with less to type. And if you do the following you can also vary how many "rounds" you want items for:

PHP:
int amount = 3;
int [item] Sewer_Items;
Sewer_Items[$item[sewer wad]] = 1 * amount;
Sewer_Items[$item[unfortunate dumplings]] = 1 * amount;
Sewer_Items[$item[bottle of Ooze-O]] = 1 * amount;
Sewer_Items[$item[oil of oiliness]] = 3 * amount;
Sewer_Items[$item[gatorskin umbrella]] = 1 * amount;

foreach itm, qty in Sewer_Items {
    if ( itm == $item[gatorskin umbrella] && have_equipped(itm) )
        qty = qty - 1;
    if ( item_amount(itm) < qty )
        if( !retrieve_item( qty, itm ) )
            abort( "Couldn't acquire enough "+ to_plural(itm) +"." );
 

Grotfang

Developer
Wouldn't

Code:
1 * amount

be better expressed as

Code:
amount

?

@me259259:

You might want to consider setting the non-combat adventures to the desired option (just to make sure they always get set correctly). If you are interested, the choice adventures numbers are (I think) 197, 198 and 199.

Eg.

Code:
set_property( "choiceAdventure197" , "1" );

Would set CA 197 to take the tunnel.

Good luck!
 

me259259

Member
Ok, I made the changes you guys suggested, and it worked great!... But while I was at it, I decided that if I wanted to change my outfit, mood, or familiar, I don't want to go searching the script to find it. So I attempted to make some user preferences at the top of the script.

The problem I'm currently having is getting the familiar to switch correctly. Is there a way for $familiar to accept a variable? So that the following works?:

Code:
string sewerFam = "animated macaroni duck" ;

use_familiar ($familiar[sewerFam]);
 

Grotfang

Developer
You might want to consider CCS handling. You could use about the same method as you did for mood.

By the way, to change mood (and CCS) using ASH and not cli_execute, simply remember that changes such as that via the cli are usually shorthand for changes to preferences. Therefore:

Code:
set_property( "currentMood" , sewerTude );

is the same as:

Code:
cli_execute ("mood " + sewerTude);

For CCS:

Code:
set_property( "battleAction" , "custom combat script" );
set_property( "customCombatScript" , "default" );

Also, bear in mind that under your current script, if you encounter the cage, you will do whatever the user is currently set to do, whether it is to gnaw out, or to abort. Is this the desired behaviour, in which case 100 adventures may not complete the sewers, or do you prefer it to abort?
 
Last edited:

me259259

Member
Good point Grotfang. I've made the changes you've suggested. Doing that gave me a couple of ideas that needed to be added to the script. First of all, I want to gnaw through the bars, but just in case I don't, I have a user preference set to easily change that. I've also added a check that will abort the script if you have a hobo code binder, but don't have it equipped (plus an option to turn off this feature).

I have a couple of new questions now though. Is there a way to see how many hobo glyphs you have in your binder? I assume I need to use get_property, but I didn't see the hobo glyph count in the user preferences.

And is there a way for mafia to tell if you encountered a specific adventure?
 

slyz

Developer
You can use the lastEncounter mafia property. It updates as soon as you get a new encounter, not once the adventure is over.
 

Bale

Minion
s there a way to see how many hobo glyphs you have in your binder? I assume I need to use get_property, but I didn't see the hobo glyph count in the user preferences.

There is no property to keep track of that. If you want to count your glyphs, you have use a script such as the one in this thread.

PHP:
// glyph checker, courtesy of zarqon, tebee and DerDrongo

string html = visit_url("questlog.php?which=5");
string[int] needed;

void check_glyph (string where, string when) {
   if (!contains_text(html, where)) needed[count(needed)] = where+" - "+when;
}
void check_glyph (string where) {
   if (!contains_text(html, where)) needed[count(needed)] = where;
}

void main() {
   if (item_amount($item[hobo binder]) + equipped_amount($item[hobo binder]) == 0) abort("No hobo binder.");
   check_glyph("The Arid, Extra-Dry Desert");
   check_glyph("The Cola Wars Battlefield", "have ascended at least once");
   check_glyph("The Hippy/Frat Battlefield","wearing Frat Warrior outfit");
   check_glyph("Belowdecks", "anytime not during the island war");
   check_glyph("The Bugbear Pen", "muscle sign only, before you defeat Felonia");
   check_glyph("Camp Logging Camp", "mysticality sign only");
   check_glyph("Cobb's Knob Menagerie, Level 3");
   check_glyph("The Defiled Nook", "during council cyrpt quest");
   check_glyph("The Enormous Greater-Than Sign", "before learning the secrets of the Dungeon of Doom");
   check_glyph("The eXtreme Slope");
   check_glyph('The "Fun" House');
   check_glyph("The Lair of the Ninja Snowmen");
   check_glyph("The Limerick Dungeon");
   check_glyph("The Misspelled Cemetary", "before council cyrpt quest");
   check_glyph("Noob Cave");
   check_glyph("The Penultimate Fantasy Airship");
   check_glyph("The Poker Room");
   check_glyph("The Road to White Citadel", "before finding the citadel");
   check_glyph("The Sleazy Back Alley");
   check_glyph("Thugnderdome", "moxie sign only");
   if (count(needed) == 0) print("You have all known glyphs!","blue");
   else {
      print("You still need "+count(needed)+" glyphs:","blue");
      foreach num in needed print(needed[num]);
   }
}
 
Last edited:

Fluxxdog

Active member
Gah! I love and hate that script! Helped me get most of the codes in my binder, but keep TAUNTING me with that last White Citadel one. 6 ascensions and still no luck >.<
 

Bale

Minion
Gah! I love and hate that script! Helped me get most of the codes in my binder, but keep TAUNTING me with that last White Citadel one. 6 ascensions and still no luck >.<

There's a trick to guarantee that you get it.

If you get to the point where you need the hang glider, whenever you encounter an eXtreme Sports Orc, just run away without killing it. If you run from the Orc, then it cannot drop a hang glider. If you don't get the hang glider, then you can keep trying to get the hobo code.

Now you will definitely get the code on your next ascension.
 
Last edited:

Winterbay

Active member
There's a trick to guarantee that you get it.

If you get to the point where you need the hang glider, whenever you encounter an eXtreme Sports Orc, just run away without killing it. If you run from the Orc, then it cannot drop a hang glider. If you don't get the hang glider, then you can keep trying to get the hobo code.

Now you will definitely get the code on your next ascension.

Unless you get really unlucky and the darn adventure doesn't show up. I'm still missing my thugnderdome-one and man is ti taking forever to show up. 200+ adventures this ascencion and still no sign of it.
 
Top