intfiction.org

The Interactive Fiction Community Forum
It is currently Mon Nov 19, 2018 3:49 pm

All times are UTC - 6 hours [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Thu Aug 02, 2018 1:07 pm 
Offline

Joined: Wed Jul 25, 2018 8:55 am
Posts: 18
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 - </i>that<i> 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;
    }
;


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. ";
    }
;


And so on.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Thu Aug 02, 2018 5:28 pm 
Offline

Joined: Sat Jul 16, 2011 3:48 pm
Posts: 309
Hmm, attaching your own output filter and some regex work would allow you to do nicer syntax of topicResponse ;-) But that would be little too advanced now.


Top
 Profile Send private message  
Reply with quote  
PostPosted: Sat Aug 04, 2018 6:14 pm 
Offline

Joined: Wed Jul 25, 2018 8:55 am
Posts: 18
Certainly too advanced for my level of understand of how the game engine works, that's for sure. I appreciate the comment.


Top
 Profile Send private message  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 7 guests


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 post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group