Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Is it possible to not have to format a certain word each time you type it?

Hello all, pfm2001 here.

I'm curious if it's at all possible to make Twine automatically format certain text? I'm trying to make it so each time a certain character's name is mentioned, that it will be their color, such as "Did you hear about Steve? I heard he and Alex get along very well."

I'm wondering because it's very tedious to keep typing "(color: #33CCCC)[ROBOT EXTRAORDINAIRE] and the like.

My sincerest thanks for reading this post, and especially if you have an answer.

Comments

  • You can combine a footer tagged passage with some (replace:) macros to do what you want.

    Place the following in a footer tagged passage, you can name the passage whatever you want but you should make it something simple because you will need to use it within a CSS select later on. The name I used in this example was style-names.

    note: The documentation of the (text-color:)/(color:) macro states that the CSS colour is a String and therefor should be wrapped in quotes.
    (replace: 'Steve')[(color: "#6600CC")[Steve</span>]]
    (replace: 'Alex')[(color: "#00CC00")[Alex]]
    
    ... add a (replace:) macro for each of the names you want to be coloured.

    You can use the following CSS to stop the footer tagged passage adding unwanted line-breaks to the bottom of the current passage, if you named your footer passage something other than style-names then you will need to alter the CSS selector to include the name you used instead.
    tw-passage tw-include[type="footer"][title="style-names"] {
    	display: none;
    }
    
  • You could try putting the formatting and the name in a variable. Has to be HTML/CSS formatting, not Twine formatting though as it'll be formatted by the browser, not the Twine engine:
    <<set $steve to "<div style='steve'>Steve</div>">>
    

    Then when you want to use the name, just <<$steve>> (or, if you have sugarcube, $steve)

    This will work when you have both Alex and Alexander on screen at the same time.
  • Thank you!
Sign In or Register to comment.