Modified mushroom script to produce 3rd +4th gen crop

tebee

Member
I've been having a go at changing efilnikufecin's mushroom script to do a 16 day cycle, basically the 10 day cycle to produce 8 gloomy back mushrooms and the 6 day cycle to produce 8 third generation mushrooms off the wiki. I've used whatever spare space I have to plant knoll mushrooms as well. The resultant script is attached here. It is, at this moment, untested and needs to be started on the first muscle day, which is today!

If anyone would like like to join me in this jorney of discovery fell free, otherwise all comments and corrections are welcomed. If you have used efilnikufecin's script previously please note I've used the same property name so you would need to delete from your saved settings.

It needs to be run once a day and once only of course...

Tom
 

Attachments

  • mrooms.ash
    10.9 KB · Views: 565
Wow! I forgot about that script a long time ago. I remember I based it on someone else's scripts, but added the built in looping instead of manual looping.

Ah found it, it was based on pastafresco's Mushroom Field Scripts.
 

tebee

Member
I've posted a sightly corrected version of this script in the first post, but have still not managed to test it 100% as my internet connection went down for 4 days first time through and haven't had a character with a long enough run muscle sign since, but I have got it as far as producing gloomy black mushrooms.

I'm working on a new version that will be switchable between the current system and just producing the maximum amount of Knoll Mushroom each day. Let you all know how I get on.


Tom
 

Sandiman

Member
I'll give this a try, is there any way I can have it be run for breakfast once per day?

General -> Preferences -> Breakfast -> "plant mushrooms".

Then just run breakfast on login or use the "breakfast" command.
 
It seems to have gotten stuck on cycle 2 for some reason... How can I reset it to start again at cycle 1 when it's muscle day again?
 

Sandiman

Member
Without modifying the planting script manually, you can't. Planting scripts work off of four variables defined in the user_prefs.txt file: plantingDate, plantingDay, plantingLength, and plantingScript. These four variables are used by the KoLMafia logic in conjunction with the individual planting scripts to determine what gets planted when.

plantingDate reflects the moon phase. This is used to determine if you've run the planting script more than once today.

plantingDay is a 0-offset value that corresponds to your progress through the plan. Your first day is 0, and your last day is N, where N is (plantingLength - 1)

plantingLength is the number of days your plan spans. A full moon cycle is 16.

plantingScript is the script run when KoLMafia says "run my mushroom planting script" (in any of the multiple ways to say that). If you felt like it, you could really make this any ASH script you wanted, although I'm not sure why you'd do that.

If you look at the values described above, the only date that would really affect what's being planted is plantingDay. We could reset that to 0, but all that would do is reset our planting script back to the square one. There isn't any part of a planting script that determines the start date/moon phase of the script -- that's all up to the user.

I should point out that you can modify the planting script itself to make it verify the correct moon phase, assuming you know or want to learn ASH. That being said, I think this functionality was purposefully left out of KoLMafia; as such, I won't be expressly posting how to add this functionality. If the powers that be give it the OK, I'd be glad to share. In the meantime, you'll either have to wait for the moon to cycle or code some ASH.

Best of luck!
 

Veracity

