|
aldwyn Newbie
Joined: 15 Aug 2012 Posts: 1
|
Posted: 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! |
|
|
|
Edogg Beginner
Joined: 27 Feb 2011 Posts: 17
|
Posted: 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} |
|
|
|
Vijilante SubAdmin
Joined: 18 Nov 2001 Posts: 5182
|
Posted: 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 |
|
|
|
|
|