Using gosub without removing paragraphs from text?

Hey eveyone, so still trying to get my head around gosub.

I have part of the story where there’s a repeated paragraph here and there, but since other things aren’t the same, it’s going to get super messy to pull out each one and list them at the bottom. I can see myself making a mess of it. But if you leave them where they are, the program doesn’t like it because there’s a gosub and return in what it thinks should be straight forward text. (If you’re going down the path that doesn’t need the gosub). So, what’s the best way to handle that?

Do you just repeat the text in each section (might be easiest for small sections/single sentences I’m thinking.)

Otherwise I’m thinking you’d need to use *if labels for either a lable/goto or gosub/return. Or am I missing something?

for example if you wanted to repeat the middle sentence somewhere else.

He takes a step back, looking through the window where the first glimmer of dawn lights the horizon with an orange hue. 

*label para1

"What of the Furies?" his wife implores desperately. "Will they not seek justice if we were to murder one of our own?"

*if (option2 = "yes")
   *goto option 2

"It has been arranged. We will not end his life, the sun and rain on the mountain top will take care of that should the gods will it." He sighs, hating to see his wife in such pain but there is no help for it. 

I’m a bit confused as to what you’re actually wanting. Do you mean you want the middle sentence to appear in various places, but then the final line only appears if option2 = no, for instance?

In that case, I’d think you want something like this:


He takes a step back, looking through the window where the first glimmer of dawn lights the horizon with an orange hue. 

*gosub furies_implore

*if (option2 = "yes")
   *goto option_2

"It has been arranged. We will not end his life, the sun and rain on the mountain top will take care of that should the gods will it." He sighs, hating to see his wife in such pain but there is no help for it. 
*label option_2
*finish
*label furies_implore
"What of the Furies?" his wife implores desperately. "Will they not seek justice if we were to murder one of our own?"
*return

And then wherever you want the ‘What of the Furies’ text, you can just include *gosub and it’ll add that paragraph for you.

Or did you mean something else? I’m not sure I’m quite clear on what result you’re looking for, sorry…

2 Likes

Thanks @Fiogan, that’s what I thought would have to happen.

Kind of, I haven’t explained it very well. I’ve got an alternative track where you can remain an advisor rather than marry the Queen, so although some parts of the story are the same, other interactions will be a bit different. (You’re going to respond differently, offer advice rather than directly make the decisions etc). But yep, it means there is some repeated text for some of the background info and things. I think repeating single sentences and using a labels with an *if on the the goto command to send it back to the right story might be the best way to go from the sounds of it.

1 Like

Right, I see, thanks!

Another thought is, if it’s a two-possibility (or minimal numbers of possibilities) option, I’ve also found the multireplace function really helpful. I’m sure this example won’t quite work, since I haven’t seen the code, but for instance: If you had a variable called ‘position’, and 1 meant the PC is the advisor, and 2 meant the PC is the king, then you could do inline replacements like so:


"What do you think?" the queen asks.

@{position "My suggestion would be to require a decision by nightfall, Your Majesty|"My command is that they shall have a firm decision before the sun sets}."

She nods.

Then the first response is for the advisor, and the second for the king. That way all your text is right there, but it might be a little easier on the eyes/coding than using stacks of *if statements every paragraph or so.

I’m currently working on a situation where the PC may or may not have been injured, and some of the text is quite different but some is the same…so I’ve been using a mix of *gosub, *if, and @{} to try and make sure I’m following the concurrent timelines. It’s been a bit interesting, at times. XD Lots of experimenting still.

1 Like

I figured that it might be complicated if I tried to explain it “wordly”, but perhaps this simple chart can help you to understand how *gosub works.

Untitled Diagram

Imagine the <<Sticky Text>> as a snippet of copy-pastable note that you can put it anywhere and anytime you want it.

2 Likes