The “nobr” tag just prevents line breaks in the passage it’s put on, unless you force a line break using something like the HTML <br>
element or the like. In order to keep your widget code clean and readable, it’s usually easier to just use the “nobr” tag so that you don’t have to worry about tons of line breaks when you call the widget.
Widgets should not be put in any special passages, as noted in the <<widget>>
macro documentation. So you should not put widgets in your StoryInit special passage.
For learning Twine/SugarCube, generally speaking, I’d recommend starting by skimming through all of the SugarCube documentation, just so you have an idea of what all it can do, and keep it bookmarked. You don’t need to memorize or understand all of it immediately, you just need to remember enough that you can recognize things in the documentation which might be useful later on.
Next, if there are any Twine games that you like or have effects, features, or UI elements that you like, you can import them into Twine to take a look at them to see how they work, and then adapt that code to your own project. (Note: If it’s a Twine 1 game then you’ll need to convert it to a Twine 2 game in order to open it in Twine 2. Use the “Twine 1 compiled HTML to Twine 2 archive converter” for that.)
For other resources, Chapel has collected a ton of Twine Resources here. There’s also the r/twinegames subreddit (where I’m one of the moderators). If you use Discord, there’s also the Twine Discord server, if you want to talk with people live. And finally, Google is your friend
, you can find lots of helpful info just by searching around the net (especially at the Stack Overflow site).
Regarding the JavaScript section, it’s for putting any JavaScript code that you want to have executed when the game first starts, or to put any functions that you want to be able to use during your game. SugarCube and JavaScript code are able to be combined within passages, so don’t think that the stuff you can do is limited to only what’s in the SugarCube documentation. For example, you can use the JavaScript alert() method to display an alert in a passage like this:
<<run alert("Some alert message text.")>>
The “Stylesheet” section, on the other hand, is where you put your CSS code, so they’re not like two separate files or anything. You just put any CSS styling you want to use in the Stylesheet section.
As for the relationship between them, CSS affects the appearance of the game’s UI (User Interface), the story passages generally determine what HTML and other content is displayed, and the JavaScript is generally for manipulating data behind the scenes. That said, you can use JavaScript to manipulate both the HTML and CSS styling on the screen if you want to. Often that’s most easily accomplished using jQuery, which is included with SugarCube.
Any code you see which uses $(something)
or jQuery(something)
that code is usually using jQuery to examine or modify elements on the screen. SugarCube extends jQuery a bit with its own jQuery methods.
Hope that helps! 