A simple link

I thought making this work would be simple but apparently I was wrong.

<<if $timeOfDay is 1>>
<<if $day is "Monday">>
<<link "Leah">>Leah<</Leah>>
<</if>>
<</if>>

basically I want this on a specific passage and to only show up at that specific time.

See the Documentation for how to code the link macro :wink:

<<link "Onward, Reginald!" "NextPassage">><</link>>
<<link [[Onward, Reginald!|NextPassage]]>><</link>>
<<link [img[onward.jpg][NextPasaage]]>><</link>>

There is also the [[Link]] markup

I was actually using this one once before.

<<link [img[onward.jpg][NextPasaage]]>><</link>>
the problem is that on that day and time nothing shows up.

see:

<<link "Leah">>Leah<</Leah>>

I think there is code from your passage that must be missing from your post…

The <<if>> were coded fine. So either the code around it gives you an issue, or the variables $day and $imeOfDay were not coded correctly.

Yup I messed that one up. It should have been $time instead of $timeOfDay

Now comes the hard part linking it to events thanks for the help

You could also combine the if conditions into one condition.

<<if $timeOfDay is 1 && $day is "Monday">>
<<link "Leah">>Leah<</Leah>>
<</if>>

yea I hadnt even thought of that! it would help clean up the code quite a bit. thanks for that

Am I understanding correctly that you want link text saying “Leah” that goes to a passage also titled “Leah”? The link macro is overkill for that—you can just have the markup [[Leah]].

esentially thats the passage I want to go to but its with a clickable picture. I think I have that part figured out. The part thats got me stumped at the moment is figuring out how to have two different story parts share the same passage without showing up at the same time.

Essentially, you just need a variable that you set somewhere before going to that passage and then in the passage itself, a structure like:

<<if $variable == true>>
     Here is the text of this part of the story.
    
     [[Next passage]]
<<else>>
     Here is the text of this other part of the story.
     
     [[New next passage]]
<</if>>

If you had more than two parts sharing a passage I’d suggest a switch tree, but for two a plain old <<if>> macro should be fine.

I was thinking of a switch but someone once told me you can be more versatile with if statments. what I was trying was

<<if $leahstory is 1>>
texthere
<<set $leahstory to 2>>
more text
<<set $leahstory to 3>>
3and so on till the end 
<</if>>

the other problem is that i may need to be able to come back to these events again. not sure if i want to make it a small bit of a grind or just a one shot build up to level

Okay, yeah, for that I would use a switch tree. If statements can be more versatile, but it doesn’t look like versatility is what you need here. Don’t use a multitool that’s okay at a wide variety of things when the specific tool made for the specific job you want to do is right there, you know?

If for some reason you specifically need to use <<if>>, the correct way to do what you’re trying to do would be this:

<<if $leahstory is 1>>
	text here
	<<set $leahstory to 2>>
<<elseif $leahstory is 2>>
	text here
	<<set $leahstory to 3>>
<<elseif $leahstory is 3>>
	etc. etc.
<</if>>

But it’s much easier to just do:

<<switch $leahstory>>
	<<case 1>>
		text here
		<<set $leahstory to 2>>
	<<case 2>>
		text here
		<<set $leahstory to 3>>
	<<case 3>>
		etc. etc.
<</switch>>
1 Like

for some reason both of these now leave my page blank

Are you initializing $leahstory first? You have to set a variable before you can check it and use its value to determine anything. If you don’t <<set $leahstory to 1>> anywhere, then the passage will be blank.

If you are initializing it, is it in StoryInit or some other passage? If it’s not in StoryInit, if you’re testing/previewing the Leah passage directly without going through the passage where $leahstory is initialized, that could be another reason why you’re not seeing it.

Yea at the very top of the passage its set to 1 and i have it set to 0 in story init

When you say at the very top of the passage, do you mean outside the if/switch tree structure? If it’s inside, then the “setting the variable to 1” is happening after the “checking whether the value of the variable is 1” and that would be why it’s blank.

If it’s outside, that’s also a problem because if you set $leahstory to 1 at the top of the Leah passage, it will reset to 1 every time someone views that passage and they will never get past the first part of the story, but in that case I have no idea why it would be blank.

Maybe you could post the code of the whole passage as it currently stands?

apparently setting $leahstory to 1 instead of 0 in storyinit worked