${text} not working

I have a simple lucktest running now and am trying to use the $ {texthere} command to reflect the score
No matter what I try, the text only updates with lucky, even though the unlucky option is working

In startup I have created
*create lucky false
*create lucktext “lucky”

I have also set Luck to 1 so as to ensure an unlucky result for testing

Here is the $ code:

#Sneak upstairs
				*label sneakup
				*set snuck_stairs +1
				*choice
					#Test your luck
						*gosub lucktestgosub
						You have been ${lucktext} with a score of ${luck}
						*choice
							*selectable_if (lucky = true) #Lucky
								You loiter around until Bill is distracted and so on

and here is the gosub code:

*label lucktestgosub
*temp lucktest 0
*rand lucktest 0 12
*if (luck > lucktest)
*set lucktext “”
*set luck -1
*set lucky true
*return
*else
*set lucktext “unlucky”
*set luck -1
*set lucky false
*return

Interestingly, if I set lucktext in the gosub from “” to eg “balloon” it doesn’t change the text, it still reads balloon
If I change the lucktext in startup to *create lucktext “” then I get no text

Any tips appreciated!

All the text in the gosub code you provided here is on the same level, without indents. Is it like that in your file?

1 Like

Sorry, an error on my part
Here is the gosub code

*label lucktestgosub
*temp lucktest 0
*temp lucktext ""
*rand lucktest 0 12
*if (luck > lucktest)
	*set lucktext "balloon"
	*set luck -1
	*set lucky true
*return
*else 
	*set lucktext "unlucky"
	*set luck -1
	*set lucky false
*return

You gotta remove the first *return, otherwise it returns before getting to *else. I bolded the one I meant:

*label lucktestgosub
*temp lucktest 0
*temp lucktext “”
*rand lucktest 0 12
*if (luck > lucktest)
*set lucktext “balloon”
*set luck -1
*set lucky true
*return
*else
*set lucktext “unlucky”
*set luck -1
*set lucky false
*return

3 Likes

If you already have *create lucktext “lucky”, you don’t need *temp lucktext “” in the subroutine, that variable already exists.

Indentation for *return is wrong: either delete the first one (like the commenter above suggested), or do that:

*label lucktestgosub
*temp lucktest 0
*rand lucktest 0 12
*if (luck > lucktest)
	*set lucktext "balloon"
	*set luck -1
	*set lucky true
    *return
*else 
	*set lucktext "unlucky"
	*set luck -1
	*set lucky false
    *return
2 Likes

many thanks for your help, unfortunatley I see now that my test isn’t working

all it is doing is looking at the variable for luck in startup and not comparing that to the randomly generated number

argh!

In the startup you have something like *create luck 1, right? Is “luck” here in uppercase or lowercase?
And is the whole gosub stuff in the same textfile as the rest of the scene?

Nevermind, just saw you managed to fix it

1 Like