Modular Choice Override 1.3.1
Zlib recommened for update-checking functionality
This is my newest relay script, though it's really more of a framework.
Ever wanted to override a choice adventure, but been frustrated with mafia's lack of support? I have been. It's very difficult to override a single choice adventure and not interfere with other choice adventure overrides. This script is designed to make overriding choice adventures easy and conflict-free. I've also included several of my own relay override scripts:
-----------------------------------------------------
Here's how it works:
The syntax for a choice override script is simple:
The PageData structure holds information about the choice adventure page.
Here's an example override script:
choice_600.ash
That's the whole file. All the heavy lifting is done by choice.ash, so all you need to do is a little text replacement and output the results. As soon as you drop this into your relay/ folder, choice.ash will call it whenever it encounters choice #600.
If you have zlib, the script will check for updates automatically. If you don't, it'll just annoy you by spamming the CLI with a zlib error, but the script will still work perfectly well.
Changelog:
1.0.0: Initial release
1.1.0: Use page text before checking form field data, to fix one choice adventure calling another. Do not override wumpus choice adventure (#360). Added new relay scripts.
1.3.0: Fixes some choice adventures from being overridden.
1.3.1: Migrated to SVN.
Zlib recommened for update-checking functionality
This is my newest relay script, though it's really more of a framework.
Ever wanted to override a choice adventure, but been frustrated with mafia's lack of support? I have been. It's very difficult to override a single choice adventure and not interfere with other choice adventure overrides. This script is designed to make overriding choice adventures easy and conflict-free. I've also included several of my own relay override scripts:
- Ronald/Grimace maps
- The lost key
- Zombie skills (Lure minions and summon minions)
- Hyboria? I don't even... helper
- Orcish Frat House blueprints - reequip your swashbuckling gear automatically
- Pyramid override (separate zip)
- Unpermery helper
-----------------------------------------------------
Here's how it works:
- Run this in your CLI to download:
Code:
svn checkout http://svn.code.sf.net/p/rlbond86-mafia-scripts/code/modular_choice_override/trunk
- To override choice adventure #N, create a script called "choice_N.ash" in your /relay folder. This script has a special syntax, discussed below.
- When you encounter that choice adventure, it will run the override() function in choice_N.ash.
The syntax for a choice override script is simple:
- Import "choice.ash" at the beginning of your script.
- Create a function "boolean override(PageData p)", which will be executed when the choice adventure is encountered.
- Do something inside this function. If you successfully use write() to output the page, return true. Otherwise, return false.
The PageData structure holds information about the choice adventure page.
- p.page is a string which contains the HTML of the page. Use this instead of visit_url(), since the page has already been downloaded once.
- p.fields is a map ( string[string] ) which contains the form fields. Use this instead of form_fields() for the same reason.
Here's an example override script:
choice_600.ash
Code:
import "choice.ash" // this is REQUIRED in a choice override script. It imports the PageData record definition.
// choice 600: Summon Minion
boolean override(PageData p)
{
string page = p.page; // get the text from the page
string wakingDeadText = "<a href=\"http://kol.coldfront.net/thekolwiki/index.php/Waking_the_Dead\" target=\"_blank\">Waking the Dead</a>";
// insert effect text if applicable
if (have_skill($skill[Summon Horde]))
{
page = replace_string(page, "value=1> time(s)</form>",
"value=1> time(s)<br /><font size=-1>(10 turns " + wakingDeadText + ")</font></form>");
}
// write to relay browser
write(page);
return true;
}
That's the whole file. All the heavy lifting is done by choice.ash, so all you need to do is a little text replacement and output the results. As soon as you drop this into your relay/ folder, choice.ash will call it whenever it encounters choice #600.
If you have zlib, the script will check for updates automatically. If you don't, it'll just annoy you by spamming the CLI with a zlib error, but the script will still work perfectly well.
Changelog:
1.0.0: Initial release
1.1.0: Use page text before checking form field data, to fix one choice adventure calling another. Do not override wumpus choice adventure (#360). Added new relay scripts.
1.3.0: Fixes some choice adventures from being overridden.
1.3.1: Migrated to SVN.
Attachments
Last edited: