Relay Override Scripting
This is a means of changing KoL's web pages so that the user sees something different. There are two kinds of relay override scripts. The first is simply known as an Relay Script. The second is a User Interface script.
Note that in order to use relay override scripts, you must have the respective KoLMafia preference checked as shown (remember to restart mafia after changing this preference):
Relay Script
For a simple Relay Script, there are several basic rules:
- The name of the script must be the same as the page it is overriding, except with an ash extension instead of a php extension. For users who have enabled relay override scripts, mafia will automatically call xyz.ash every time the relay browser attempts to visit xyz.php.
- Unless the script is displaying entirely new content using writeln(), it should first load the unmodified page from KoL using the command visit_url() with no parameters.
- Then the contents of the page can be modified with replace_string() or other string manipulation functions.
- Finally, the modified page is written with the write() command.
Here is an example of a relay script. This will modify shore.php to reveal items that are needed for the level 6 tower monster. The script must be named shore.php in order to modify the correct page.
// This script will only work if it is named shore.ash
void main() {
buffer results;
// Get the basic shore page
append(results, visit_url());
// This will modify the Dude Ranch text if a stick of dynamite is needed
void dynamite() {
if(available_amount($item[stick of dynamite]) < 1)
replace_string(results, "Distant Lands Dude Ranch Adventure",
"<font color=\"green\"><b>Distant Lands Dude Ranch Adventure"
+" (stick of dynamite needed)</b></font>");
}
// This will modify the Paradise Island text if a tropical orchid is needed
void orchid() {
if(available_amount($item[tropical orchid]) < 1)
replace_string(results, "Tropical Paradise Island Getaway",
"<font color=\"green\"><b>Tropical Paradise Island Getaway"
+" (tropical orchid needed)</b></font>");
}
// This will modify the Ski Resort text if a barbed-wire fence is needed
void fence() {
if(available_amount($item[barbed-wire fence]) < 1)
replace_string(results, "Large Donkey Mountain Ski Resort",
"<font color=\"green\"><b>Large Donkey Mountain Ski Resort"
+" (barbed-wire fence needed)</b></font>");
}
// Only do this if the character has no access to the mall
if(!can_interact()) {
// If the character has a level 7 telescope, only check for the necessary item
if(get_property("telescopeUpgrades") == "7")
switch(get_property("telescope7")) {
case "see a wooden beam":
dynamite(); break;
case "see a formidable stinger":
orchid(); break;
case "see a pair of horns":
fence(); break;
}
// Check for all three items
else {
dynamite();
orchid();
fence();
}
}
// Write the modified page to the web browser
write(results);
}
User Interface Script
More information will be added later. In the meantime, here are two links: