HTML Twine - Help with syntax

Sin-X

God of Death
Donor
Apr 30, 2017
266
403
Hey guys,

I've started working on twine sugarcube game, mainly just a side project for a bit of fun and a new learning experience. I'm fairly competent when it comes to HTML, CSS, Javascript and many other coding languages however twine seems to have its own syntaxing that befuddles me XD.

I'm having issues editing the navigation menu found at the side of the screen, I basically want to implement some links that can be used to get to specific passages containing stats information.

The passage i want the link to go to is titled: Logbook1, below i have pasted a snippet of code I'm using to insert the link into the side menu but no matter what I try the link does nothing.

Essentially I have two questions.... is there batter way to add stuff to the side menu rather then dom injection? and does anyone have experience in implementing working links in the nav menu that can help me out here?

JavaScript:
setup.setupMenu = function setupMenu() {
        var mc = document.getElementById("menuContainer");
            
        var rlb = document.getElementById("logbook");
            if(rlb) {
                mc.removeChild(rlb)
            }
            
        //SET LOG BOOK
        if(State.variables.logbook != undefined) {
            var ms = document.createElement("SPAN");
            ms.setAttribute("title", "[[Logbook->Logbook1]]")
            ms.setAttribute("aria-label", "[[Logbook->Logbook1]]")
            ms.setAttribute("data-type", "link-markup")
            ms.setAttribute("data-name", "[[Logbook1]]")
            ms.setAttribute("class", "debug")
            
        
            var lb = document.createElement("A");
            lb.setAttribute("id", "logbook");
            lb.setAttribute("data-passage", "Logbook1");
            lb.setAttribute("class", "link-internal");
            lb.setAttribute("tabindex", "0");
            
            ms.appendChild(lb);
            mc.appendChild(ms);       
            document.getElementById("logbook").innerHTML = "Logbook";
        }
}
 

Kinderalpha

Pleb
Donor
Dec 2, 2019
198
265
Common troubleshoot technique for any language is to verify that State.variables.logbook does meet the condition specified (not undefined). Not sure if you've confirmed this or not.

Also, have you looked into the wiki for relevant It appears you need to use a passage which I'm not sure if you are with the given snippet. for creating a side menu button and linking it. .

. I haven't watched them personally but they seem to be on the subject of passages and links which is relevant to your problem.

I'm on mobile or I'd help out more with testing it. Good luck, hope this helps.
 
  • Like
Reactions: Sin-X

Sin-X

God of Death
Donor
Apr 30, 2017
266
403
Common troubleshoot technique for any language is to verify that State.variables.logbook does meet the condition specified (not undefined). Not sure if you've confirmed this or not.

Also, have you looked into the wiki for relevant It appears you need to use a passage which I'm not sure if you are with the given snippet. for creating a side menu button and linking it. .

. I haven't watched them personally but they seem to be on the subject of passages and links which is relevant to your problem.

I'm on mobile or I'd help out more with testing it. Good luck, hope this helps.

Hey,

Thanks for getting in touch I will give an update as soon as I have time to verify if this information is helpful or not, a quick glance suggests it might be exactly what I'm looking for.

Using the code snippet I presented above I'm not using any special storyMenu im injecting a link straight into the dom tree, Logbook is indeed defined as the link appears I just couldn't get it to actually take me to a page when clicked.

Will hopefully have chance to look at what you have posted in the next couple days and then I will be sure to let you know how I got on.

Thanks again for the help.
 

Sin-X

God of Death
Donor
Apr 30, 2017
266
403
Common troubleshoot technique for any language is to verify that State.variables.logbook does meet the condition specified (not undefined). Not sure if you've confirmed this or not.

Also, have you looked into the wiki for relevant It appears you need to use a passage which I'm not sure if you are with the given snippet. for creating a side menu button and linking it. .

. I haven't watched them personally but they seem to be on the subject of passages and links which is relevant to your problem.

I'm on mobile or I'd help out more with testing it. Good luck, hope this helps.
Hey,

Just wanted to say thanks again, this was exactly what I was looking for guess I should of delved around the wiki a bit more instead of just trying to do things the hard way XD

:)
 
  • Like
Reactions: Kinderalpha