HTML UIBar doesn't appear when I load the game (Twine/Sugarcube)

Peanut Games

Newbie
Game Developer
Jan 25, 2022
54
93
Normally, I should see the UIBar in other passages, but since I used the UIBar.hide().stow() code in the first passage, the UIBar does not appear when I move to another page. I am using the first passage like a title screen so I must hide the UIBar. I either need to use a different way to hide it in the first passage or I need to make the UIBar appear when the "Load" button is clicked. How can I fix this?
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,481
4,322
I think you mean when the game is loaded, not when clicking the load button. I think this should work in your javascript.
Code:
Save.onLoad.add(function (save) {
    UIBar.show().unstow();
});
 
Last edited:

guest1492

Member
Apr 28, 2018
350
288
You should adjust your CSS to do it instead. That way you won't have to worry about people loading saves, navigating backward/forward, refreshing the browser, etc.

Example:
CSS:
body[data-tags~=titlescreen] #ui-bar {
  display: none;
}
 

Alcahest

Engaged Member
Donor
Game Developer
Jul 28, 2017
3,481
4,322
You should adjust your CSS to do it instead. That way you won't have to worry about people loading saves, navigating backward/forward, refreshing the browser, etc.

Example:
CSS:
body[data-tags~=titlescreen] #ui-bar {
  display: none;
}
That is how I do it, however, that doesn't solve all the problems. For instance, once the UIBar has been shown, and you go back (or forward) to a passage with display:none for the UIBar, that will not reset the left margin. As if the UIBar is just hidden, not stowed. For this reason, I add margin-left:0 to the CSS for such passages.
 
  • Like
Reactions: guest1492

Peanut Games

Newbie
Game Developer
Jan 25, 2022
54
93
I tried what you both said, but when I did what Alcahest said, the game's functions were completely broken. I think I made JS a little complicated :) In the second one, there was a margin problem. I created a solution by adding both of your methods.

CSS:
body[data-tags~="no-side-bar"] #ui-bar {
    display: none;
}

body[data-tags~="no-side-bar"] #story {
    margin-left: 2.5em;
}
Thank you both, by the way. I wouldn't have thought of this way without the codes you wrote.
 
  • Like
Reactions: Alcahest