Howdy, Stranger!

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

[SC] Calculations within inventory, and also a question about the sidebar

edited June 2016 in Workshop
Okay, so I'm using these macros to help set up an inventory system. It's working just fine, and adding things properly, but I was wondering if there's a way to have it use the added info in a calculation so that it can display in a more immersive way. For example, the player starts with 80 units of food, stated in the story to be enough food for about a week. In the inventory, I don't want it to display as "80 food units", because this isn't the space future and food doesn't come in units. What I would want it to display is more like "Food: 8 days", with a background calculation of $food = 80/10. This is all so that later on as the player starts traveling, I can put into passages that to travel in X direction will subtract Y days worth of food (set $food to $food -30) and have it continue to display properly on the inventory page. Is this doable?

My other question, about the sidebar: is there a way to remove the forward/back buttons or have them selectively enabled? I don't want to hide the sidebar entirely, as the link to the inventory is there and I hope to use the save mechanic as well, but I feel like being able to go back will mess up the flow of the story.

I'm using SugarCube 2.0 in Twine.

Comments

  • somnomania wrote: »
    Okay, so I'm using these macros to help set up an inventory system. It's working just fine, and adding things properly, but I was wondering if there's a way to have it use the added info in a calculation so that it can display in a more immersive way. […] Is this doable?
    I don't have time to explain how at the moment, however, yes, it is possible.

    somnomania wrote: »
    My other question, about the sidebar: is there a way to remove the forward/back buttons or have them selectively enabled?
    You want Config.history.controls, which you'd use like so: (goes in> Twine 1: a script-tagged passage, Twine 2: Story JavaScript)
    Config.history.controls = false;
    
  • Ah, thanks! I only just thought to check my notifs, so sorry for the late reply. I'd like that explanation though, when you have the time. I have a bunch of other tabs open with posts about inventory systems and returning to the previous passage, but I haven't been able to sit and look through them all yet to see if I can work out the solution on my own.
  • Getting back around to this.

    The particular inventory macros you're using are more of a key item type—i.e. they don't track quantity. Additionally, you mention a $food variable, which really doesn't make sense in context of those macros.

    Is the food tracking bit supposed to be separate from the inventory (macros)?
  • Getting back around to this.

    The particular inventory macros you're using are more of a key item type—i.e. they don't track quantity. Additionally, you mention a $food variable, which really doesn't make sense in context of those macros.

    Is the food tracking bit supposed to be separate from the inventory (macros)?

    Not necessarily; I mean, it is a component of the inventory, but as it's affected by time and distance, and nothing else in the inventory really would be, I suppose it is sort of separate. But I still don't really have enough knowledge about how to construct macros to know how to do a separate thing just for food tracking.

  • You don't really need macros—aside from <<set>> and <<print>>—for what you've talked about, so far, with your food system. So, unless you just really want it display exactly as the rest of the inventory, there's no real reason to get complicated with things.

    For example, if simply displaying the player's food situation whenever you display the normal inventory is fine, then you could simply do something like:
    ''Food:'' <<=($food/10).toFixed(1)>> days
    ''Inventory:'' <<inv>>
    
    The call to toFixed(1) is simply there to keep the displayed decimal places under control.

    I'm not trying to talk you out of putting the food into the inventory, however, to do so would require you to use different inventory macros—since, as I mentioned, the ones you linked do not track quantity at all.
Sign In or Register to comment.