I think I'm getting the hang of this, but could use some pointers

Fluxxdog

Active member
I've been working with mafia for a while now and finally got the confidence up to make some of my own scripts. They seem to work rather well, but I'd like some feedback as to how I could improve them. madness.txt explains the rationale behind them.

One problem I do have is when a script changes equipment, it seems to change it back afterward after the script finishes. Not sure what I'm doing there.

Thanks in advance to any critique!

EDIT: Removed old files no longer used.
 
Last edited:

slyz

Developer
I guess you're talking about stinkycheese.ash, but maybe giving us more details would help. Maybe a CLI output?
 

heeheehee

Developer
Staff member
While we're on the topic of stinkycheese.ash, why use modifier_eval() (in prop_count())? to_int() works just as well (and is fewer characters to type!). Also, functions like check_eq_sword() could be written, simply:
PHP:
boolean check_eq_sword(){
	return (have_equipped($item[stinky cheese sword]) || have_equipped($item[staff of queso escusado]));
}
To be fair, that doesn't really work too well for separate accessory slots, so I guess you could leave those alone (or try some other funky stuff...).

For conjuregoodies.ash, it doesn't take into account having the Sauceror accessory (which requires the character to be a Sauceror). :)
Also, I don't get why you have an else statement for tome summons if both parts do the same thing. =P

I'm with slyz -- can we get some CLI output / specifics?
 

Bale

Minion
aftercoretest.ash - provides in_aftercore(), a boolean to test if the prism has been broken. While in_hardcore() works for HC, can_interact() doesn't work for SC or casual. The test case was ripped directly from AscendStatus.ash
I'm afraid that script can be replaced with a single line:

Code:
boolean in_aftercore() {
	return get_property("kingLiberated").to_boolean();
}
 

Fluxxdog

Active member
slyz said:
I guess you're talking about stinkycheese.ash, but maybe giving us more details would help. Maybe a CLI output?
For the gear changing, yeah. Here's what it puts out:
Code:
checking for goodies...
sniffing the cheese...
Taking off stinky cheese wheel...
Equipment changed.
Taking off stinky cheese sword...
Equipment changed.
Using 1 stinky cheese wheel...
You lose 14 hit points
You acquire an item: stinky cheese eye
Finished using 1 stinky cheese wheel.
Putting on stinky cheese eye...
Equipment changed.
Using 1 stinky cheese sword...
You lose 14 hit points
You acquire an item: stinky cheese diaper
Finished using 1 stinky cheese sword.
Using 1 stinky cheese diaper...
You lose 14 hit points
You acquire an item: stinky cheese wheel
Finished using 1 stinky cheese diaper.
Using 1 stinky cheese wheel...
You lose 14 hit points
You acquire an item: stinky cheese eye
Finished using 1 stinky cheese wheel.
Putting on stinky cheese eye...
Equipment changed.
You have no weapon! Rethink your strategy please! (Note: Right here is where the abort kicks in)

Calling Universal Recovery for type=HP, amount=0
You need 1 more stinky cheese sword to continue.
You need 1 more stinky cheese wheel to continue.
Putting on Order of the Silver Wossname...
Equipment changed.
Putting on pulled porquoise pendant...
Equipment changed.
And it puts on the equipment that I had on before making the eyes. It's not that big a deal as I can just re-equip them, but I'd like to know what I'm doing wrong.
heeheehee said:
While we're on the topic of stinkycheese.ash, why use modifier_eval() (in prop_count())? to_int() works just as well (and is fewer characters to type!).
Huh. I wasn't aware of that. Some of the functions listed in the wiki were a tad confusing. Just one long list @_@... Would I be correct in guessing all to_xxx functions convert data from one type to another (i.e. string to integer)?
heeheehee said:
Also, functions like check_eq_sword() could be written, simply:
Gah! Case of overthinking :/ For the eyes, the slots that they're in doesn't matter so much as just having 2 equipped
heeheehee said:
For conjuregoodies.ash, it doesn't take into account having the Sauceror accessory (which requires the character to be a Sauceror).
Haven't gotten that far yet. Heck, I haven't even done a run as a Sauceror yet ^^
heeheehee said:
Also, I don't get why you have an else statement for tome summons if both parts do the same thing. =P
Legit question. I wanted the code in place in case I ever do get another tome and want to use that either in my run or aftercore.
Bale said:
I'm afraid that script can be replaced with a single line:
Wow. Very simple. I don't think I'd have guessed that one for quite some time. Question: With that, I don't even really need a separate test, I could just do this directly in the script, right?
PHP:
if (get_property("kingLiberated").to_boolean()) {
funky_chicken(); }
Although, in all honesty, I think I might keep in_aftercore() because it is so much nicer to read.
 

slyz

Developer
The Mafia error seems pretty self-explanatory: it stops the automation because you don't have a weapon. It then uses the outfit checkpoint it created before running your betweenBattle script (but fails because you don't have the stinky weapons anymore).

