Howdy, Stranger!

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

[Sugercube 2.x] How do I have inventory that can always be accessed?

edited September 2015 in Help! with 2.0
OK What I have in mind isn't exactly inventory as such. What I have in mind more is 'you click on this thing to have a list that populates when you encounter things that the player will want history on.'

I might want to ask how specifically to do that, but right now I just want to be able to mouse to the side or above or below the actual story area, click a button, then get a list of things players can view at their leisure, potentially with flags that trip if you look at them.

Comments

  • edited September 2015
    You can add your own markup links to the side-bar by creating a passage named StoryMenu and placing your links in that passage.

    StoryMenu
    [[Inventory]]
    
  • Awesome, any idea how to make the resulting 'inventory' page self populate with entries as they're discovered?

    Since I'm going more for a guidebook approach here is what i want.

    Person clicks on snippit. In that snippit are a few things I will want people to read about.

    How do i indicate an event where the guidebook has new items in it (text blinking till clicked, text blurring in and out, or something) and have entries only pop up if you click on story snippits that have items you want to go into length about?

    I'd almost want to say treat it like a table of contents that populates with thigns as you get there.

    That actually isn't a bad idea either since it means you can go back to different nodes and see if different paths can be taken.

    I like that i can populate a sidebar with Things since I can have a separate inventory and guidebook.
  • http://twinery.org/wiki/twine2:add_an_inventory_system

    Should get you started. It works pretty well. You can make adjustments to suit your needs.
  • So, less of an inventory and more of a journal?

    How are you tracking that journal entries are discovered? That will, obviously, shape the mechanics of how the journal page is populated. If you don't know that yet, then that's the first thing you need to think about.

    It could be as simple as something like setting some kind of boolean flag. As an example, say you wanted to track whether the player had found an autopsy report and decided to use a $variable to do so. First, you'd want to initialize it to false in the StoryInit special passage. Then, whenever the player has discovered the report, you simply set the $variable to true:
    <<set $foundAutopsyReport to true>>
    
    In your journal passage, you'd just test the value of the associated $variable. For example:
    <<if $foundAutopsyReport>>
    … stuff about the autopsy report …
    <</if>>
    
  • I was actually considering the idea of using tags but... That's nice.

    Can you track what snippits have been clicked on so i can use that as something like <<if 'name of thing' true>>
    -Character commentary about the thing-
    <</if>>

    Like character goes to 'farmhouse' there's a new journal entry about the farmhouse.

    I am assuming things found in <<if> flags can contain links and other variables?
  • edited September 2015
    You can just use what themadexile wrote at the top of the farmhouse passage.
    <<set $farmhouse to true>>
    

    It'll happen right when they visit. Now your appendix or whatever has that next bit that shows it.
    <<if $farmhouse>>
    The farmhouse info!
    <</if>>
    

    You can also include that set to true code inside a click.
    <<click "farmhouse">>\
    <<set $farmhouse to true>>\
    <</click>>\
    

    That way when they click farmhouse they add it to the appendix. So you could have " read about the farmhouse " and it displays the info, but that info is also in the journal.



    I would recommend trying some things out until you get a good idea of what you want, that'll make it easier to figure out how to do things. :)
  • How do I have a notification fade in at there being new entries to read?
  • As for how to know there's new entries to look at, the simplest thing would probably be to make a story variables just for that (initialized to false), which you set to true whenever you enable a new entry. For example, using the $farmhouse example, and assuming you'd call such a variable $journalUpdated:
    <<set $farmhouse to true, $journalUpdated to true>>
    
    Basically, any time you enable a entry, you set the $journalUpdated flag. Afterward, you'd just need to check the state of $journalUpdated to know if the notification needed shown.

    As to how to do the notification itself, that would largely depend on what you're looking for. It could be as simple as a bit of code in the StoryCaption special passage. For example:
    <<if $journalUpdated>>New Journal Entries Available<</if>>
    
    If you wanted something more animated and/or displayed elsewhere, then you need to get specific about what you want.
  • At this point not sure what I want so going to see how that works.

    Also I don't have to keep resetting the update flag to false after each update?
  • You do, but you can do that within the journal itself, say at the top.
  • so something like <<if $journalupdate is true; set $journalupdate false>>\ and have that at the top of the journal page?
  • At the top of the passage, yes. Your syntax is incorrect though. It should be something like the following:
    <<if $journalUpdated is true>><<set $journalUpdated to false>><</if>>\
    

    That said, you really should not test boolean values against the boolean literals in a conditional. While it is not incorrect to do so, it is unnecessary. It would be better as the following:
    <<if $journalUpdated>><<set $journalUpdated to false>><</if>>\
    

    However, in this case, you don't really need the <<if>> there at all. Since the code's sole purpose is to turn the flag off when the player views the journal, you could simply do that. For example:
    <<set $journalUpdated to false>>\
    
  • edited September 2015
    Dude, you are an awesome person for helping a noob like me out.

    Thank you Sir of Sirs.

    Edit: I only thought to include an explicit check for a true condition because the way it was explained to me by a codemonkey friend over the years is generally it's better to not assume. Then again literally this thing is just an off button for a single condition, not checking an entire array of conditions and having to flip one or two depending on what's going on.
Sign In or Register to comment.