Is there a way to only run scripts once?

N

neb_net

Guest
Is there a way to only run scripts once?
I need this for mushroom field scripts etc. to run on startup, but only the 1st time i use Kolmafia each day.

Sorry if that doesn't make much sense!
 

macman104

Member
[quote author=neb_net link=topic=216.msg1096#msg1096 date=1150400125]
Is there a way to only run scripts once?
I need this for mushroom field scripts etc. to run on startup, but only the 1st time i use Kolmafia each day.

Sorry if that doesn't make much sense!
[/quote]So you mean, like, some sort of setting that prevents a certain script from being run more than once a day? If that's what you're wondering, not really, however, that's an interesting idea, I kind of like it.
 

neb_net

New member
Yeah that's what I meant, also with the "On Login: " thing.

Never mind that it's not possible, I can always just remember which scripts I've run
 
There is a backhanded way...

You have to set a property flag. Then when you want to run your "once a day" script, have it flip that flag.

You would then need to flip the flag again before you could rerun that script.

Still requires some effort on the part of the user... But prevents double running of scripts.
 

Tirian

Member
One option that would partially protect you would be to make sure that you run the daily script before you do any drinking, and then the first line in your script could be to check that your drunkenness is 0.
 

macman104

Member
[quote author=Presto Ragu link=topic=216.msg1103#msg1103 date=1150404681]
There is a backhanded way...

You have to set a property flag. Then when you want to run your "once a day" script, have it flip that flag.

You would then need to flip the flag again before you could rerun that script.

Still requires some effort on the part of the user... But prevents double running of scripts.
[/quote]Yea, I thought about mentioning that, my biggest thing is remembering whether or not I've run the script. Especially with the mushroom script, there's not a good way to double-check besides what your mushrooms look like, which defeats the purpose of scripting if it requires you to manually check. But yea, you could mess around with property flags.
 
Another way to handle the mushroom fields for 1st generation mushrooms.
the "field harvest" command only picks full grown mushrooms leaving any spores. Calling "field harvest" with nothing but spores in your field will do nothing. Having a test following the harvest command as shown below will result in the planting code to never execute if you don't get any mushrooms of the correct type from the harvest command.

This is a section of my icypeak.ash script:
The cycle will need to be started manually by planting the spores the first time, but then will maintain the fields as long as you run the script daily, and can be ran over and over again with no meat wasted pulling and re-planting spores.
Code:
item MushroomToFarm = $item[knoll mushroom];

void DoMushroomFields()
{
//MushroomToFarm is declared, and initialized at the top of this script.
//It will be assumed that the field has already been purchased.
int PreFarmShrooms;
int iterations;
PreFarmShrooms = item_amount(MushroomToFarm);
cli_execute("field harvest");
if(item_amount(MushroomToFarm) > PreFarmShrooms)
  {
  iterations = 1;
  While(iterations != 17)
    {
    cli_execute("field plant " + int_to_string(iterations) + " " + MushroomToFarm);
    iterations = iterations + 1;
    }
  }
}

//the following added to make this a stand alone ash script.

void main()
{
DoMushroomFields();
}

2nd or 3rd gen mushrooms will require another method.
 
Top