New Content - Implemented Order of the Green Thumb: The Florist Friar

fronobulax

Developer
Staff member
The same way that exactly-matching monster names helps people without Manuel, I suppose.

Which would be?

(Again, just curious. My personal opinion, which I would not unilaterally inflict on the rest of the community, is that consistency between KoL and KoLmafia is A Good Thing and breaking scripts is an acceptable cost to pay for that. However I have been beaten up about that when advocating consistency because it makes sense in a software engineering and maintenance context but has no visible user benefit. So asking the question gives me ammunition for the next time when I am the advocate, and hence target. Thanks).
 

Winterbay

Active member
I think that when KoL has a "correct" name, then it is good to use that since it makes for potentially less confusion in discussions between non-mafia users and mafia users in sya kol chat.
 

lostcalpolydude

Developer
Staff member
12237 adds checking when you log in, florist_available(), and _floristPlantsUsed (comma-separated).

The biggest thing still missing is get_florist_plants(). The information it would report is already in FloristRequest.floristPlants, but I couldn't figure out how to have an ASH function return what I was going for. I was thinking of something like a record with a string key and three string values, but perhaps a single string value would be more straightforward to implement.
 

Veracity

Developer
Staff member
How about an array of three strings?

string [3] plants;

Take a look at RuntimeLibrary.get_goals() to see how to return a string array like that.
 

lostcalpolydude

Developer
Staff member
get_goals() returns a string [int], I want to return a string [string]. I think I need to add some code elsewhere to support that. Maybe DataTypes, maybe AggregateType, I don't really know yet.
 

Veracity

Developer
Staff member
You keep talking about a string key. I think you mean a "location" key, right? I haven't looked at the florist since day one or so; I got bored when I saw how badly it messed up my fight page. But, you can plant up to three plants in each location, right?

form_fields() returns a map from string to string. It calculates the map key like this:

Value keyname = new Value( name );

To make a location key, you would do this:

Value keyname = DataTypes.parseLocationValue( name );

The only difficulty is creating the value to return. A string with three comma separated plant names would be easy. But, the user would have to call split_string() or the equivalent to get the three plants. So, you could do an implicit split_string() and return an array of three strings. Look at split_string() to see how to create that value, if it is unclear.

The ASH program could do this:

Code:
foreach loc, plants in get_florist_plants() {
    print( "Location '" + loc + "'" );
    foreach plant in plants
	print( "   plant '" + plant + "'" );
}
or this
Code:
foreach plant in get_florist_plants( to_location( loc ) ) {
    print( "   plant '" + plant + "'" );
}
If I don't understand how you want this function to operate, please explain more. Thanks.
 

lostcalpolydude

Developer
Staff member
You keep talking about a string key. I think you mean a "location" key, right?

I guess the first thing a script would do with a string is apply to_location() to it, so it should be a location key. That means not including ambiguous keys though, rather than letting script writers make guesses about what the ambiguous keys are.

That looks straightforward enough to implement soon.
 

Veracity

Developer
Staff member
Before I bother with that, KoL will hopefully deal with some locations having identical names (pre/post crypt cemetary, (un)hydrated desert). Eleron asked me before about having mafia location names match KoL location names (probably because it would let him use mafia data files for more stuff in kolproxy), and I said no because it would break scripts and bring no benefit to mafia users. Now that there is a benefit for mafia to have matching names, I asked him about bugging TPTB to provide unique location names, and he's going to work on that.
And here is where having a location type vs. a string type is a little problem: if what you store is KoL's (possibly ambiguous) location names, how do you return the "correct" location value?

I suppose you could have a function to parse KoL's location name into KoLmafia's location name - but, as you mentioned, KoL currently has locations with identical names. Unless Eleron has gotten the KoL devs to fix that.
 

lostcalpolydude

Developer
Staff member
After lots of testing and multiple read-throughs of Veracity's post so that it could sink in, I think I got get_florist_plants() right in 12244.
 

lostcalpolydude

Developer
Staff member
Code:
foreach loc, counter, plant in get_florist_plants() {
    print( "Location '" + loc + "'" );
    print( "Counter '" + counter + "'" );
    print( "Plant '" + plant + "'" );
}
is what I was working with. Not sure if that's any better or if I overlooked stuff while trying to sort out ASH data types.
 

Veracity

Developer
Staff member
You are fast. I deleted the message you were responding to, since I had forgotten how to use foreach correctly, but you had already replied. Sorry!

Nice job!

My new test program:

Code:
string [location][int] plants = get_florist_plants();

foreach loc in plants {
    print( "Location '" + loc + "'" );
    string [int] array = plants[ loc ];
    foreach index in array {
	string plant = array[index];
	if ( plant != "" )
	    print( "Plant = " + plant );
    }
}
yields this:

> Florist.ash

Location 'The Mer-Kin Outpost'
Plant = Kelptomaniac
 
Last edited:

lostcalpolydude

Developer
Staff member
I think all that's missing for this feature to be complete is matching zone names. I'm going to start a new thread for that so those can be organized in one place, and then all of those can be changed at one time for minimal script disruption.
 

Crowther

Active member
I've been messing with these functions and I've made some progress on automatically planting flowers, but for some reason get_florist_plants() doesn't list any flowers in Castle in the Clouds in the Sky (Top Floor), but the florist shows I have them planted there and the flowers show up in the used list properly. I planted them with the cli command, but that worked okay for The Spooky Forest.
 

lostcalpolydude

Developer
Staff member
I've been messing with these functions and I've made some progress on automatically planting flowers, but for some reason get_florist_plants() doesn't list any flowers in Castle in the Clouds in the Sky (Top Floor), but the florist shows I have them planted there and the flowers show up in the used list properly. I planted them with the cli command, but that worked okay for The Spooky Forest.

The only reason that should happen (especially after looking at the table of everything planted, which wipes mafia's list and parses it from scratch) is if KoL and mafia use different names for a location, but the castle stuff has already been updated to match, so I don't have any ideas for that.
 

Crowther

Active member
The only reason that should happen (especially after looking at the table of everything planted, which wipes mafia's list and parses it from scratch) is if KoL and mafia use different names for a location, but the castle stuff has already been updated to match, so I don't have any ideas for that.
I even tried logging out and back in.
Two other problems I had with my script. The function my_location() didn't work for me, because I call my script from my mood as an unconditional trigger, so the location is already updated to the place I'm about to adventure. I solved this by parsing the florist's page, but that's an extra server hit.
The other problem I had was mafia considers it a choice adventure that it can't simply leave. This required another server hit as well to convince mafia the choice adventure was over.
Other than that my script was functional, but I don't want to release it with those extra server hits.
 

Crowther

Active member
Oh, I just found lastAdventure. I'll take a look at using that.

EDIT: Nope. That's the same as my_location().
 
Last edited:
Top