Developer
Staff member
[quote author=Sandiman link=topic=783.msg8624#msg8624 date=1217878626]
I should point out that you can modify the planting script itself to make it verify the correct moon phase, assuming you know or want to learn ASH. That being said, I think this functionality was purposefully left out of KoLMafia; as such, I won't be expressly posting how to add this functionality. If the powers that be give it the OK, I'd be glad to share. In the meantime, you'll either have to wait for the moon to cycle or code some ASH.[/quote]
I don't believe the functionality was purposefully omitted because of any feeling that "users shouldn't do this". I believe that holatuwol created what he considered to be a tasteful user interface for defining scripts and generated scripts only have what is required to support that UI.

Requiring a script to begin on a certain day is unnecessary except for gloomy mushroom scripts, and therefore complicated the UI, and was therefore omitted.

I'd say go ahead and share your technology.
 

Sandiman

Member
Ay ay, cap'n.

This isn't something new so much as a sideways way of doing things. The whole point is that moon_phase() returns a number 0 through 16. As long as you know what the phase is when you want to start (for example, the first muscle day is phase "8"), you can do a check on that in the planting script.

Here's an example planting script, as generated by the KoLMafia mushroom layout creator:
Code:
void main()
{

  if ( !have_mushroom_plot() )
  {
    print( "You do not have a mushroom plot." );
    return;
  }

  if ( get_property( "plantingScript" ) != "test" )
  {
    set_property( "plantingDay", -1 );
    set_property( "plantingDate", -1 );
    set_property( "plantingLength", 10 );
    set_property( "plantingScript", "test" );
  }

  if ( get_property( "plantingDate" ).string_to_int() == moon_phase() )
    return;

  set_property( "plantingDate", moon_phase() );
  int index = (get_property( "plantingDay" ).string_to_int() + 1) % 10;
  set_property( "plantingDay", index );

  if ( index == 0 )
  ....

Now here's a modified planting script that only allows each index to be performed on a certain day:
Code:
void resetPrefs()
{
	set_property( "plantingDay", -1 );
	set_property( "plantingDate", -1 );
	set_property( "plantingLength", 16 );
	set_property( "plantingScript", "MaxShrooms" );
}

void main()
{

  if ( !have_mushroom_plot() )
  {
    print( "You do not have a mushroom plot." );
    return;
  }

  if ( get_property( "plantingScript" ) != "MaxShrooms" )
  {
		resetPrefs();
  }

  if ( get_property( "plantingDate" ).string_to_int() == moon_phase() )
    return;

  int plantingDate = moon_phase();
  set_property( "plantingDate", plantingDate );
  int index = (get_property( "plantingDay" ).string_to_int() + 1) % 16;
  set_property( "plantingDay", index );

  # "8" is the first Muscle day - index 0 can only be performed on day 8, and so on
  int offsetDate = (index + 8) % 16;
  if ( offsetDate != plantingDate )
  {
    print( "Moon phase is not correct for running this script. Try again tomorrow." );
    resetPrefs();
    return;
  }
	
  if ( index == 0 )
  ...

Mine is a bit drastic, as most people don't really need it to check EVERY day for validity. This is more of a worst-case scenario.

Hope this helps people!
 

Sandiman

Member
I'll do you one better. Here's my script that does 8 gloomy and 2 rounds of level 3 mushrooms (if people want me to put this in a different topic so it's easier to find, that's fine).

I had to do this by hand, because the mushroom layout doesn't do 16 days, so I may be off on it. I was actually inspired to make it when I saw this post, and I haven't been able to test it yet. ::crosses fingers::

If anyone wants to use this, be my guest.

EDIT: I suppose it would help if I told people how to use this. Because it's a 16-day script, it can't be run directly from KoLMafia's mushroom layout tool. You must either call the script from the CLI or edit your user preferences and set "plantingScript" to "MaxShrooms". It wouldn't be a bad idea to delete the rest of the planting* variables, just for cleanliness -- this script will initialize them on first run. Once it has been run once, having the "plant mushrooms" box checked in your breakfast settings will ensure the script gets called on breakfast.

EDIT 2: I added a 'notify' line to the script. I figure if people are actually using this, it would be cool to know.

EDIT 3: Updated the script to version 0.2; the script should now run correctly for days 8-16.
 

Attachments

  • MaxShrooms.ash
    3.4 KB · Views: 212
Wow very nice Sandi, I'll be sure to give this a trial run on the next muscle day. Thanks for the breakfast and checks so that it doesn't run more than once, very nice and impressive.
 

snooty

Member
I recently tested the OP's script on a multi, the initial 11 days (from the first muscle day) were successful, and today I harvested my 8 gloomies. When mus days roll around again, I'll also test Sandiman's script and indicated adjustments.

Thanks much for your efforts, both of you!
 
Sandi, I seem to run into problems when ticking the "Plant mushrooms" for breakfasting. I get this error:

No available namespace with function: planting/MaxShrooms.ash
 
Should the script be picking the mushrooms today?

August 25, 2008 - Starch 2

Ronald: waxing crescent
Grimace: new moon

All the gloomies are there, but the script isn't picking them.

In gCLI:

plantingDate => 1
plantingDay => 0
Moon phase is not correct for running this script. Try again tomorrow.
plantingDay => -1
plantingDate => -1
Initializing chat interface...
 

Sandiman

Member
Actually, the script failed yesterday, too. It was supposed to plant mushrooms to start the second 3rd-generation cycle, and it failed to do so.

For those of you wanting a learning experience, take a look at line 53 of the original script.

Incorrect (and current) code:
Code:
int offsetDate = index + 8 % 16;

Correct code:
Code:
int offsetDate = (index + 8) % 16;

Turns out 8 % 16 is always 8. Who knew? ;)

For those of you running my script, sorry for screwing up one of your moon loops. If you manually edit your user preferences and set the following values, then run the script, it will pick all your gloomy mushrooms:
Code:
plantingDate=0
plantingDay=8

I would suggest that those choosing to go this route manually clear our their mushroom fields on the first Muscle day; while the script will continue to run every day, it will no longer be breeding the correct mushrooms (it was supposed to plant mushrooms yesterday to start the second 3rd-generation cycle). If the field is not cleared on the first Muscle day, it will not produce the desired mushrooms.

Those of you who do NOT want to continue planting mushrooms in this cycle (after all, it won't be 3rd-gen mushrooms) should install the new version and pick your gloomy mushrooms manually.

For all parties involved, the script will automatically "restart" its planting cycle on the first Muscle day, so you should be good to go provided you a) have the new version installed and b) have a blank mushroom plot by the first Muscle day.

I hope that answered everyone's questions. If not, please let me know.
 

Attachments

  • MaxShrooms.ash
    3.4 KB · Views: 232

snooty

Member
I also encountered the same situation, thanks for the fix, Sandiman! Also, I've posted a link to this thread in our clan forum, hope you don't mind :)
 
Top