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
aldwyn
Newbie


Joined: 15 Aug 2012
Posts: 1

PostPosted: Sat Jan 02, 2016 7:50 am   

Script to replace a word with a randomly generated phrase
 
I'm wanting to set up a trigger that will essentially take anytime I try to speak a certain word like "curse" using say or yell and draw randomly from a selection of phrases to put in it's place. I've been trying for hours to read the help files to figure it out but thought it might be easier to just ask on here for any advice.

Thanks!
Reply with quote
Edogg
Beginner


Joined: 27 Feb 2011
Posts: 17

PostPosted: Sun Jan 03, 2016 5:05 pm   
 
make a string list variable to hold the certain words like "curse":
#var cursewords {curse1|curse2|etc}

make a trigger (make it a regular expression trigger):
#trigger {@cursewords} {#VAR replacement {%case( %random(1, 3), "phrase1", "phrase2", "phrase3")}}
#sub {@replacement}
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Mon Jan 04, 2016 9:24 am   
 
You are looking for a command input trigger. #ONINPUT

I would also suggest using a regex instead of zScript patterns because of the word boundary wildcard.
Code:
#VAR ReplacePhrases {stuff1|stuff2|stuff3}
#ONINPUT {\b(?:word1|word2|word3)(?:ed|ing|s)?\b} {#SUB {%item(@ReplacePhrases,%random(1,3))}} "" {regex}
_________________
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