ASH Script

Well, here's my try at a .ash script for castle farming.
It's kind of simple, and is there anything that needs to be changed?
 

Attachments

  • castlefarming.ash
    1.2 KB · Views: 33

heeheehee

Developer
Staff member
A couple (?) things, focusing just on syntax for now:

If this is going to be public, you'll have to also include eatdrink_modified.ash, unless it's from some forum post -- in that case, link to the post.

These functions take strings (most of them, at least). So... instead of outfit( Meat Farming ), you'd want outfit( "Meat Farming" ).

You declare variable types and new functions. So you don't need to define outfit( "Meat Farming" ) as a boolean. You could either use outfit( "Meat Farming" ); or capture this value when debugging: if(!outfit( "Meat Farming" )) print("Could not equip outfit \"Meat Farming\"!","red");

ASH doesn't take "*" as input. For items, at least, use item_amount(item). For adventures, use my_adventures().

For Beanstalk:Giant's Castle, two problems with the location. First, Beanstalk is the container, so it's not really part of the location name (When figuring this out, check adventures.txt if you need to). Second, you need to declare that it's a constant as follows: $location[Giant's Castle]. You have to do this for all constants (aside from string, buffer, and aggregate, I believe -- strings and buffers are surrounded by quotes, and aggregates are kinda weird -- I think they can only be stored to a map).
("constants" is bolded because variables don't have to be declared in this manner. Just making this distinction clear.)

Finally, you'll want to end each of these lines with a semicolon. It's just how ASH syntax works.

Not trying to turn you away from the ASH language, of course -- it's always good to have another scripter around!
 

slyz

Developer
First off, you should test for syntax errors by typing verify castlefarming.ash, this should give you valuable information if something isn't written correctly, or if a return value isn't the type that is expected etc...

In this case, you will find out that you should put a ; at the end of each line.

Next, ashref is your friend. The verify command gave me this error:
Code:
Expected ), found Meat (castlefarming.ash, line 4)
This means something is wrong with line 4:
Code:
boolean outfit( Meat Farming );
(I already added the ;)
First of all, outfit() isn't a variable, it's a function, so no need to declare it. You would need to declare a variable in which the return value of outfit() is stored, i.e. if you did something like this:
Code:
boolean OutfitPutOnOK;
OutfitPutOnOK = outfit( Meat Farming );
Since you don't need to store the return value of outfit(), let's remove the boolean on line 4, and running the verify command again gives:
Code:
Unknown variable 'Meat' (castlefarming.ash, line 4)
ashref will tell you:
Code:
> ashref outfit

boolean have_outfit( string )
boolean outfit( string )
since outfit() needs a string, change line 4 to:
Code:
outfit( "Meat Farming" );
Now, after removing every boolean at the beginning of each line, let's verify again:
Code:
> verify castlefarming

Unknown variable 'leprechaun' (castlefarming.ash, line 5)

> ashref use_familiar

boolean use_familiar( familiar )
The argument for use_familiar() needs to be a constant of the type $familiar, so we change line 5 to:
Code:
use_familiar( $familiar[leprechaun] );
And the debugging continues =)
 
Last edited:

Grotfang

Developer
Well, here's my try at a .ash script for castle farming.
It's kind of simple, and is there anything that needs to be changed?

Try using "verify <script>" in the CLI:

Code:
verify castlefarming.ash

This checks to make sure the script will run at all as an ash script - a useful feature. In terms of your own script... it's a reasonable effort as a first try. One point that heeheehee didn't catch is that you spelt disturbing fanfic "dusturbing fanfic", which isn't a valid item name.

Other than that, it's great to see someone new giving it a shot. The advice you will get from mafia's native interface using "verify" will probably help a lot as it points to lines which it thinks are wrong.

Keep up the good work!
 

heeheehee

Developer
Staff member
Erm, yeah. And he didn't have an action specified for rave whistle.

Edit: Also, to clarify what I meant by new functions: this applies to any function that hasn't already been pre-defined (either earlier in the script or by Mafia).
 
Last edited:
Well, I've edited it some, added in some stuff, took all the booleans out, and here's my second try.
Thanks for the help you've given me!
 

