Lines not showing after an if: statement

Twine Version: 2.7.1
[also choose a Story Format tag above]

I’m not sure why this code isn’t working. any help appreciated

You find 2 large paintings hung up on the wall. They depict an epic battle between Greek and Turkish warriors.(if:$Perception is true)[(print:" Using your candle flame you can also see some protrusions from the paintings. It looks like you could reach out and grab them")(show:?SpookyScary)(show:?SkeletonsSend)(show:?ShiversDown)(show:?YourSpine)]

I am not sure what would be wrong with this code, because we seem to be missing information:

  • Is $Perception set to true somewhere before this code? (because the code below showed the second sentence just fine)
(set:$Perception to true)
You find 2 large paintings hung up on the wall. They depict an epic battle between Greek and Turkish warriors.(if:$Perception is true)[(print:" Using your candle flame you can also see some protrusions from the paintings. It looks like you could reach out and grab them")(show:?SpookyScary)(show:?SkeletonsSend)(show:?ShiversDown)(show:?YourSpine)]
  • What do the code below refer to?
(show:?SpookyScary)(show:?SkeletonsSend)(show:?ShiversDown)(show:?YourSpine)

Yeah sorry for not being more clear, I want to show some hidden lines using those show commands, but it’s only showing the second sentence. I don’t understand why, assuming perception is true, that it only shows the second sentence not the hidden lines

Then this code above is the reason nothing is happening. Do you have hooks in your passage called: SpookyScary, SkeletonsSend, ShiversDown adn YourSpine?

I have code such as:

|SpookyScary)[There is a cool chill in the air]

etc for each of those

The issue is the order of execution, and how the (show:) macro works.

The content of a Passage is processed/executed from left to right, starting from the first line and working its way down to the last line. The (show:) macro scans the current HTML structure of the page, looking for any instances of the supplied target, and “reveals” each instance it finds.

So if your code looks like the following (1)…

You find 2 large paintings hung up on the wall. They depict an epic battle between Greek and Turkish warriors. \
(if: $Perception)[{
	Using your candle flame you can also see some protrusions from the paintings. It looks like you could reach out and grab them
	(show: ?SpookyScary)
	(show: ?SkeletonsSend)
	(show: ?ShiversDown)
	(show: ?YourSpine)
}]

|SpookyScary)[There is a cool chill in the air]

…then if the $Perception variable has a value of true the (show: ?SpookyScary) macro call gets executed before the line that defines the SpookyScary Hidden Hook is processed. Which means the HTML element that represents that Hook won’t yet exist in the HTML structure of the page, so the (show:) macro can’t “reveal” it.

You can test this behaviour yourself by temporarily moving the |SpookyScary)[There is a cool chill in the air] definition to the start of the content…

type or paste code here|SpookyScary)[There is a cool chill in the air]

You find 2 large paintings hung up on the wall. They depict an epic battle between Greek and Turkish warriors. \
(if: $Perception)[{
	Using your candle flame you can also see some protrusions from the paintings. It looks like you could reach out and grab them
	(show: ?SpookyScary)
	(show: ?SkeletonsSend)
	(show: ?ShiversDown)
	(show: ?YourSpine)
}]

…which results in the (show:) macro call now being able to find the Hook’s representative HTML element.

note: The (show:) macro is normally called in response to an end-user’s interaction with the current page.

There are (at least) two ways to resolve this issue:

1: Don’t use Hidden Hooks.

You find 2 large paintings hung up on the wall. They depict an epic battle between Greek and Turkish warriors. \
(if: $Perception)[\
	Using your candle flame you can also see some protrusions from the paintings. It looks like you could reach out and grab them
	
	There is a cool chill in the air
	
	The contents of the SkeletonsSend hook
	
	The contents of the ShiversDown hook
	
	The contents of the YourSpine hook
]

2: Move the code that “reveals” those Hooks to the end of the Passage.

You find 2 large paintings hung up on the wall. They depict an epic battle between Greek and Turkish warriors. \
(if: $Perception)[{
	Using your candle flame you can also see some protrusions from the paintings. It looks like you could reach out and grab them
}]

|SpookyScary)[There is a cool chill in the air]

|SkeletonsSend)[The contents of SkeletonsSend]

|ShiversDown)[The contents of ShiversDown]

|YourSpine)[The contents of YourSpine]

(if: $Perception)[{
	(show: ?SpookyScary)
	(show: ?SkeletonsSend)
	(show: ?ShiversDown)
	(show: ?YourSpine)
}]

(1) You will likely notice that I changed your original code slightly. My variation uses uses Escaped line break & Collapsing Whitespace markup, along with line-breaks & indentation, to make it a little easier to read.
It also removes the usage of the is keyword comparison operator, which is redundant when determining if a Boolean variable is true or false.

Thank you very much