jasonharper
Developer
r8318 adds some experimental features for giving scripts a HTML-based graphical user interface, that appears in the relay browser. This isn't actually a new capability; the basic idea is simply a relay override script that doesn't actually override any existing KoL page, so it can create a page from scratch. However, the capability has been mostly ignored, probably due to various inconveniences in actually using it - such as lack of any easy way to actually access such a page. (You'd have to have a second override script, to add a link to your page from some existing page!)
r8318 solves that problem by collecting relay scripts with names that start with "relay_" (which are unlikely to ever match an in-game page) into a menu in the top pane. It also adds some ASH features for more conveniently dealing with HTML fields and text.
This isn't going to obsolete other forms of mafia scripting - relay scripts aren't really suitable for long, ongoing processes such as autoadventuring, since nothing appears in the browser until the script exits. Also, writing them requires a rather different mindset than the sequential execution of a normal script: if the relay script presents options for the user, they are actually read by an entirely separate invocation of the script than the one that displayed the options. The areas in which relay scripts will be the most useful are user-friendly configuration of other scripts, and presentation of options for the user to carry out in the relay browser themselves (since the script can simply link to any in-game activity).
I've provided one useful example of a relay script already: Breakable equipment fine tuning. Here's another one, more useful to script writers: it allows you to type in HTML code, and immediately see what it produces in the browser, and the form field values that it would submit.
I'm planning on writing some further tools to assist in relay script writing.
EDIT: Oops, I uploaded a version of this script where I'd temporarily changed to method=GET for testing, instead of method=POST which is generally a better idea. It's a simple change on line 5 if you already downloaded the script.
r8318 solves that problem by collecting relay scripts with names that start with "relay_" (which are unlikely to ever match an in-game page) into a menu in the top pane. It also adds some ASH features for more conveniently dealing with HTML fields and text.
This isn't going to obsolete other forms of mafia scripting - relay scripts aren't really suitable for long, ongoing processes such as autoadventuring, since nothing appears in the browser until the script exits. Also, writing them requires a rather different mindset than the sequential execution of a normal script: if the relay script presents options for the user, they are actually read by an entirely separate invocation of the script than the one that displayed the options. The areas in which relay scripts will be the most useful are user-friendly configuration of other scripts, and presentation of options for the user to carry out in the relay browser themselves (since the script can simply link to any in-game activity).
I've provided one useful example of a relay script already: Breakable equipment fine tuning. Here's another one, more useful to script writers: it allows you to type in HTML code, and immediately see what it produces in the browser, and the form field values that it would submit.
PHP:
void main()
{
string[string] fields = form_fields();
string scr;
write("<html><body><form method=POST action=\"");
write(__FILE__);
writeln("\">");
if (fields contains "__scriptcode__") {
scr = entity_decode(fields["__scriptcode__"]);
remove fields["__scriptcode__"];
writeln("Form fields detected:<br>");
writeln("<table border=2>");
writeln("<tr><td>Name:</td><td>Value:</td>");
foreach key, val in fields {
write("<tr><td>");
write(entity_encode(key));
write("</td><td>");
write(entity_encode(val));
writeln("</td></tr>");
}
writeln("</table>");
} else {
writeln("This script allows you to quickly test HTML code, and see exactly what values are submitted by form elements.");
scr = "<input type=radio name=rb value=23 checked>this<br>\n<input type=radio name=rb value=42>that<br>\n<input type=checkbox name=cb checked>other<br>";
}
writeln("<p>");
writeln(entity_encode("Edit your code here. Don't include <html>, <body>, or <form> tags, as the script provides them."));
writeln("<br><textarea name='__scriptcode__' rows=15 cols=80>");
write(entity_encode(scr));
writeln("</textarea>");
writeln("<br><input type='submit' value='exec'> Your results will appear below:</p>");
writeln(scr);
writeln("</body></html>");
}
I'm planning on writing some further tools to assist in relay script writing.
EDIT: Oops, I uploaded a version of this script where I'd temporarily changed to method=GET for testing, instead of method=POST which is generally a better idea. It's a simple change on line 5 if you already downloaded the script.
Attachments
Last edited: