Feature - Implemented Valhalla relay scrips for pets and consumables

Veracity

Developer
Staff member
For use in TCRS, to give you a heads-up about what you'll get for a particular class/sign combination.

For the "astral pets" page, perhaps two dropdowns: "Class" and "Sign" and another control (dropdown, checkbox, radio buttons...) to say whether you are doing TCRS or not.

If you are not doing TCRS or have not chosen both class and sign, all 15 astral equipment pieces display the default modifiers you get for a non-TCRS run.
If you are doing TCRS and have selected both class and sign, the modifiers are replaced with those that apply.
That's all Javascript and, judging my tune spoon functionality provided by KoL which does similar dynamic updates, not that hard.

For the "astral consumables" page, something similar, except the items it shows you are astral hot dog, astral pilsner, and steel margarita (whose size is of interest) and what it shows is size/modifiers (since they can grant an effect).

This could be a relay script - and I append the data files for such which will be needed to modify the HTML - or built-in to KoLmafia.

I attach a couple of data files, and the simple ASH script I used to generate them from the following maps, which I created by reading all 54 TCRS_class_sign.txt files.

string [string, string, item ] pet_modifiers;
string [string, string, item ] consumable_modifiers;
 

Attachments

  • TCRS.astral_pets.txt
    79.2 KB · Views: 32
  • TCRS.astral_consumables.txt
    8 KB · Views: 31
  • TCRSastral.ash
    1.8 KB · Views: 24

Veracity

Developer
Staff member
You know, I sort of like how this turned out.

Here is a relay script which handles the pets as I envisioned.
It needs the data files I generated.
Put the script in "relay" and the data files in "data" and tell me how it looks next time you are in Valhalla.

(No consumables yet).
 

Attachments

  • TCRS.astral_consumables.txt
    8 KB · Views: 23
  • TCRS.astral_pets.txt
    79.2 KB · Views: 20
  • afterlife.ash
    8 KB · Views: 24
Last edited:

Magus_Prime

Well-known member
Tried it this morning and it works well. Thank you.

Edit: It occurred to me, after ascending, that it would be helpful to know what, non-wish, sources of "Got Milk" are available for a given class/moon-sign combination. Not sure where it would be best to put it though.
 
Last edited:

Veracity

Developer
Staff member
Here's a new version which also (in addition to the previous support for the astral pet store) decorates the Deli to let you look at the size (and possible granted effects) of the astral hot dog and astral pilsner - as well as for the steel margarita. Improved the ASH and Javascript, too.

I suspect that some people have spreadsheets and such and make class/sign decisions based on which easily available potions give them run-shortening effects. I suspect that consumable and pet attributes are lower in priority - although they'll want +ML and such. Not that I really know, since I don't compete. But what I have here is probably useful for the general public.

I'm considering submitting this script and associated data files right into the "relay" and "data" directories of KoLmafia itself, so they become "official" support for this, rather than requiring you to install them from svn - and requiring me being the only one who maintains it, since the alternative puts them on my Sourceforge repository. :) I want this to be a generally available KoLmafia interface improvement to the KoL page, since what KoL provides is downright misleading, what with the description it shows when you click on the equipment being randomized every time you click it. That's a poor CX, in my opinion.
 

Attachments

  • afterlife.ash
    13.6 KB · Views: 25
  • TCRS_astral_pets.txt
    79.2 KB · Views: 31
  • TCRS.astral_consumables.txt
    8 KB · Views: 21
Last edited:

ereinion

Member
I for one would appreciate it if you added this to mafia itself, though I suppose if I ever get round to actually doing one of the summer runs I can easily install the script you've added here. Dunno how much of the general public who visits these forums often enough to be aware of that option though.
 

Veracity

Developer
Staff member
I'm interested in dev opinions on this technique.

Consider what we do to decorate Fernswarthy's Basement. We have supporting Javascript functions in relay/basement.js and Java in webui/BasementDecorator. When you visit basement.php, it modifies the HTML from the server to load basement.js and use that to change the UX for the page. The Java code uses methods and data from the rest of the KoLmafia source code to support that.

This is a relay script written in ASH which uses data that I provide and methods in the ASH runtime library. As a relay script, when you visit afterlife.php, the script is called and it modifies the HTML to directly inject the Javascript functions it needs and adjusts the other elements of the page.

The two techniques are equivalent:

