New to Squiffy (and loving it). I've googled around quite a bit for an answer here and can't seem to find anything. It's entirely possible I'm mixing JS and Squiffy incorrectly, any guidance would be appreciated.
I'm attempting to put a button at the bottom of my Section that allows users to check their 'inventory'. The inventory is a standalone section( [inventory] ) that functions as expected when a passage link is set to it. Here's my button setup:
<button type="button" <button onClick=squiffy.story.go("inventory");>Inventory.</button>
The button displays as expected, but clicking it will not prompt the [inventory] passage.
I've also tried removing the button logic entirely and simply entering:
This also fails to trigger the [inventory] passage. Is there something I'm doing incorrectly with squiffy.story.go? Do I need to activate some additional js code in order to enable this?
Out of my league here. Have you tried standard JS code in the button (like setting a boolean to true)? Does that work? Are there other squiffy commands you can also try?
Just trying to narrow down what could be the problem - I suck at JS code, frankly.
Your button is missing quotes. Does it help if you do:
Looking at this again (thanks, spammer!) I see what I should have seen last time.
I believe the
[[some section]]: window.story = squiffy.story; Here's the inventory button: <button onclick="window.story.go('inventory');">Inventory.</button>
The inventory is a standalone section( [inventory] ) that functions as expected when a passage link is set to it.
Not sure what you mean there. Is inventory a section or a passage?
A section would start with
[[inventory]]:. A passage would start with
If you mean it's a passage, then
squiffy.story.go isn't the function you want. In that case, the example would become:
[[some section]]: window.story = squiffy.story; Here's the inventory button: <button onclick="window.story.passage('inventory');">Inventory.</button> [inventory]: <hr/> You're carrying a bunch of junk.
(I added an
<hr/> there because clicking a passage link outputs an
<hr/> by default, but calling
squiffy.story.passage does not)
How do you make the Inventory available anywhere and not in the specific [[some section]]?
If I put it in the header [] then the button appears but as a passage  it will not call it. As a section  it does call it, but then I am stuck in that inventory now - how do I get "back"? i.e. if it is only in [[some section]] it continues ok, but I don't want to put the commands in every section...
In another thread (link) I posted a chunk of JS which I think should allow [passage links] to open a passage in the master section from any section.
So you could do:
[]: Here are some links to the [inventory] and [your stats]. [inventory]: Display the inventory here. [your stats]: display stats here
and it should work for every section. (Although it should be noted that if any section has its own
[inventory]: passage, the link in the header will display that instead)
I've not tested it properly, so this is mostly a guess. But if I'm understanding the code I've read correctly, that should make it work.