Attachments

  • castlefarming2.ash
    1.8 KB · Views: 26

slyz

Developer
Code:
> verify castlefarming2

No functions in your current namespace.

Script verification complete.

First of all, the script should run, so ... nice!

Now, you can start adding in more functionality, like setting a mood (to use knob pet spray and knob nasal spray), and overdrinking (if you want the script to take care of that of course).
 
Yeah, I got that also, and I was wondering if that meant it would run.
Oh, how do I set a mood or a CCS? I couldn't find that in my browsing (more of a hunt and find the basics) through the wiki.
 
Last edited:

slyz

Developer
You could either include it in your outfit name by saving your outfit as Meat Farming M=castlemood.

You can also include the familiar and equipment you want to go with the outfit, by naming it: Meat M=castlemood F=lep E=detector.

Mafia will automatically switch everything when you call outfit("Meat M=castlemood F=lep E=detector").
 

heeheehee

Developer
Staff member
Edited to preserve relevant portions only: EatDrink.ash does this through cli_execute("mood whatever_the_heck_your_mood_is_called");
So that's always an option.
 
Last edited:

heeheehee

Developer
Staff member
I was messing around with the set_property(string, string) function, since currentMood is in the user preferences. Apparently it doesn't work? I have no idea why; a restart may be needed. If so, does this count as a bug?

Edit: Apparently yes, restart is needed for this to take effect. Probably because Mafia only loads your preferences once you log in. Now the question before reporting it is do we want it to reload a preference after changing it?
 
Last edited:

slyz

Developer
Do you mean the GUI doesn't show the change, or that mafia actually doesn't use the mood when auto-adventuring ?
 

heeheehee

Developer
Staff member
In a way, both. Mafia doesn't use the mood, and the mood tab in Adventure doesn't change to reflect this. It does, however, change (and sequentially, work) if I log out and back in.
 
Thanks!
Now, it's all ready for me to try tomorrow, when I have a character with adventures.
Is there a line of code to put in to let me simulate it?
To see if eatdrink will run correctly or not.
 

Grotfang

Developer
Is there a line of code to put in to let me simulate it?
To see if eatdrink will run correctly or not.

As of your last posted script (castlefarming2.ash) you do not try to run eatdrink.ash. You simply import it.

I would suggest either changing that line to:

Code:
cli_execute("call EatDrink.ash");

Which I think it what you imagine import will do, or:

Code:
import <EatDrink.ash>;
eatdrink( 15 , 19 , 15 , false );

Which (assuming you have liver of steel) should eat, drink and spleen you to fullness. A more intelligent system would check max fullness, etc (shamelessly taken from heeheehee - thanks for spotting my error!):

Code:
import <EatDrink.ash>;
int eat = fullness_limit();
int drink = inebriety_limit();
int spleen = spleen_limit();
eatdrink( eat , drink , spleen , false );

The example above will work whatever your max fullness, etc is.
 
Last edited:

heeheehee

Developer
Staff member
Erm, doesn't EatDrink eat/drink/spleen to a limit, rather than x more fullness-points?

In that case, just
Code:
int eat = fullness_limit();
int drink = inebriety_limit();
int spleen = spleen_limit();
should be sufficient.
 

Grotfang

Developer
Erm, doesn't EatDrink eat/drink/spleen to a limit, rather than x more fullness-points?

In that case, just
Code:
int eat = fullness_limit();
int drink = inebriety_limit();
int spleen = spleen_limit();
should be sufficient.

Huh. Cool. I will edit my post accordingly
 
Thanks, I wasn't aware that import <eatdrink.ash> didn't call it.
So, I changed that to
Code:
import <EatDrink.ash>;
int eat = fullness_limit();
int drink = inebriety_limit();
int spleen = spleen_limit();
eatdrink( eat , drink , spleen , false );

Oh, and I put in cli_execute("set counterScript = cookie.ash");.
Will that work? Since I would like to get some semi-rares along with my regular items/meat, so I can mallsell them.
Edit: Here's my attempt at mallselling the semi rares, and I'll mess with the prices after the script is done running, by hand.
 

Attachments

  • castlefarming2.ash
    2.2 KB · Views: 22
Last edited:
Top