1) Both use data provided by KoLmafia itself. I created new data files from the 54 TCRS class/sign data files - as well as, in effect, modifiers.txt, to get the non TCRS data - to get files which go in the "data" directory.
2) Both inject Javascript to provide for dynamic adjustment of what the browser displays, running in the browser itself.
3) Both replace the page returned by the KoL server with a customized version.
4) Both COULD use user settings to control whether or not you see the modifications - although neither does, I believe.

The relay script provides the following advantages (and disadvantage):

If the user puts their own relay script in to the "relay" directory, it will override the built-in support. They could inadvertently remove the support we provided. But they could take the relay file from the KoLmafia source and customize or augment it to meet their own needs. However, building it in like I propose would make merging our changes with their customizations harder, since SVN's merge ability is unavailable.

Using the BasementDecorator technique, users can still augment the built-in changes, since I believe we pass the KoLmafia adjusted page to the relay script.

My opinion: I think using a relay script and associated data files (including, potentially, auxillary Javascript files) is the "modern" preferred technique, now that ASH has matured into its current state. Now, the REAL "modern" technique would use something other than regexps to find & insert stuff in the (often crufty) HTML that KoL provides. Perhaps the xpath functionality which we have - and which will soon be improved, if Saklad5 has their way :) - will make ALL relay scripts easier to code robustly.

And I think for UI improvements that we want ALL users to have without having to know to do an SVN install, putting the script and data right into the KoLmafia "relay" and "data" source directories is the way to go.

Thoughts?
 
Last edited:

Magus_Prime

Well-known member
FYI: In post four the attached file TCRS_astral_pets.txt should be named TCRS.astral_pets.txt for afterlife,ash to use it.
 

xKiv

Active member
If the user puts their own relay script in to the "relay" directory, it will override the built-in support.

Maybe it's time to invent some techniques and tools for running multiple independent relay scripts on the same page?

I can imagine something with, say, new-style relay scripts (that get passed page DOM object and have to use new DOM-manipulation functions) for xxx.php living as relay/xxx/script_###.ash, and then one old-style script living as relay/xxx.ash
- but how does mafia decide which of the new scripts gets run first? Would it just have to assume that they are really indepentend - and commutative, so the order does not matter?
- would the old-style run before or after new-style? I am thinking after, it already had to potentially deal with any changes in mafia's output, and the first examples we have of "new-style" is just migration of mafia's builtin(s)
 

Magus_Prime

Well-known member
When first posted the file " TCRS.astral_pets.txt" has a period between "TCRS" and "astral". The second time it was posted there is an underscore in that spot.
 

Veracity

Developer
Staff member
Revision 19359 adds this script and its two data files to KoLmafia. I had to adjust the code that finds relay files to load an internal file (from the .jar) if there was not already a script in the "relay" directory. If it does find a file there, it will use it and not load the internal file. This allows user-supplied scripts to override internal scripts.

Unfortunately, it's not exactly right - even assuming we want that override behavior - because "loading" an internal relay script consists of copying the internal file from the jar file to your "relay" directory, where it is handled like any other relay file. Unfortunately, since it only looks for the internal script if there is not a relay file there, it will not update the script if we later release a changed version - although we do have the functionality for detecting that...

I might have just changed my mind about letting user scripts override internal scripts...
 

Veracity

Developer
Staff member
Yeah, for now, I want internal scripts to be able to update themselves when we submit new versions.
Revision 19360 will copy an internal script into the relay directory if it exists, which will overwrite a user-supplied script
 

fronobulax

Developer
Staff member
I might have just changed my mind about letting user scripts override internal scripts...

We have a precedent with some of the data files.

But, if we are going to bundle it in a jar file and accept the burden of updating and maintaining it then I am willing to say that a user is not and should not be allowed to make persistent changes. They can work around an automatic overwrite situation by keeping a copy of their local changes and manually merging or they can petition the devs to include their changes in the release.

My concern is that this makes it difficult for a user to provide an independent relay script for a page but that seems to me to be incentive to investigate a way that multiple relay scripts can process the same page.
 

VinnyB

Member
I just ascended again, and was looking over the helpful astral item descriptions, but noticed that they didn't match the ones on the PL sheet. Turns out "Pastamancer" and "Sauceror" are swapped in the Astral Pet Store dropdown menu (PM should be #3 and S #4)
(When I selected S wombat, it was showing me PM wombat instead)
 

VinnyB

Member
Oh, sorry, I think that may also be the case for the astral grocery store place (not there anymore, but pretty sure it said my dogs would be size 2 when they're size 1)
 

Veracity

Developer
Staff member
I use the same ASH function to generate the dropdowns on both pages, so I am sure it is fixed in both. Thanks again.
 
Top