Page 1 of 1

Question about responsible use

Posted: 10 Feb 2016 10:17
by Mayobe
There's a couple of things that I want to do that would require a universal trigger (followed by a dynamic regex within the script), but I'm concerned about implementing this because I'm not 100% clear on the script interpretation. I suspect and hope that scripts are executed on the client machine, but I want to confirm that this is the case before writing such a script, since I imagine it could place undue strain on the server otherwise.

Am I good to go?

Re: Question about responsible use

Posted: 10 Feb 2016 11:37
by Aerylina-leafschade
I'm curious about what you mean, I hope someone replies to explain the reply you seek as I'm curious about triggers and stuff.

Re: Question about responsible use

Posted: 10 Feb 2016 11:52
by cotillion
Web Client scripts are client side so you'r fine as long as you don't send too many commands to the server.
You might run into issues with the trigger being auto-disabled if it fires too often.

Re: Question about responsible use

Posted: 10 Feb 2016 14:44
by Mayobe
Cool. Thanks, cotillion. It should only fire once per line and will only perform gwc.output.replace() calls, so no server spamming.

How does the auto-disable trigger? Is it just trigger count per some amount of time, or... ?

The script I have in mind would trigger on every line, so it could be an issue.

Actually, to be concise, what I'm planning to do is throw a handful of one-word strings (character names) into an array on userdata and then have the trigger highlight them when they appear. The issue being that the actual trigger can't read from userdata AFAIK, so it would have to be a universal trigger and then I would run a string.replace within the script in a foreach that iterates the array. (Or I'll probably look up JS regex to see if I can just compose a single regex as a string and run it through replace)

--

Aerylina-leafschade, the web client triggers/aliases can run short JavaScript programs. I was just checking to make sure that the script was being run on my machine locally and not on the Genesis server. If it were being run on the server then it would have been irresponsible to run a compute-heavy script like the one that I'm planning. I don't think that my script alone would have caused trouble, but if everyone used a similar script it would generate a lot of extra work for the server.

Some info if you're curious about triggers and aliases:

*When writing a plain alias you can use $1, $2, $3 to refer to arguments provided:
alias for "test"
"say TESTING: $1"
Then during play type: "test helooooo"
The command sent to the server should be "say TESTING: helooooo"

*When using a regex trigger the match is args[0] and the capture groups are args[1...?].
*If you're not familiar with regex syntax you can learn it here: http://www.regular-expressions.info/
*And test/debug here: https://regex101.com/#javascript

*Special functionality is exposed through the gwc object:
- gwc.connection.send("fart"); //send the 'fart' command to the server (your character will fart)
- gwc.output.append("HELLO WORLD"); //append 'HELLO WORLD' to your local output (I think nothing gets sent to the server.)
- gwc.output.color("magenta"); //set the text color of the previous line to magenta. (http://www.w3schools.com/colors/colors_names.asp)
- gwc.output.color("#00FF00", "white"); //set the color of the previous line to green on a white background (http://www.w3schools.com/colors/colors_picker.asp)
- gwc.output.replace("orc", "kitten"); //replace the word "orc" with the word "kitten" (on your display only)

Code: Select all

Trigger on regex: .*?coin.*
Script:
var str = args[0].replace(/(coins|coin)/g, '<span style="background-color: rgb(64,64,64); color: yellow;">$1</span>');
gwc.output.replace(args[0], str, true);
The words 'coin' and 'coins' will have a grey background and yellow text. Note the use of the 'g' regex option to allow multiple replacements in a single line (since the word may appear more than once in the line).

- gwc.userdata
This object is persistent and linked to your scripts/account. Script data is per user and stored on the server, so you can change machines and your scripts will still be available to you (if you're using the web client). The gwc.userdata object can be used to store variables for use between alias and trigger scripts. For example, you could write an alias 'disembarking' and have it do:

Code: Select all

gwc.userdata.disembarking = !gwc.userdata.disembarking;
var str = "Auto-Disembark Set To: ";
if(gwc.userdata.disembarking) { str += "on";  }
else                          { str += "off"; }
gwc.output.append(str);
gwc.output.color("cyan");
Then you can set up a trigger for "leaves the ship" and have it run:

Code: Select all

if(gwc.userdata.disembarking) { gwc.connection.send("disembark"); }
Now you can use the command "disembarking" from the command line to turn the behavior on and off. When it's on you will automatically leave a ship when you see someone else leave (like the captain when you arrive at the destination).

Some words from Cherek about the GWC API and about GMCP: https://www.genesismud.org/forums/viewt ... =37&t=2947

Be bold and experiment!

Re: Question about responsible use

Posted: 10 Feb 2016 15:05
by Aerylina-leafschade
-reads everything- dayum.


I haven't programmed like that since 1999 web design. 0.0

Re: Question about responsible use

Posted: 10 Feb 2016 15:08
by Mayobe