SOLVED: While checking cycle, it won't show link to another passage

so I have this simple cycle for day/night

<<newcycle 'time' 4>>
    <<phase 'Morning' 'Noon' 'Evening' 'Night'>>
<</newcycle>>

but when I put this code so the player will be able to sleep when it’s night or evening:

<<if Cycle.check('time', 'Night')>>[[Go to Sleep->DormSleep]]<</if>><<if Cycle.check('time', 'Evening')>>[[Go to Sleep->DormSleep]]<</if>>

it won’t appear in the passage.
any help would be appreciated

Edit: found a solution, so to anyone who needs it:

<<if Cycle.get('time').current() is 'Evening' or 'Night'>>[[night night|DormSleep]]<</if>> 
1 Like

That conditional is not doing what you seem to think it is. As written it’s always truthy, so the link will always be available.

The logical conjunction (and, &&) and disjunction (or, ||) operators work upon complete sub-expressions, they do not provide junction or union functionality.

In other words, you seem to think it’s doing:

Cycle.get('time').current() is ('Evening' or 'Night')

When its actually doing:

(Cycle.get('time').current() is 'Evening') or 'Night'

Regardless of what the first part results in, the latter ('Night') will always be truthy.

Assuming that Cycle.get('time').current() is actually what you want to be doing, then you’ll want one of the following to actually achieve what you’re attempting.

Complete sub-expressions:

<<if Cycle.get('time').current() is 'Evening' or Cycle.get('time').current() is 'Night'>>…

Complete sub-expressions w/ cached current cycle value:

<<set _currentTime to Cycle.get('time').current()>>
<<if _currentTime is 'Evening' or _currentTime is 'Night'>>…

Array matching:

<<if ['Evening', 'Night'].includes(Cycle.get('time').current())>>…

Chapel’s cycles system may have a built-in way to achieve the same result, but I’m not familiar enough with it to say.

1 Like