don't stop executing a script when I hit an error, and other questions

stannius

Member
I am working on a script to play while I am traveling over the crimbo season. I have included it below for reference. My question is: how do I make it so the script continues executing even if it hits an error. (for example, maybe I logged in before the script ran and ate some food already. I don't want the rest of the script to stop just because I hit my fullness.)

I saw there's a "continue" command, but I didn't understand how to use it from the one sentence of documentation provided :)
I saw other script examples in the forum which use ASH and "catch" the error by using the boolean return value from commands (either assigning it to a variable or using it in an if statement.) I would prefer to not have to convert my script to ASH format if I can avoid it.


I am also open to feedback on reducing the server load caused by my script. I will set it to run as a scheduled task every morning at 3 AM or so (pacific time). I have already followed all the guidelines requested on the main forum post (buffing and buying restores for the duration, etc.)

Is there a cli script flow control variable for number of adventures remaining? (to enable turn banking.)

Code:
use 20 stench wad
eat 3 bat wing chow mein
drink 3 gimlet
drink bottle of Pinot Renoir

acquire 15 green snowcone
acquire 15 orange-frosted astral cupcake
familiar sombrero
outfit crimbo powerleveling
mood crimbo powerleveling

adventure * Spooky Fright Factory

uneffect the moxious madrigal
outfit pajamas
drink gimlet

skill summon snowcone
skill 3 pastamastery
skill 5 advanced saucecrafting
 

Nightmist

Member
[quote author=stannius link=topic=630.msg2942#msg2942 date=1166034069]
*Weee a proper "need help with script" request, good on ya!*
[/quote]

Well to be honest I don't know how to "stop" cli scripts from erroring out so I can't really answer your main question. (I'm a ASH man myself heh)

I assume thats only a snippet of the script judging from the "uneffect the moxious madrigal" but no casting of another AT buff later on in it. (Just wondering if you accidently added that or if its ment to be there)

While theres no "my_adventures()" command in CLI, the "adventure" command allows non-positive numbers which mean "everything except", and with these "if today is <statname> day" and "if tomorrow is <statname> day" flow commands you can bank turns for stat days pretty easily.
 

stannius

Member
[quote author=Nightmist link=topic=630.msg2946#msg2946 date=1166057624]
Well to be honest I don't know how to "stop" cli scripts from erroring out so I can't really answer your main question. (I'm a ASH man myself heh)
[/quote]

Yeah, guess I'm going to have to jump into ASH sooner or later. But I've only got a couple days so I hope it can be later :)

[quote author=Nightmist]I assume thats only a snippet of the script judging from the "uneffect the moxious madrigal" but no casting of another AT buff later on in it. (Just wondering if you accidently added that or if its ment to be there)[/quote]

While I did simplify the script somewhat for my post, that particular bit is indeed intended. My "crimbo powerleveling" outfit includes the plexiglass pendant, which allows 4 AT buffs at once, and I want control of which buff is removed when I switch to a different outfit not including the pendant. The casting of Madrigal is (intended to be - I haven't actually tested my script yet ;) handled by the mood (casting enough to last the entire day of course).

While theres no "my_adventures()" command in CLI, the "adventure" command allows non-positive numbers which mean "everything except", and with these "if today is <statname> day" and "if tomorrow is <statname> day" flow commands you can bank turns for stat days pretty easily.

Ah, you're right, that's perfect for my needs. Flow commands don't allow "or" clauses do they?

Thanks for your response, it was definitely helpful!

Stannius
 

Nightmist

Member
[quote author=stannius link=topic=630.msg2947#msg2947 date=1166062961]
Ah, you're right, that's perfect for my needs. Flow commands don't allow "or" clauses do they?
[/quote]
Not that I'm aware of. You can always use multiple "if" commands though. (Yeah it means you will probably either have to have copies of a semi-colon separated commands or a "call" command to another file with he commands, messy but it works =D)

Heh once you start wanting "AND" clauses in CLI scripting is when it starts getting messy ;)[/offtopic remark]
 

stannius

Member
[quote author=Nightmist link=topic=630.msg2948#msg2948 date=1166064254]Not that I'm aware of. You can always use multiple "if" commands though. (Yeah it means you will probably either have to have copies of a semi-colon separated commands or a "call" command to another file with he commands, messy but it works =D)[/quote]

Indeed :)

To get around my original problem, I am using the "standard input redirect" trick:
Code:
"java -jar KoLmafia-9.9.jar --CLI < scripts\vacation_daily.txt"
(rather than using "script=scripts\vacation_daily.txt", which could abort.)

And I am using multiple if's to adventure as you suggested:
Code:
# use up all adventures on stat days
if today is mysticism day
  adventure * The Crimborg Collective Factory
if today is muscle day
  adventure * The Crimborg Collective Factory
if today is moxie day
  adventure * The Crimborg Collective Factory

# if not a stat day, bank turns
adventure -114 The Crimborg Collective Factory

Thanks for your help. I'll endeavor to learn ASH by the time of my next trip ;)

stannius
 
Top