Redirecting the player based off of a variable

I am trying to send the character to a different room based off of which character they selected on a previous screen but it always redirects to the first option no matter what the variable is set to. Any ideas? For clarification, it is working as if the variable is always 1 even if its set to 0 or 3 or any other number and simply redirects to “The Beginning”. I have tried putting it all in square brackets like the code at the bottom but that doesn’t fix it either. Not sure what to do as this seems to be quite a rare problem. Any help or suggestions appreciated

Twine 2.7.1.0

(if:$Character = 1)(go-to:"The Beginning")(else-if:$Character = 2)(go-to:"The Beginning2")(else-if:$Character = 3)(go-to:"The Beginning3")(else-if:$Character = 4)(go-to:"The Beginning4")

The code in brackets I referenced:

[(if:$Character = 1)(go-to:"The Beginning")(else-if:$Character = 2)(go-to:"The Beginning2")(else-if:$Character = 3)(go-to:"The Beginning3")(else-if:$Character = 4)(go-to:"The Beginning4")]

Your main problem is that the (if:) macro attaches to a hook, which controls what is run and what is not, but you’ve left the hooks out.

Another issue is that Harlowe doesn’t actually have an = operator, the correct operator is is

The correct version is:

{(if:$Character is 1)[
    (go-to:"The Beginning")
](else-if:$Character is 2)[
    (go-to:"The Beginning2")
](else-if:$Character is 3)[
    (go-to:"The Beginning3")
](else-if:$Character is 4)[
    (go-to:"The Beginning4")
]}
1 Like