Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 110

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3798
Location: Pensacola, FL, USA

PostPosted: Thu Aug 18, 2016 12:31 pm   
 
Not that I am aware of.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Aug 18, 2016 8:27 pm   
 
I believe you can inline the image using #SUBSTITUTE and MXP. See https://www.zuggsoft.com/zmud/mxp.htm
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 110

PostPosted: 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
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3798
Location: Pensacola, FL, USA

PostPosted: 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.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 110

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3798
Location: Pensacola, FL, USA

PostPosted: 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.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 110

PostPosted: 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.

Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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
Reply with quote
Xerakon
Apprentice


Joined: 10 May 2011
Posts: 110

PostPosted: 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:

Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 3798
Location: Pensacola, FL, USA

PostPosted: Mon Aug 22, 2016 1:06 pm   
 
Looks like the trigger in question had a pattern of *1.
That looks more like an #ALARM.
_________________
Windows 10 Home Premium 64-bit
AMD Phenom II x6 1055T 2.8GHz 16GB
CMUD Pro v3.34
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: 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
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net