I'm using Sugarcube with V2 of Twine (online at the moment).
I've seen some games using this template, that have other elements in the sidebar, such as the location and/or time of day.
How would I do this? Not necessarily those elements, but I would like to know how to add things to the sidebar. I think it would be handy to show objects being carried, for example.
I'm guessing it requires complex scripting, which is where I'm pretty much stuffed as I know none of it.
[Edit] Okay, so I've discovered links can be added to the sidebar by adding a StoryCaption passage. Getting those links to do what I would like is still beyond me.
Comments
You will need to supply a lot more detail if you want people to explain how to achieve the results you want. lol
To add links, actual links only, to the UI bar you may use the StoryMenu special passage. As to how to make the links, they're usually either passage links or <<click>> macros (see: markup language and <<click>> macros). For example: Just put each link on its own line.
As a final note about UI bar links. They're commonly used to navigate to passages which provide character descriptions, inventories, journals, etc. Doing so, obviously, navigates the player away from the story. So, to get the player back to the proper place within the story, you'll probably need to use the <<return>> macro, if the visited passage alters state, or the <<back>> macro, if it does not—there are other methods you may, or may have to, use depending on the the complexity of your side passages (see: <<return>> macro, <<back>> macro, previous() story function).
To add other, non-link content (e.g. stat displays), to the UI bar you may use the StoryCaption special passage. As to how to make displays of one sort or another, generally you simply place whatever it is you want to print there in the passage—either alone, if it's simply a $variable, or via the <<print>> macro, if it's more complex (see: naked $variable formatter and <<print>> macro). The reason that works turn-to-turn is that most of the special passages are processed each turn ("turn" here meaning each time the player navigates a passage). For example: I used a wiki table there to make things align nicely, but you get the idea, I hope. You may use whatever markup you wish there (SugarCube's wiki markup or HTML).
greyelf, I was thinking the exact same thing as I was writing the post, and almost added a line to explain I realised no one would be able to offer help unless I was more specific. I suppose I was sort of asking in preparation - in as much as I knew I would probably want to use side links / elements at some point, without knowing exactly what at this time.
TME, I'm afraid I'm not familiar with macros, markup, and even less with scripting and java. I have a fairly good understanding of CSS, and a little html.
For instance, I would now know how to add a link to an inventory, and how to send the player to that particular passage, but certainly not how to generate the inventory within that passage.
Would the code to generate an inventory go in the passage itself, or a seperate code sheet somewhere, such as when adding CSS?
Second. You're going to have to learn, at least some of, the macros and markup. Most authors probably get by with no real understanding, or use of, JavaScript (unless they use Snowman, since that's all you get), so knowledge of JavaScript isn't mandatory. CSS knowledge will be useful—since, aside from basic markup like emphasis/strong/etc, all styling is done via CSS. HTML knowledge could also be useful—since, if desired, you may use HTML in preference of most of the wiki markup.
That would depend on what kind of "inventory" you're talking about. You can write an inventory in a number of different ways and that, naturally, affects how you'd go about generating it, displaying it, adding/removing items from it, etc.
That said, you will likely have, at least, some code in the inventory passage itself. If you're using some of the inventory macros which can be found around here, then you may simply have a few macro invocations. If you're doing more of a key item type inventory, then your inventory passage might consist solely of a number of <<if>> macros.
Anyway, am I correct in thinking that the <<if>> macros would be used in conjuction with variables elsewhere?
I think I need to study the tutorials as I don't even know how to add variables, but the one thing I find with tutorials for things like this, is that while they explain the code itself, they never explain where the code goes.
For example, let's say you initialize some key item $variables in StoryInit: Then you might show that the player has, or does not have, them in your inventory passage, like so: You'd set them to true in other passages. How you'd go about that depends on you, really—could be automatic in some cases, could require the player to choose to take the item in others, etc.
In the case of the Twine story formats, that would likely be because where the code goes depends largely on what you're doing. The notable exceptions to this, where the code mostly/always goes into the same place, are (for Twine 2):
Then after this, I set up another passage and call it Inventory (linked to from the sidebar) and add the conditions you posted?
But then when I set up a regular location passage that includes an item the player can take, how do I code that?
i.e
I'm sure it's not as simple as that, is it?
First. You have too many left square brackets here on [Take axe.
And whether it's that simple or not is up to you. I mean, yes, you do need more than what you've shown, but it could be nearly that simple.
For the following examples I'm going to use Twee notation (i.e. :: Passage Name)—you can't use this with Twine, but it makes a decent notation for examples.
You could, for example, do something like the following: That allows you to add extra detail for the axe, but it also adds an extra state to the history that you don't really need.
Alternatively, you could something like the following instead using a setter link: There is currently an issue with Twine 2 where it mishandles setter links a bit. As a workaround, you could write the above using the <<click>> macro:
* once I'd remembered to change the inventory code to 'if $hasAxe;' from the example you provided.