Howdy, Stranger!

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

Making an Inventory system that affects Stats (carryweight etc)

Hey to all!
This is a discussion to see what ways others can think around this particular problem.

I want to make an inventory of multiple items that all have a carry-weight
Equipped items affect stats (EG, weapons increase DAM etc)
I also want the option to discard said items and use them when needed (making camp at night etc)

Some items are easy.
Having the bedroll will activate the 'just sleep here' button that progresses the clock 8 hrs, triggers the 'time past 24' event etc...

I am struggling a little with how to have the character carrying 5 health potions, each weighing 1.

I'm probably being too ambitious, but I can't be the only one trying to get my head around this!

(Using Sugarcane in Twine 1.4.2 but am content to use any other build format)

Also, for anyone just wanting an inventory system, I uncovered this: I understand it takes a little shoe-horning, but I think it might work... but it won't do what I want to here.


  • edited January 8
    I created one for harlowe (twine 2.x) so assuming you want to redo all our work and learn a new format follow on

    first I want to know what do you want to accomplish because mine is maybe more complex than what you need

    do you want a shop system (which btw will take lots of time)

    what types of items do you want

    is there a limit to the inventory or is it an infinite black hole of items

    what stats do you want, what stats do you have in the game

    is a inventory system really useful to your situation by that I mean can you drop gear or is gear just replaced automatically

    if gear is just replaced all you need is a datamap

    for whatever reason you want to drop gear or get gear out of loot you need an inventory system

    is loot luck based or is it a specific item

    does gear stack,if so how much does each item stack

    I can't help if you're being too damn vague
  • edited January 8
    [EDIT] I can't use twine 2 because I can't see anything on it.
    I'm colourblind and anything on a blue background is impossible to see
    Stuffed that up.

    No shop. This will be loot-based only
    Items are in four categories: Weapon. Armour. Food. Water. (and coins, but they'll be easy enough to track with a +1 variable)
    There will be a limit. To avoid the game getting too easy. Each item will be balanced to match the biome it'll be found in.
    Current stats are: Strength, Agility, Stealth, Inteligence, Ingenuity ,Endurance, Luck, Carry, Damage, S-Damage, Defence, S-Defence, Critical, Hands.
    An inventory system would be very useful for the carried items, but weapons and armour can be replaced as there's no need to waste your pocket-space on it.
    Loot is luck-based
    Gear will stack as high as the carry-weight allows (up for discussion). Want to carry nothing but healing potions and your gear, sure.

    I didn't want to throw all the particulars of my game out when I don't know what information is relevant. I didn't mention a shop anywhere and unless asked, I wouldn't have even thought about it.
  • general tips (since there's no harlowe in twine 1.x wish I could actually help)

    1.reduce the amount of stats it's a bit too much I have no idea what hands could be, neither do I know the difference between strength/damage,intelligence/ingenuity, endurance/defense, as a player I would not like a game that's too complicated look at popular sandbox games (I am assuming your making a sandbox game) like Don't starve or minecraft they have about 3-4 stats even most mmorpgs/rpgs don't have that much

    2.maybe you can upgrade/enchant your equipment to get specific stats that you're looking for

    good luck it's unfortunate that I couldn't be of help
  • Some of it might be simplest is your base item was a stack, not a single item. So a healing potion would be a stack of 1 healing potion. You'd store the attributes of single items in the base of the stack and use a widget (assuming you're using Sugarcane 2 with 1.4.2) to recalculate the total attributes of the stack:

    healing_potion: { tag: 'Healing Potion',
    single: [ 1, 0, 0, 0 ,0 ,0 ]
    count: 3,
    total: [ 3, 0, 0, 0, 0, 0] }

    The total array is simply the single array multiplied by the count. To total your inventory you just need to add all the individual total arrays together.

    The tag is used to locate objects when moving some of them to a new location. If you can find a stack of the object in the new location, simply adjust the counts and retotal each stack. If a stack ends up with 0 count, destroy it (but watch clone vs pointer - set $a to $b simply makes $a point at $b, you need set $a to clone($b) to get a new a object that is independent of the $b object. ) If you can't find an existing stack in the new destination, you'll need to create a new one (i.e. the first time you pick up a healing potion).

    You might be able to save some memory with a 'type' value that points to an entry in a master single array, but that makes things a bit more complicated.
  • mykael wrote: »
    […] use a widget (assuming you're using Sugarcane 2 with 1.4.2) […]
    (emphasis mine) No such story format exists. You're confusing Sugarcane—included with Twine 1.4.2, no longer actively developed—with SugarCube. The OP claims to be using Sugarcane.
  • I'm still new to all this, been using Harlowe and SugarCube (focusing more on SC because it seems more powerful), but I'd like to throw in my input. I'll say this, without going into javascript functions and/or using SugarCube's widget system, you're gonna have a hellova time keeping things neat, clean, and usable. I'm currently looking into better ways of utilizing datamaps or any key-value structure so I can create complex objects (like items) on the fly. The difficult part is creating the functions that play nicely with them and Twine script. I've spent 95% of my time just researching how to make custom Javascript functions work, and JS was my first language.

    When I first played around with Harlowe I used a ton of flag variables (basically just booleans) to act as inventory and item system, and it was hell. I definitely suggest looking into compartmentalizing your code as much as possible.

    Ultimately, though, I don't think it's wise to attempt something as complex as an Inventory in Harlowe. I don't particularly care for SugarCube's format, and I like the color highlighting on Harlowe, but it just doesn't have the same fundamental power that SugarCube does.

    Hope that helps a little.
  • mykael wrote: »
    […] use a widget (assuming you're using Sugarcane 2 with 1.4.2) […]
    (emphasis mine) No such story format exists. You're confusing Sugarcane—included with Twine 1.4.2, no longer actively developed—with SugarCube. The OP claims to be using Sugarcane.

    Sorry, I meant Sugarcube - which is a much better place to start a major project from.
Sign In or Register to comment.