Genesis Forums
https://www.genesismud.org/forums/

Marking in colour one word
https://www.genesismud.org/forums/viewtopic.php?f=37&t=3289
Page 2 of 3

Author:  cotillion [ 21 Nov 2015 15:30 ]
Post subject:  Re: Marking in colour one word

Hmm, I guess triggers which only highlight should be exempt from the loop detection somehow.
I'll see if I can improve it.

For now I'd recommend Alisas approach.

Author:  britanica [ 22 Nov 2015 02:16 ]
Post subject:  Re: Marking in colour one word

cotillion wrote:
Hmm, I guess triggers which only highlight should be exempt from the loop detection somehow.
I'll see if I can improve it.

For now I'd recommend Alisas approach.


Agree that Alisas approach is better for highlighting.

I currently only use the catch all trigger (.*) when checking for no obvious exits to display the mobile key pad. (viewtopic.php?f=37&t=3307). It currently disables itself when I quick walk.

Possibly a checkbox to exclude the trigger from the check could be added?

Author:  Carnak [ 21 Dec 2015 01:27 ]
Post subject:  Re: Marking in colour one word

As for the disabling of triggers, I use this to go around it. An alias I activate when I awaken.

function ListRegex(regex, str) {
if (! regex.global) {
throw new Error('Please set flag /g of regex');
}
return (str.match(regex) || []);
}
function escapeRegExp(str) {
return str.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
}
function replaceAll(str, find, replace) {
return str.replace(new RegExp(escapeRegExp(find), 'g'), replace);
}
function uniq(a) {
var seen = new Set();
return a.filter(function(x) {
return !seen.has(x) && seen.add(x);
});
}
function colors(str) {
var ColorList = [
["darkmagenta", "you", "You"],
["red",
// Health
"at death's door", "barely alive", "terribly hurt",
"in a very bad shape", "in agony", "in a bad shape",
"very hurt", "suffering", "hurt", "aching", "somewhat hurt",
"slightly hurt", "sore", "feeling well", "feeling very well",
// Low Durability
"a little worn down"],

["lime",
// High Durability
"in prime condition", "in a fine condition"],
["aqua",
// Progress
"a tiny amount of progress", "minimal progress",
"slight progress", "low progress", "a little progress",
"some progress", "modest progress", "decent progress",
"nice progress", "good progress", "very good progress",
"major progress", "great progress", "extremely good progress",
"awesome progress", "immense progress", "tremendous progress",
"fantastic progress"
],

["white",
// Names
gwc.gmcp.data.character.status.name,
// Equipment
"sturdy black greaves", "sturdy black bracers", "black platemail",
// Directions
//"north", "west", "east", "south", "up", "down"
],

//["ADDCOLOR",""]
];

for (k = 0; k < ColorList.length; k++) {
var regex = new RegExp(ColorList[k].slice(1).join('|'), 'g');
var matches = uniq(ListRegex(regex,str));
for (l = 0; l < matches.length; l++) {
str = replaceAll(str, matches[l], matches[l].fontcolor(ColorList[k][0]));
}
}
return str;
}
// Triggers
function actions(str) {
}
// Triggers END

var delay = 15;
var last = document.getElementsByClassName("line hanging-indent").length;
var timer = setTimeout(function check() {
var current = document.getElementsByClassName("line hanging-indent").length;
if (current != last) {
if (last>current) {last=current;}
for (last; last < current; last++)
{
var str = document.getElementsByClassName("line hanging-indent")[last].innerHTML;
actions(str);
document.getElementsByClassName("line hanging-indent")[last].innerHTML=colors(str);
}
}
setTimeout(check, delay);
}, delay);

$("#mudoutput").css("color","green");
gwc.output.append("Your settings have been updated!");

Author:  Carnak [ 21 Dec 2015 01:30 ]
Post subject:  Re: Marking in colour one word

Has anyone solved how to change keybindings on numpad in portal? I attempted something along these lines, but failed miserably.. Works if you want to bind some other keys though..

