Howdy, Stranger!

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

Use text for 'history' buttons?

edited November 2016 in Help! with 2.0
I'm using Sugarcube 2.11.0 and would like to use simple text for the back and forward history buttons. I'd like them to say 'back' and 'forward' and sit on separate lines below the 'restart' and saves' links, so that they just look like a continuation of that block of links.

I've found the selector - #ui-bar-history [id|="history"] - and can move them around with margins, change their size and colour, etc, but changing them to simple text is beyond my capabilities.

I'm also never sure if when using margins to position something, there's any guarantee that things will be in the same position for everyone who views the game, so if there's any way to be sure they line up with the aforementioned links, rather than me just throwing values at the margins until I get them where I want, then that would be a plus.

I found this (when following the link I inadvertently made above) and assume this goes in StoryInit, which isn't quite what I wanted, I don't think.
<<click "<<">><<script>>State.backward()<</script>><</click>>
<<click ">>">><<script>>State.forward()<</script>><</click>>


  • Of course! I put this code in one of the sidebar passages, for instance StoryMenu then just hide the buttons with CSS.

    On that link Greyelf says it's better to use Config.history.controls = false;, but I don't know what he means when he says place it in your story's script tagged passage.
  • Right, got it. The Config goes in the Edit Story JavaScript sheet.
  • edited November 2016
    I'd suggest simply using the StoryMenu special passage, rather than adding them to the core menu items. The macro-based solution you've shown there is also a bit out-of-date and doesn't allow for the Jumpto dialog. I'd suggest the following instead:
    <<link "Backward">><<script>>Engine.backward()<</script>><</link>>
    <<link "Forward">><<script>>Engine.forward()<</script>><</link>>
    <<if Story.lookup('tags', 'bookmark').length gt 0>>
    \<<link "Jumpto">><<script>>UI.jumpto()<</script>><</link>>

    If you really needed them as part of the core menu, then I can show that, but that would be a bit more complicated—requiring a bit of JavaScript and CSS.
  • edited November 2016
    I'm not sure what the jumpto does, but I'll substitute my own code for yours and see what I get.

    Thanks. I'll be back with comments if needs be.

    Well there's no immediate or obvious difference. They look and behave exactly as they did with my own code, but I bow to your better judgement in terms of the code being more up-to-date so will stick with yours.

    Thanks again.
  • The Jumpto button is part of the normal history navigation UI, along with the Backward and Forward buttons, and opens the Jumpto dialog. The dialog allows a player to quickly jump between passages which have the bookmark tag. Think of bookmark tags as something like checkpoints for the history.

    The code I provided above, like the default UI bar Jumpto code, displays the button/link only if any passages have a bookmark tag, so players won't see the button/link unless it will actually be possible for them to make use of the dialog.
  • So you're saying if I have an important passage, tag it with 'bookmark' ?
  • Jud_Casper wrote: »
    So you're saying if I have an important passage, tag it with 'bookmark' ?
    If you want that to be a convenient place for the player to be able to jump to when navigating the history, sure. If not—for whatever reason—then don't worry about it. From what little I know of your project, I'm unsure how much history navigation players will likely be doing anyway.

    Jump points, set up via the bookmark tag, are probably most useful—to players—in projects with somewhat linear paths—e.g. CYOAs. They're probably less useful in projects that are more game oriented—e.g. with lots of passage repetition. I'm not saying they shouldn't be used in game-y projects, just that they should probably be used sparingly, at key points, and not in passages that get revisited very often.
  • Okie dokie. Cheers.
  • edited November 2016
    I've just done some experimenting with jumpto and discovered an issue.

    My bookmarked passage features a car that won't start. If I continue following the path until I reach a passage where I find petrol and a variable is switched to true (in order for the car to start at the bookmarked passage), and then I use the 'jumpto' feature to return to the car, the true variable seems to be cancelled out and the car still won't start (even though I've collected the petrol). It works as it should if I navigate back the normal way, so the prob is def with the jumpto feature here.
  • The Jumpto dialog is a history traversal mechanism, like Backward and Forward. Just as if you'd used Backward many times, you, literally, went back in time within the history to a moment before you had the fuel.
  • Ah, not what I thought then. I didn't realise these link acted like time-travel. I just thought they were ways to navigate between locations (should the need be for whatever reason) without affecting your current state.
Sign In or Register to comment.