Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Anchor linking within a passage sugarcube2 and in general

I'm trying to do a back to the top link.
I did manage to do it by saying [[Back to the top|first passage]].
However when I switched to another story format(protagonist) it didn't work.
I'm wondering if there's a general type of scripting that might work across most story format.

Best Answers

  • Answer ✓
    If you're talking about restarting the story/game, then how that's done will be different in almost every story format.

    If you're simply talking about sending the player to the first passage, then that would be the same as sending them to any passage. Any of the following link should accomplish that in all Twine 2 story formats:
    [[Back to the top|name of first passage]]
    
    [[Back to the top->name of first passage]]
    
    [[name of first passage<-Back to the top]]
    
  • edited March 18 Answer ✓
    Your link markup is syntactically incorrect. Try:
    <span id="top"></span>\
    Some text.
    
    … more text …
    
    … a lot more text …
    
    <a href="#top">Jump to top</a>
    


    That said, if you simply want to jump to the top, then the following would probably be a better choice:
    Some text.
    
    … more text …
    
    … a lot more text …
    
    <<link "Jump to top">><<script>>window.scroll(0,0);<</script>><</link>>
    
  • Answer ✓
    You can use the Javascript window.scroll() function to do what you want.

    The following is one way to do this in SugarCube 2 using a link:
    <<link "Top">><<run scroll(0, 0)>><</link>>
    

Answers

  • mega01man wrote: »
    I'm trying to do a back to the top link.
    When you say "back to the top" do you mean:

    1. Navigate back to the first passage of the story.

    2. Scroll to the top of the current passage after the reader needed scroll down to read all the text.

  • greyelf wrote: »
    mega01man wrote: »
    I'm trying to do a back to the top link.
    When you say "back to the top" do you mean:

    1. Navigate back to the first passage of the story.

    2. Scroll to the top of the current passage after the reader needed scroll down to read all the text.

    it is number two. I'm trying to replicate the html anchor link bookmark.
    <a href=#top>Jump to top</a>
    
  • edited March 18
    If you're talking about restarting the story/game, then how that's done will be different in almost every story format.

    If you're simply talking about sending the player to the first passage, then that would be the same as sending them to any passage. Any of the following link should accomplish that in all Twine 2 story formats:
    [[Back to the top|name of first passage]]
    
    [[Back to the top->name of first passage]]
    
    [[name of first passage<-Back to the top]]
    
    yes lol i just noticed that. that the any link format of twine 2 will work on across story formats XP thank you still!
  • Your link markup is syntactically incorrect. Try:
    <span id="top"></span>\
    Some text.
    
    … more text …
    
    … a lot more text …
    
    <a href="#top">Jump to top</a>
    


    That said, if you simply want to jump to the top, then the following would probably be a better choice:
    Some text.
    
    … more text …
    
    … a lot more text …
    
    <<link "Jump to top">><<script>>window.scroll(0,0);<</script>><</link>>
    
    greyelf wrote: »
    You can use the Javascript window.scroll() function to do what you want.

    The following is one way to do this in SugarCube 2 using a link:
    <<link "Top">><<run scroll(0, 0)>><</link>>
    

    Thank you both! They both work!
Sign In or Register to comment.