Ive got a game setting that turns swearing on or off. If the mode is on, you see swearing in the text and dialog. I saved this setting in a bool and by default its true: bool matureLanguage = true;
I wrote this String, if matureLanguage is false, instead of the inputted swear word string, display a "censor" of characters:
String swear(String sSwearWord)
{
if (matureLanguage == true)
{
return sSwearWord;
}
else
{
sSwearWord = "$%#@";
return sSwearWord;
}
}
However, I dont know exactly how to display this (with Display, Say or in a dialog). This was my best attempt:
Display("Go %d yourself.", String swear(Fuck));
How would I display this in dialog, say command or with display?
You were very close. You just have to do this (which also works for character.Say):
Display("Go %s yourself.", swear("Fuck"));
Also you don't have to store the censored word into a string variable before returning it, you can simply just return the string itself:
String swear(String sSwearWord)
{
if (matureLanguage == true)
{
return sSwearWord;
}
else
{
return "$%#@";
}
}
Hi Ryan!
Thanks for your help, I got it working now! Man, I was sooo close...Im slowly learning :P
Now, one last question:
This could create a problem when I activate speech, since the text can be censored but the same audio file with swearing will be played. I guess I can use "if/ else", but then I would have to write the dialog line twice and defeats the purpose of my above script. Is there a way to make the call to the audio file a variable aswell? Something like:
function swearAudio(int swearFile)
{
if matureLanguage == true
{
return swearFile; //which would be file #2 (cEGO2.wav)...the line with swearing
}
else
{
return 1; //which would be file #1 (cEGO1.wav)...the line with a "Beep" sound instead
}
}
This is normally how we'd write the line with the audio file for speech:
cEgo.Say (&2 "Go %s yourself.", swear("Fuck"));
Is it possible to make the "&2" audio file call a variable? (the number 2 here would reflect cEgo2.wav)...something like:
cEgo.Say("%d "Go %s yourself.", swearAudio(2), swear("Fuck"));
This should do it:
cEgo.Say("&%d Go %s yourself.", swearAudio(2), swear("Fuck"));
The most convenient way would be to use two consecutive audio files; that way you can use this:
int swearAudio(int x) {
if (matureLanguage) return x;
return x+1;
}
Awesome, thanks Khris!
;D