$(document).keydown(function(e) {
switch(e.which) {
case 109:
gwc.output.append("testing");
break;

default: return;
}
e.preventDefault();
});

Author:  cotillion [ 09 Jan 2016 15:41 ]
Post subject:  Re: Marking in colour one word

Carnak wrote:
Has anyone solved how to change keybindings on numpad in portal? I attempted something along these lines, but failed miserably.. Works if you want to bind some other keys though..

$(document).keydown(function(e) {
switch(e.which) {
case 109:
gwc.output.append("testing");
break;

default: return;
}
e.preventDefault();
});

You can do this by modifying the global keyMap object.
But that's subject to change in the future.

Author:  Vlek [ 16 Jan 2016 07:11 ]
Post subject:  Re: Marking in colour one word

Cotillion, could you please fix the issue with line breaks causing triggers to not fire or fire for only part of a given statement? If the word was long and at the end of a line, it could cause the word to not highlight correctly. Have the server send the complete strings and have the client do the linebreaking while keeping them in their own cubbied paragraphs so they can be used in the same way still.

Author:  cotillion [ 16 Jan 2016 11:55 ]
Post subject:  Re: Marking in colour one word

Vlek wrote:
Cotillion, could you please fix the issue with line breaks causing triggers to not fire or fire for only part of a given statement? If the word was long and at the end of a line, it could cause the word to not highlight correctly. Have the server send the complete strings and have the client do the linebreaking while keeping them in their own cubbied paragraphs so they can be used in the same way still.

This should not be happening with 'options screenwidth off' set.
It's supposed to be off by default for GWC users.

Author:  Vlek [ 17 Jan 2016 02:22 ]
Post subject:  Re: Marking in colour one word

cotillion wrote:
This should not be happening with 'options screenwidth off' set.


Bah, you're right! That looks like it did the trick. That's really weird though. Even if it's set to a specific number, that shouldn't separate them into different paragraphs and cause them to not highlight or work correctly. For instance, the obvious exits that get cut off at the end will not be clickable to travel in that direction. Also, I don't think it's off by default. I'm pretty sure it's preset to like 80.

I had made a bug report about this issue and you said that highlighting would have to be reworked. I'll update that there's a workaround.

Author:  Mayobe [ 06 Mar 2016 03:54 ]
Post subject:  Re: Marking in colour one word

Minor necro, but with the hilight issue I think it's worthwhile to add some kind of exemption or else just a special trigger because it would allow the user to store a map of keywords and colors/background-colors that could be modified from the command line.

For example, I could make an alias so that I could issue the command:

hilite apple red

which would add the key 'apple' to the map and associate it with the color red, until I decided to remove it later with another command.

Alternatively, if we could have programmatic access to the scripts themselves we could use the mentioned method and just make aliases that would alter the trigger value.

Author:  Vlek [ 08 Mar 2016 03:55 ]
Post subject:  Re: Marking in colour one word

Mayobe wrote:
I think it's worthwhile to add some kind of exemption or else just a special trigger because it would allow the user to store a map of keywords and colors/background-colors that could be modified from the command line.


That's already thoroughly doable. I have that setup right now. You're basically capturing everything, checking whether there's a word in your special highlight list, and then highlighting it based on the saved color value that you gave when you created the highlight rule using a console command. I'd strongly encourage, if you do go this route, to try to put as much cool stuff into the one all-capturing trigger as possible. It doesn't exactly play fair with other triggers.

Mayobe wrote:
Alternatively, if we could have programmatic access to the scripts themselves we could use the mentioned method and just make aliases that would alter the trigger value.


You do understand that you're using a webclient where, quite literally, everything is available to you. If you really wanted, you could plunge headfirst into https://genesismud.org/play/gwc.min.db935731c9d2118f.js and try to pull out the necessary functions to do whatever it is you want. HOWEVER, the normal shmuck that just wants red "apples" isn't going to go through the trouble. Plus, even if you were able to figure something out, that's not to say cotillion won't make a change a week later that thoroughly breaks your code. I've been down that road, it's only worth it if hacking webclients is the fun for you, not necessarily the game.

Page 2 of 3 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/