Can you use gosub label combined with a variable

I can’t seem to figure the right way out.

So I want use a variable to keep track of the relationshipt talks characters had with each other. But I don´t want to use a if-statement whenever I encounter a new position where a relationship talk may trigger, so I created a variable for counter and was hoping to use this variable in a gosub list hopping. I´ll give an example so it might be easier to understand.

*create dave 0

*fake_choice
    #talk to dave
        *gosub dave0
        *set dave +1
    #talk to dave again
        *gosub dave{dave}
        
*label dave0
some text
*return

*label dave1
some text
*return

At the moment the *gosub dave{dave} does not work, is there a possibilitie to make it run ind such a way, or do I have to continually ask if-statements to check in which dave you are?^^ sounds strange^^

Try this. I set this up so it doesn’t use actual arrays, but you can also use CS arrays which is probably the more “proper” way to do it.

*create dave 0

*label loop
*fake_choice
    *if (dave=0) #talk to dave
        *gosub dave0
        *set dave +1
    *if (dave>0) #talk to dave again
        *gosub {"dave"&dave}

*goto loop

*label dave0
some text
*return

*label dave1
some more text
*return

For more info, check here:

2 Likes

Here is a way you can do it; like above I’ve made it without using arrays. You can make it more simplified if you use refs instead of the *if block inside the first *gosub though.

*create dave_convo 1

*label talk_dave

*choice
	#Leave.
		*goto after_talk_dave
	#Talk to dave@{(dave_convo_1 > 1)  again|}.
		*gosub dave_index
		*goto talk_dave

*label after_talk_dave

You leave the house and go to your car...

*ending
*comment ----------dave_index------------
*label dave_index

*if (dave_convo = 1)
	*gosub dave_convo_1
*elseif (dave_convo = 2)
	*gosub dave_convo_2
*elseif (dave_convo = 3)
	*gosub dave_convo_3
.
.
.

*set dave_convo +1

*return
*comment ----------dave_convo_1------------
*label dave_convo_1

"Hey Dave, tell me about yourself."

"Sure, I'm..."

*return
*comment ----------dave_convo_2------------
*label dave_convo_2

"Hey Dave, tell me about your father."

"Sure, my father is..."

*return
*comment ----------dave_convo_3------------
*label dave_convo_3

"Hey Dave, tell me about your mother."

"Sure, my mother is..."

*return

1 Like

Thank you so much, I never thought of putting the whole thing in the {} it works just fine. How do I mark this as solved?