Hi, I’m working on a selection system where it gets called up by
(link-replace: “select”)[(display: “SELECT”)]
The passage SELECT is working fine when I check but when I test the whole thing, all the links become unclickable and white. Is there a way to fix that? I’m using chrome with the default Harlowe.
Sorry, it’s my first time here, this is the code for the passage, its a bit repetitive so I only put in three lines of it but it’s basically copy and paste.
(click:?back)[(replace:?select)[You decide not to select anything]]
(click:?red_key)[(replace:?select)[(set:$select = “red key”)You selected the (print:$select).]]
(click:?blue_key)[(replace:?select)[(set:$select = “blue key”)You selected the (print:$select).]]
(click:?paper)[(replace:?select)[(set:$select=“paper”)You take out your (print:$implement).]]
I tried just copying and pasting the passage code into the initial passage but it still had the same problem.
As your code stands, it works. It might be a problem in the passage that’s calling it.
Personally, I put the hooks at the front instead of the back, stops creating accidental passages.
Due to how the (click:) family of macros are implemented (1) it is generally recommended that you use one of the (link:) family of macros instead whenever possible.
The following is a variation of your own SELECT passage code, that has been changed to use a (link:) macro instead. I have also added the usage of Collapsing whitespace mark-up and HTML line-break <br> elements to better control when & where blank lines appear.
|select>[{
(link: "None")[(replace: ?select)[You decide not to select anything]]
(if: $inventory contains "Red_key")[
<br>
(link: "Red key")[
(replace: ?select)[{
(set: $select = "red key")
You selected the (print: $select).
}]
]
]
(if: $inventory contains "Blue_key")[
<br>
(link: "Blue key")[
(replace: ?select)[{
(set: $select = "blue key")
You selected the (print: $select).
}]
]
]
(if: $inventory contains "Paper")[
<br>
(link: "Paper")[
(replace: ?select)[{
(set: $select = "paper")
You selected the (print: $select).
}]
]
]
}]
You can safely remove the extra line-breaks & indentation I have used to make the code more readable.
(1) Each of (click:) family of macros need to wait until the entire Passage content has been processed and the generated HTML elements have been added to the ‘current’ web-page before the macro can scan the entirety of the ‘current’ webpage’s HTML structure looking for the specified ‘target’, so each occurrence can be converted into a ‘link’. This scanning process needs to be done for each and every (click:) macro call made within the current passage, and any dynamic change to the HTML structure of the ‘current’ web-page (like those done using the (replace:) macro) may cause the whole scanning process to be re-done.
So in the case of your SELECT that scanning was initially done 4 times when the contents of the Passage was initially process, once for each of the 4 (click:) macros within that Passage. And another 4 times when one of the ‘links’ was selected.