SugarCube - How to hide the UI bar until a certain passage?

I’ve got code that is making various things happen in the UI bars displays etc for the first few passages of the game.

It looks ugly, and I’m not sure how to ‘hide’ it from the player, until they’ve got their characters selected that is.

Well, the simple method is to use the UIBar.stow() or UIBar.hide() method initially to hide the UI bar, and then use UIBar.unstow() or UIBar.show() method to make it visible when you’re ready to display it.

If you stow the UI bar, then people will still be able to unstow the UI bar, and access the “Saves”, “Restart”, and other such buttons. If you hide the UI bar, then people won’t be able to restart or load a save until they get far enough into the game for the UI bar to become visible.

Possibly a better thing to do is to simply not show that information in the UI bar unless hasVisited("Some Passage") is true, where “Some Passage” is the name of the first passage where you want that information to be visible on the UI bar. So just:

<<if hasVisited("Some Passage")>>
    UI bar information code goes here.
<</if>>

That way nothing will show there until you’re ready for it to be visible.

Hope that helps! :grinning:

1 Like

That ifvisited method works perfectly.

Thanks a lot maestro. :slight_smile: :slight_smile:

Is there a way to use that code to close it off again once it’s at the end game scene?

If you need that, then you might want to just add a tag to any passages where you don’t want the information to be displayed, and then only show the information when that tag isn’t there.

For example, you could add a “NoInfo” tag to the passages where you want the information hidden, and then you’d do this:

<<if !tags().includes("NoInfo")>>
	UI bar information code goes here.
<</if>>

That will let you turn that information off in whatever passages you want, just by setting a “NoInfo” tag on those passages.

Enjoy! :grinning:

1 Like

I just did that, but it seems to be doing the opposite. Whatever passages I have that tag in, it reveals the entire UI.

Edit, I’ve got it working! Another solution from HiEv! :smiley:

On a similar matter, I’ve been really struggling to have some password variables not only hidden until they are needed, but to not cause the restart / save buttons to be moved down due to the ‘empty space’ of the hidden passwords moving them.

<div style="text-align: left;">
	<<print $password1>><br>
	<<print $password2>><br>
	<<print $password3>><br>
	<<print $password4>><br>
	<<print $password5>><br>
	<<print $password6>><br>
	<<print $password7>><br>
	<<print $password8>><br>
	<<print $password9>><br>
	</div>

Now I’ve tried to use the nobr variable like this

<div style="text-align: left;">
	<<nobr>><<print $password1>><br>
	<<print $password2>><br>
	<<print $password3>><br>
	<<print $password4>><br>
	<<print $password5>><br>
	<<print $password6>><br>
	<<print $password7>><br>
	<<print $password8>><br>
	<<print $password9>><br><</nobr>>
	</div>

@HiEv
But it doesn’t prevent the empty space from being created.

<<nobr>>
<div style="text-align: left;">
	<<if $password1>><<print $password1>><br><</if>>
	<<if $password2>><<print $password2>><br><</if>>
	<<if $password3>><<print $password3>><br><</if>>
	<<if $password4>><<print $password4>><br><</if>>
	<<if $password5>><<print $password5>><br><</if>>
	<<if $password6>><<print $password6>><br><</if>>
	<<if $password7>><<print $password7>><br><</if>>
	<<if $password8>><<print $password8>><br><</if>>
	<<if $password9>><<print $password9>><br><</if>>
</div>
<</nobr>>
1 Like

Brilliant work Elfin brother!

I’m guessing you left out the “!” in front of “tags()” in the <<if !tags().includes("NoInfo")>> code. The “!” stands for “not”, so it reverses true/false results. You have to leave that in for it to work.

Also, instead of using $password1, $password2, etc… you should use an array. Then your code would just be:

<<nobr>>
	<div style="text-align: left;">
		<<for _i = 1; _i < $password.length; _i++>>
			<<if $password[_i]>><<print $password[_i]>><br><</if>>
		<</for>>
	</div>
<</nobr>>

(Note: That assumes that $password[0] isn’t used, since arrays always start at 0.)

Basically, anytime you start numbering your variables, it’s likely you’d be better off using an array instead.

Enjoy! :grinning:

1 Like

No i did a straight copy paste of your earlier code, but did wonder if that little exclamation mark was a key factor… :slight_smile: