|
Xerakon Apprentice
Joined: 10 May 2011 Posts: 111
|
Posted: Thu Aug 18, 2016 2:21 am
Emojis? |
Is it possible to trigger an image to replace the words being said? For example -
When someone says Kappa, I want to replace the word with the Kappa emoji image. Right now, I've got a simple snippet up:
Code: |
Trigger: Kappa
#IM C:\Images\kappa.jpg
#WAIT 5000
#IM |
This basically just displays it in a popup for 5 seconds. But I was wondering if it would be possible to replace the text on the line like in a chatroom?
Thanks. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Thu Aug 18, 2016 12:31 pm |
Not that I am aware of.
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Xerakon Apprentice
Joined: 10 May 2011 Posts: 111
|
Posted: Sat Aug 20, 2016 6:49 pm |
Well, we've made some progress atleast to the inline function:
Script is as follows:
Code: |
<trigger priority="20720" id="2076">
<pattern>(*)kappa(*)</pattern>
<value>#SUB {%1<IMAGE C:\Users\Jeremy\Desktop\kappa.gif>%2}</value>
</trigger>
|
As you can see - it currently will not allow any words after the image. And will only recognize one trigger inline. Have I missed something? I have tried with and without Repeat within line checked.
Thanks,
J |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sat Aug 20, 2016 9:31 pm |
#SUB replaces the entire matched pattern, and * is very greedy
#TR {(%w) kappa (%w)} {#SUB {image}}
would only match single words on either side.
but i would use:
#TR {kappa} {#SUB {image}}
you need to enable the repeat within line option for it to fire more than once in the same line. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Xerakon Apprentice
Joined: 10 May 2011 Posts: 111
|
Posted: Sun Aug 21, 2016 1:39 am |
Hey shalimar,
I went with your second suggestion with the repeat within line option enabled.
It works perfectly with one mention. When you have more, however, it starts behaving oddly. See below.
Any ideas? Or is this just a MXP/IMAGE limitation?
Thanks. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Sun Aug 21, 2016 3:46 am |
I think it has to do with the fact that images have no set character width, so its having issue with the spacing.
Not sure what can be done about it.
Maybe instead of #SUBing the images in you could use #SAYADD to append the image to the end of the line?
No need for it to repeat within line then, which seems to be the issue with images. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Aug 21, 2016 1:33 pm |
Try doing the repeat in code instead with only 1 substitution.
#REGEX {\bkappa\b} {#PSUB {%subregex(%line, "\bkappa\b", "<IMAGE ...>")}} |
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Xerakon Apprentice
Joined: 10 May 2011 Posts: 111
|
Posted: Sun Aug 21, 2016 5:00 pm |
I'll admit that I am out of my element with REGEX and such.
Using your code and changing only the ... in the image tag to add the filepath, it appeared to only echo the image information a few times as well as the mud-based prompt.
|
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Sun Aug 21, 2016 5:31 pm |
The use of regex in this case is to catch word boundaries so that it will only match when the text you want to replace appears to be a distinct word. The trigger I provided should not have the Repeat with Lines flag set. But it also looks to be having some other problems. It looks like #PSUB did not activate the MXP and all the ANSI color information was lost.
Scrap the old and now we get a little more complex...
Code: |
#REGEX {\bkappa\b} {}
#COND {(*)} {
#GAG
#MXP {%subregex(%1, "\bkappa\b", "<IMAGE C:\Users\Jeremy\Desktop\Emojis\kappa.bmp>")}
} {reparse|ansi} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
Xerakon Apprentice
Joined: 10 May 2011 Posts: 111
|
Posted: Sun Aug 21, 2016 10:05 pm |
Hey Vijilante - Thanks so much for helping with all of this!
So, That worked perfectly, no matter what I did with it!
However, when I tried to add a second emoji (just copied the code and changed kappa to pride)... well, it works fine if you do it on its own line. But if you try to have two emojis on the same line in any way, it actually crashed cMud. But gave me this error:
|
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Mon Aug 22, 2016 1:06 pm |
Looks like the trigger in question had a pattern of *1.
That looks more like an #ALARM. |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: Tue Aug 23, 2016 6:49 am |
I am not really sure why it caused a trigger loop, but let's reduce it to 1 trigger and eliminate that problem. Because %subregex uses backslashes to reference captured data and we not have some I felt it prudent to cover all backslashes with proper escaping.
I was sort of expecting you would want many emoji. If you are putting all the emoji pictures in one place then a simple list would do for the solution; otherwise you will want to use a record variable and there will be a few other changes. I added the "no trigger" option which turns off "trigger on trigger" which should prevent any sort of trigger loop.
Code: |
#VAR EmojiList {kappa|pride}
#REGEX {\b(?:@EmojiList)\b} {}
#COND {(*)} {
#GAG
#MXP {%subregex(%1, %concat("\b(",@EmojiList")\b"), "<IMAGE C:\\Users\\Jeremy\\Desktop\\Emojis\\\1.bmp>")}
} {reparse|ansi|notrig} |
|
|
_________________ The only good questions are the ones we have never answered before.
Search the Forums |
|
|
|
|
|