Howdy, Stranger!

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

Display problems with sideways scrolling text

Okay, so for a game I'm making I want a sideways-scrolling text region like the little snippets you get at the bottom of the TV news. Basically my idea is to wrap a string inside a timed repeat and on each loop through the repeat I remove the first character of the string. Then if the string is reduced below I certain length I append new text to it. This is almost, but not quite, working correctly:
<<set _scrollstring to "THIS IS A TEST! WATCH ME SCROLL! ">>
<span id="scrollregion">_scrollstring</span>
<<silently>>
    <<repeat 64ms>>
	   <<if _scrollstring.length lt 30>>
		<<set _scrollstring to _scrollstring + "LOTS OF SCROLLIE TEXT! HOORAY! ">>
           <</if>>
        <<set _scrollstring to _scrollstring.substring(1)>>
		<<set _dispstring to _scrollstring.substring(0,20)>>
        <<replace "#scrollregion">>_dispstring<</replace>>
    <</repeat>>
<</silently>>

The problem is that every so often the displayed string will briefly appear below its proper position, and in a huge font size. I can't see where in my code the font size could be modified, so I am very puzzled. Is this a bug in how Twine displays/replaces text, or am I missing something?

Thanks.

Comments

  • edited September 2016
    Well, it would seem that I am the biggest fool on the face of the Earth. It was all the exclamation marks in the displayed string that were doing it. If an exclamation mark becomes the first character displayed, the whole thing is interpreted as a heading.
  • A line starting with exclamation points is what defines a heading, yes.
  • So is there any way of getting the <<print>> macro to suppress markup inside the expression it's printing, and just print every character exactly as-is?

    Clearly in my case escaping the exclamation mark with a backslash is not an option.
  • edited September 2016
    BTW, if you really want to have exclamation points within your marquee, and not have them start a heading, you could do something like the following (untested, but should work).

    FIND:
    <<set _dispstring to _scrollstring.substring(0,20)>>
    
    REPLACE WITH:
    <<set _dispstring to _scrollstring.substring(0, 20).replace(/^!/, "&#33;")>>
    
    That will replace an exclamation point in the first position with it's numeric character reference—meaning that it will display as an exclamation point, but not trigger the heading markup.

    EDIT: Fixed the NCR ("&33;" ⇒ "&#33;").
  • Perfect! Thank you very much, that solves my problem.
  • Edited the code a bit, had the NCR messed up.
Sign In or Register to comment.