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

Alias/Trigger non alphanum character issue
https://www.genesismud.org/forums/viewtopic.php?f=38&t=3424
Page 1 of 1

Author:  Mayobe [ 29 Jan 2016 10:04 ]
Post subject:  Alias/Trigger non alphanum character issue

I was trying to write a trigger for coloring noob chat earlier and it seems that it doesn't like to detect angle braces. I tried standard

<Newbie>

and regex

\<Newbie\>

but I had no luck with either.

Later on I was coloring health reports and noticed that "is at death's door." was not being colored. I changed it to "is at death" and it started working.

So it looks like there may be some issues with triggers parsing non alphanumeric characters?

Not a huge issue, but kind of annoying.

Author:  britanica [ 29 Jan 2016 12:47 ]
Post subject:  Re: Alias/Trigger non alphanum character issue

Currently the trigger receives the text as the html string that will be displayed in a <div>

This means that using html encoding is currently required.

Code:
' = &#39;
>  = &gt;
< = &lt;

at death's door  =   at death&#39;s door
<Newbie> = &lt;Newbie&gt;



Google html encoding for a full list of characters that will be changed.

Author:  Mayobe [ 29 Jan 2016 14:04 ]
Post subject:  Re: Alias/Trigger non alphanum character issue

The info is appreciated. I do hope that it gets resolved soon though.

Author:  Mayobe [ 03 Feb 2016 05:43 ]
Post subject:  Re: Alias/Trigger non alphanum character issue

Okay, I'm running into this again.

I wrote this thing:

Code:
Name: <knife and coin>
Type: regexp
Pattern: .*?(kni|dirk|dagger|stiletto|coin).*

Execute the following javascript:

var str = args[0].replace(/(knife|knives|dirks|dirk|daggers|dagger|stilettos|stiletto)/gi, '<span style="background-color: rgb(40,40,40); color: magenta;">$1</span>');
str = str.replace(/(coins|coin)/g, '<span style="background-color: rgb(64,64,64); color: yellow;">$1</span>');
gwc.output.replace(args[0], str, true);


And it works in general, but I noticed that it wasn't triggering in battle on lines like this:
Quote:
You cut the watching small male orc's body with your jagged sharp knife.


So I tested by repeating the line and it's the apostrophe that's causing the failure.

Author:  Vlek [ 12 Feb 2016 08:37 ]
Post subject:  Re: Alias/Trigger non alphanum character issue

That's some pretty funky alias writing.

Here's mine where I highlight newbie messages based on the user talking and add a timestamp instead of the "newbie" tab. Keep in mind this isn't going to be plug and play because I have base things saved in my userdata that you're obviously not going to have.

Pattern:
Code:
Newbie&gt; (\w+).*:.*


Code:
Code:
if ( args[1] !== undefined ){
  //gwc.output.append( args.slice(1) );
  if ( gwc.userdata.newbie_messenger_list === undefined ){
  //Create the dictionary if it doesn't exist to house players:colors
  gwc.userdata.newbie_messenger_list = {};
  }
  if ( gwc.userdata.newbie_messenger_list[ args[1] ] === undefined ){
  //Add the person to the list and assign them a color after randomly selecting an unused one
  gwc.userdata.newbie_messenger_list[ args[1] ] = gwc.userdata.random(gwc.userdata.colors);
  }
  //Now finally color the message accordingly
  gwc.output.color( gwc.userdata.newbie_messenger_list[ args[1] ] );
}

var currentTime = new Date();
gwc.output.replace('Newbie', currentTime.getHours() + ':' + ( currentTime.getMinutes().toString().length > 1 ? '' : '0' ) + currentTime.getMinutes(), true);

if ( gwc.userdata.music.enabled ){
  gwc.userdata.music.ding.play();
}

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