Variable/IF problem
TyCamden
11 May 2016, 20:52The following test code is not working right, especially the 3 IF statements at the end of it. Can anyone help?
[[intro]]:
var psg1 = 0
var psg2 = 0
var psgtotal = 0
This is my test story using Squiffy for the first time.
First I will create an [[option]] for going to the next section.
[[option]]:
Now I will create [passage 1] and [passage 2] before also creating [[section 2]].
[passage 1]:
var psg1 = 1
var psgtotal = psgtotal + 1
This is the text for the first passage link.
[passage 2]:
var psg2 = 1
var psgtotal = psgtotal + 1
This is the text for the second passage link.
[[section 2]]:
When a new section appears, any unclicked passage links from the previous section are disabled.
{if psg1=1: My variable psg2 indicates you clicked Passage 2.}
{if psg2=1: My variable psg2 indicates you clicked Passage 2.}
{if psgtotal=0: My variable psgtotal indicates you clicked NO Passage.}
leobos67
11 May 2016, 22:07There is confusion between javascript variables and squiffy attributes. The following code works as you want:
[[intro]]:
set("psg1",0)
set("psg2",0)
set("psgtotal",0)
This is my test story using Squiffy for the first time.
First I will create an [[option]] for going to the next section.
[[option]]:
Now I will create [passage 1] and [passage 2] before also creating [[section 2]].
[passage 1]:
set("psg1",1)
set("psgtotal",get("psgtotal")+1)
This is the text for the first passage link.
[passage 2]:
set("psg2",1)
set("psgtotal",get("psgtotal")+1)
This is the text for the second passage link.
[[section 2]]:
When a new section appears, any unclicked passage links from the previous section are disabled.
{if psg1=1: My variable psg1 indicates you clicked Passage 1.}
{if psg2=1: My variable psg2 indicates you clicked Passage 2.}
{if psgtotal=0: My variable psgtotal indicates you clicked NO Passage.}