Another tip: you use a switch in stinkycheese.ash when what you really want is an if/else:
PHP:
int cheesecount = get_property(propstring).to_int();
if ( cheesecount < 75 ) {
	if (!check_sword()) cli_execute ("fold stinky cheese sword");
	if (!check_eq_sword()) equip($item[stinky cheese sword]);
	if (!check_wheel()) cli_execute ("fold stinky cheese wheel");
	if (!check_eq_wheel()) equip($item[stinky cheese wheel]);
}
else {
	if (check_eq_wheel()) equip($slot[offhand],$item[none]);
	if (check_eq_sword()) equip($slot[weapon],$item[none]);
	switch (eye_count()){
	case 0:
		cli_execute ("fold stinky cheese eye");
		equip($slot[acc3],$item[stinky cheese eye]);
	case 1:
		cli_execute ("fold stinky cheese eye");
		equip($slot[acc2],$item[stinky cheese eye]);
	case 2:
		if (!check_eq_eye2() || !check_eq_eye3())
			abort ("Somthing's wrong with the eyes!");
	}
}

You should just replace none in equip($slot[weapon],$item[none]); by some weapon you want equipped.
 

heeheehee

Developer
Staff member
Huh. I wasn't aware of that. Some of the functions listed in the wiki were a tad confusing. Just one long list @_@... Would I be correct in guessing all to_xxx functions convert data from one type to another (i.e. string to integer)?
Yep. Since they're polymorphic functions, you don't even need to specify the type you're converting from!
Gah! Case of overthinking :/ For the eyes, the slots that they're in doesn't matter so much as just having 2 equipped
Then equipped_amount() is what you want in that case. Note that this function returns an int.
Wow. Very simple. I don't think I'd have guessed that one for quite some time. Question: With that, I don't even really need a separate test, I could just do this directly in the script, right?
PHP:
if (get_property("kingLiberated").to_boolean()) {
funky_chicken(); }
Yeah, that'd work.
 

Fluxxdog

Active member
The Mafia error seems pretty self-explanatory: it stops the automation because you don't have a weapon. It then uses the outfit checkpoint it created before running your betweenBattle script (but fails because you don't have the stinky weapons anymore).
OK, that leads to other questions. The betweenBattleScript I use is BestBetweenBattlle.ash. B4battle.ash gets called as a mood (and as part of this complete breakfast!)

I guess I should narrow down the question: Does using abort() cause it to put on the Backup? If so, is there a better way to break adventuring without putting on my old gear?

slyz said:
Another tip: you use a switch in stinkycheese.ash when what you really want is an if/else:
<snip!>
You should just replace none in equip($slot[weapon],$item[none]); by some weapon you want equipped.

Actually, i had considered an if/else scenario, but vetoed it. By using if{}, it would always force a change if I had something else on for some other reason, such as if I wanted to go in the 8-bit realm and needed to hold a transcontinuum functioner (or whatever ^^). Though now that you got me thinking about it, I could just use 1 if{} for ==0 to make and equip the sword and shield and then test to see if it's in the range of 75-80 when I want to make the eyes. B4battle.ash doesn't run the test if the cheese is at maximum potency, so no need to worry about when it gets past 99. Also, I don't know when it'll hit that 75-80 range. I could be on a bounty hunt where I want higher item drops or I could be farming when I want meat. I could get things set up so I switch between the 2 automatically, but I don't think I'm quite skilled enough yet.
heeheehee said:
Then equipped_amount() is what you want in that case. Note that this function returns an int.
Awesome. Thanks for that heads up.
 

slyz

Developer
OK, that leads to other questions. The betweenBattleScript I use is BestBetweenBattlle.ash. B4battle.ash gets called as a mood (and as part of this complete breakfast!)

I guess I should narrow down the question: Does using abort() cause it to put on the Backup? If so, is there a better way to break adventuring without putting on my old gear?

I thought it was a betweenBattle script, but what I said works for moods too. Mafia creates the checkpoint before running everything (mood, restore, BBattle etc...) when auto-adventuring. I tried to find a post (by Veracity maybe?) explaining in what order Mafia did things when auto-adventuring, but wasn't succesful.

Using an abort() anywhere would simply stop Mafia I guess, and I suppose it wouldn't try to re-equip the checkpoint outfit in that case.
 

jasonharper

Developer
betweenBattleScripts aren't run in a checkpoint, and therefore can make persistent changes to your outfit. Mood actions are inside a checkpoint, so changes will be reverted before any further adventuring takes place.
 

Fluxxdog

Active member
betweenBattleScripts aren't run in a checkpoint, and therefore can make persistent changes to your outfit. Mood actions are inside a checkpoint, so changes will be reverted before any further adventuring takes place.
Ah, so the fact it's being run as a mood is what's causing it to switch back. Then I guess the solution is to set my betweenBattleScript to my own script and have it call BBB itself. Thanks!
 
Top