An approach for setting character speech style


#1

I don’t know if this is what this forum is for, so apologies up front if this doesn’t belong here. That said, I have some stretches of dialog where characters are talking back and forth. I find it useful to colorize each character’s speech to help clarify who’s talking. Also, I like to italicize thoughts without using quotes around them. I modified the Actor class to accommodate that so that I don’t have to remember to put that in the text.

[code]//support for changing the appearance of text for a character’s speech.
//keep in mind that sez(txt) and thinks(txt) take single quoted strings, so don’t forget to escape ’ chars (e.g., ‘I’m’, etc.)
//
//also, if you always use style elements (italic, bold, or underline) for a given character’s sez or thinks, you’ll need to
//reverse those tags in your supplied text. e.g., if you’ve defined
//
// isItalicThink = true
//
//then the following is the way to go to emphasize a phrase in the text being displayed (i.e., reverse the normal tag order)
//
// me.thinks(‘Well - that was odd!’)
//
//this isn’t necessary if you leave the style properties nil

enum sezDoubleQuote, sezSingleQuote;

modify Actor
//nil doesn’t use quotes at all
quoteChar = sezDoubleQuote
quoteCharThink = nil

//styles
isItalic = nil
isBold = nil
isUnderlined = nil
isItalicThink = nil
isBoldThink = nil
isUnderlinedThink = nil

//text color. nil doesn't set the color
txtColor = nil
txtColorThink = txtColor

sez(txt){ return sezBase(txt, quoteChar, isItalic, isBold, isUnderlined, txtColor); }
thinks(txt){ return sezBase(txt, quoteCharThink, isItalicThink, isBoldThink, isUnderlinedThink, txtColorThink); }

sezBase(txt, qc, i, b, u, tc){
    local t;
    t = qc == nil ? '' : (qc == sezDoubleQuote ? '<q>' : '\'');
    t += i ? '<i>' : '';
    t += b ? '<b>' : '';
    t += u ? '<u>' : '';
    if(tc != nil){ t += '<FONT COLOR=' + tc + '>'; }
    
    t += txt == nil? '' : txt;
    
    if(tc != nil){ t += '</FONT>'; }
    t += u ? '</u>' : '';
    t += b ? '</b>' : '';
    t += i ? '</i>' : '';
    t += qc == nil ? '' : (qc == sezDoubleQuote ? '</q>' : '\'');
    
    return t;
}

;[/code]

For example:

[code]me: Actor
location = startRoom
isItalicThink = true
txtColor = ‘blue’
;

mary: Person ‘mary’ ‘mary’ @startRoom "Mary. "
isHer = true
isProperName = true
txtColor = ‘red’
isItalicThink = true
;

< other coding stuff >

+++ HelloTopic
topicResponse (){
"You look around the room as Mary continues to paint her nails. Shes been staying here long enough that she’s
made changes to the decor and furnishings. You give her a quick nod. <<me.sez(‘Hello Mary,’)>> you say, breaking the silence.

    <.p><<mary.sez('Oh, hello!')>> she replies, looking up. <<mary.sez('I\'ve been wondering when you\'d show up.')>>
    
    <.p><<me.thinks('And here I thought she didn\'t even knew I existed,')>> you think to yourself. <<me.sez('So, what have you been up to?')>>
    you ask. ";
}

;[/code]

And so on.


#2

Hmm, attaching your own output filter and some regex work would allow you to do nicer syntax of topicResponse :wink: But that would be little too advanced now.


#3

Certainly too advanced for my level of understand of how the game engine works, that’s for sure. I appreciate the comment.