Requesting Help with Handy Dandy Custom Farming Script

Izzle

New member
Please excuse the intense length and noobyness xD.

Hi everyone, I'm new to scripting and I'm attempting to make something that seems a little complex to me... I've been looking around the manual, and I'm currently writing a script to farm using my (brand spankin' new) Ninja Pirate Zombie Robot.

Now, before I post the script as I have written thus far, here are the actions I intend for it to perform:

Put on the NPZR outfit
Buy 5 Salty Dogs
Drink 5 Salty Dogs
Adventure at the Castle in the Clouds in the Sky
After each adventure, cast Leash of Linguini based on remaining MP
Keep adventuring until only 3 adventures remain
Put on the Rollover outfit
Send 6 meat to Testudinata
Send 8 meat to Testudinata
Send 1 meat to Testudinata
Sell all my Toast for 110 meat each with a limit of 5.
Output summary to E:\farm.txt
Print "Done." to the screen

[glow=red,2,300]npzr hunt.txt:[/glow]
----------------------------------------
outfit npzr
buy 5 salty dog
drink 5 salty dog
---EXECUTE--- hunt.ash
outfit rollover
send 6 meat to testudinata
send 8 meat to testudinata
send 1 meat to testudinata
mallsell Toast 110 5
summary E:\farm.txt
echo Done.
----------------------------------------


[glow=red,2,300]hunt.ash:[/glow]
----------------------------------------
void huntit()
{
while ( my_adventures() > 2)
{
adventure( 1, The Castle in the Clouds in the Sky );
---EXECUTE---( leash.ash );
}
return;
}
----------------------------------------

[glow=red,2,300]leash.ash:[/glow]
----------------------------------------
void leash()
{
while( my_mp() > 11)
{
int tocast;
int currentmp;
currentmp = my_mp();
tocast = currentmp / 12;
if( tocast == 0)
{
cast_leash( tocast);
}
}
return;
}

void cast_leash()
{
if( have_skill( Leash of Linguini )
{
use_skill( tocast, $skill[Leash of Linguini] );
}
}
----------------------------------------

Now for the not-so-great bits...
First of all, I'm not entirely sure what I'd put when I want the script (or sub-script?) to terminate itself and either end the whole thing or continue on with its parent script. In a post somewhere on this forum I saw someone use "return;" so I hope that's what it is =P.
When selling the Toast (NPZR likes to pick these up), will it only put in one, or will it put in all of them? If only one, then I will have to write a script to make it continue doing so until I have no more toast left. No biggie.
Assuming the adventures performed will deal with combat in the normal weapon-fighting way, how can I ensure that it refers to the Custom Combat Script instead? This is essential as the combat script dictates the number of times to use the Dictionary to pass rounds without dealing damage, and to commence regular attacks at round 29.
Also, if I were to have a summary, an encounter list, and an inventory list (for example), all outputted to files, would it work if I directed them to the same file? The idea is for the results to appear in a sequential fashion (appended), rather than having the entire file overwritten each time. That's not exactly what I'm looking for, though, as really what I'm interested in is having the summary file include all the times I've ever run the script.
Lastly, and very importantly, what command must I use to have a script execute another script? At the moment I have those bits substituted with "---EXECUTE---," but that obviously isn't going to cut it... I do this simply so that I have the different parts clearly divided. If it is not possible, I suppose I could have it all in ASH and put it in a single file.
Oh and before I end this, I was wondering whether it is possible to use both the more-basic scripting (covered in "Scripting with KoLmafia") and advanced scripting (ASH, covered in "Advanced Scripting With KoLmafia") in the same script. I imagine this would make a few people's lives a little easier, though I don't expect it to parse two different syntax-y-thingies at once.

And, uhh, that's it. Any help would be greatly appreciated =).



( split previous post and put your writings as guest in here so you could modify them if you wanted to at some point... -Daychilde )

Oopsies. I just registered and discovered that there is an whole forum for this kinda thing...

Could a mod please move this thread? =)

Thanks.
 

Nightmist

Member
[quote author=Izzle link=topic=266.msg1345#msg1345 date=1152147767]
*Yay someone that Reads the Manual First!*
[/quote]

First of all, I hear KoLMafia's Custom Combat is being nerfed to screw over stasis strats so if your planning to stasis you may be screwed over in the next release of KoLMafia. (Note: I hear, I cant exactly confirm since i'm not Hola)

Random Semi-Related Notes:
Return is usually used to well return a value to whatever called it. In your case I don't think you need to stick return in there since its a void code.

Ive never messed around with the mallsell function so ill let someone else answer that...

About the Custom Combat Script, read above.

I always assumed the "send output to file" commands all appended (Theres also a "mirror" command that you might be interested in) i'm not completely sure though. As for knowing how many times you have run the script do you mean like a actual counter or just keeping the old logs and constantly appending to it? (If you mean a counter, the ash scripting commands
Code:
void set_property( StringName, StringValue)
string get_property( StringName)
might be helpful)

Instead of "---EXECUTE---" I think a simple call command should be good enough.

Yes you can mix ASH and CLI scripts but only as long as they are in different files. (ASH also has a handy little
Code:
cli_execute()
which means you can use standard cli commands in a "ASH only" script.)


Now for the actual script suggestions:

For your individual ASH files you can stick them in the same file and then just use for example
Code:
leash();
instead of calling a different file.

When you call the ASH file from your CLI file the ash file needs a
Code:
void main()
which mafia launches (In any ASH script mafia will run top level commands(Commands not put into groups) and then the main function. It will ignore others unless told to run them from the main())
 
When selling the Toast (NPZR likes to pick these up), will it only put in one, or will it put in all of them? If only one, then I will have to write a script to make it continue doing so until I have no more toast left. No biggie.

Code:
Ive never messed around with the mallsell function so ill let someone else answer that...

I can take that one.

The mall sell function will place all of the toast you have into the mall.

Now I will elaborate a little more on one of nightmist's suggestions:

Code:
void jump(int times)
{
print("jumping " + times + " times");
}

void sit()
{
print("sitting");
}

void main()
{
jump(5);
sit();
}

Output:
Jumping 5 times
sitting

all the script above does is display some text, but it is the simplest way to show an actual script with user created functions in it. You were pretty close to having that already. Proper function order would be:
void cast_leash()
void leash()
void huntit() but re-name this one void main()

all the functions would be in the same script.

Name the script hunt.ash (or whatever)

in npzr hunt.txt change ---EXECUTE--- hunt.ash to
Code:
call hunt.ash

change ---EXECUTE---( leash.ash ); to
Code:
Leash();
and so on
 
Top