Linebreaks for strings in a temp variable


#1

Hi, I came across this issue last night as I was trying to program my stat screen.

My issue comes with trying to fit a decent amount of words into a single temporary variable. This is what I have:

*temp morale_flavour
*if morale >= 41
*set morale_flavour “You have an average amount of confidence. You are still daunted by considerable odds, but you do believe that you can perform most jobs with a decent amount of effort. There is nothing particularly out of place with your current psyche.”
*goto morale_text

While this does work, when I open the page it stretches the screen so that the entire variable is a single line of text, with no line breaks. If I try making line breaks into the code, it’ll throw me an exception, so for now I have no choice but to leave it as one big line.

I was wondering if there were any suggestions for a work-around for this, or an alternative strategy to get more text as a descriptor for statistics. Any help would be appreciated!


#2

This should work for yahs I can not take credit for this since @CS_Closet 's mention in a different thread.

*temp text1 “First sentence.”
*temp text2 “Second sentence.”
*temp text3 “Third sentence.”

*fake_choice
-#{text1} {text2} ${text3}
–Choice Body

So if you want to use the whole text you would want to basically do the same with your temp variable and break it into chunks.

*temp morale_flavour_1
*temp morale_flavour_2
*temp morale_flavour_3
*if morale >= 41
*set morale_flavour_1 “You have an average amount of confidence. "
*set morale_flavour_2 “You are still daunted by considerable odds, but you do believe that you can perform most jobs with a decent amount of effort.”
*set morale_flavour_3 " There is nothing particularly out of place with your current psyche.”
*goto morale_text

{moral_flavour_1} {moral_flavour_2} ${moral_flavour_3} would give you a slightly different result and you can linebreak now.


#3

@Kurisu

Is there any particular reason the flavor text has to be a stat? It might be easier if you just use a regular *if statement for this kind of thing so you can add formatting as needed:

*if morale >= 41
  You have an average amount of confidence.
  *line_break
  You are still daunted by considerable odds, but you do believe that you can perform most jobs with a decent amount of effort.
  *line_break
  There is nothing particularly out of place with your current psyche.
*goto next_section

It will still show the text if the conditions are met and will save you the hassle of making temps at all.


#4

Here’s a similar section from the Choice of Rebels stats screen – this flavour text is based on “cred_a” (your credibility with the aristocracy), but you could do the same with morale.


    ARISTOCRATS:
    *line_break
    *if cred_a > 299
      You have sympathizers and supporters across a surprisingly broad range of dissatisfied aristocrats.
      *line_break
    *if (cred_a < 300) and (cred_a > 200)
      Most aristocrats abhor your rebellion, but a handful are growing cautiously sympathetic.
      *line_break
    *if (cred_a < 200) and (cred_a > 99)
      You are unpopular with your fellow aristocrats - those who have heard of your little rebellion, anyway.
      *line_break
    *if (cred_a < 100) and (cred_a > 0)
      You are loathed by your fellow aristocrats as a bloody-handed traitor to your own kin.
      *line_break
    *if cred_a < 1
      You are the object of rabid hatred by the aristocracy, who will stop at nothing to see you hunted down and killed.
      *line_break

And if you want to use it repeatedly in the text rather than just the stats screen… in my chapter 2 I’ve got a *gosub morale_check which takes you to:


*label morale_check
At the moment,
*if morale < (followers/2)
  you sense that morale is bad among your followers -- more than half of them are miserable.
*if (morale >= (followers/2)) and (morale < followers)
  morale could definitely be better in the band; a significant minority of your followers are dispirited and would run away if the going got tough.
*if (morale >= followers) and (morale < (followers+20))
  the band's morale is good, though you don't know how well it will hold up under a serious challenge.
*if morale >= (followers+20)
  morale is outstanding among your band;
  *if wealth > 9 
    you shouldn't need to spend any more on boosting their spirits.
  *if wealth < 10 
    they're confident in your leadership and in their future.
*return

[I know it could be done with \*elseif and \*else, but I believe that would require lots of \*goto, which for some reason feels more fiddly to me than additional >< statements.]


#5

Thanks for the quick replies guys!

Yeah, there was actually no real reason for it to be kept in a variable, since I’d only be calling it in the stat screen anyways. I think I’ll use the method that CS_Closet and Havenstone mentioned, though I’ll keep Pace’s suggestion in mind too since that’ll be useful if I actually need to use temps.

Thanks again.


#6

If you’re using Notepad++ you can go to the top toolbar’s “view” and select ‘word wrap’ that’ll make the text fit your screen size and prevent horizontal scrolling, automatically creating multiple line lines.

Like so:


#7

I actually do use Notepad++, but I use the vertical edge settings from the preferences instead, and then just line-break manually for readability. It seems that CScript automatically linebreaks words in the game, so there’s no need for me to make sure margins don’t fit or anything.