Yes, what I am going to ask has been answered, but searching around not in a way I understand.
My game will be simple enough. combat is resolved through choices instead of die rolls, same with stealth sections and what not. however. when it comes to items I will need an inventory. and some of these items would be cursed, and the idea I had for this is say, the PC picks up a pair of Magic gloves, if the PC ever examined the gloves it will activate a compulsion flag and eventually they won't be able to resist and put them on. (maybe done through through coin flipping. get heads 3 times means you are compelled to wear them)
I don't know how to implement these as I haven't really toyed around with picking up items, equipping gear, examining an item at any time while progressing with the paths you are already on. and having flags like "If examined, If worn"
Even more advanced...which kind of gets away from me wanting to keep it simple. is item durability. If the Player decided they want to play the Princess. I thought it would be fun to include her high heels and dress as a problem. her heels might break if she runs around to much. her dress will rip and tear over the course of the adventure, things will get dirty and stained. and I wanted these to affect her mood.
Comments
Since you wouldn't want to branch the story into separate passages on every item you decide to pick up or not, inventory state would have to be kept using variables. What kind of variables depends on how generic you need item management to be. If it is just the princess's dress that suffers wear and tear, you can keep a variable like $dressDamage, increase it on events that tarnish the dress and use some <<if>>s to describe how the dress currently looks. If you want to keep track of durability on many items, you'll have to come up with a generic system for that.
A generic system should probably use classes in JavaScript. That way you could attach event handlers to certain events: on pickup, on drop, on wear, on take-off etc. For example a cursed item could make the take-off action fail. It is tricky to get all the interactions in a generic system right though. For example, a drop action has to trigger a take-off action on worn items, otherwise you could get rid of worn cursed items by dropping them. Alternatively, you don't offer the drop action on worn items, but then you have to be careful that all in-story actions make those checks as well, for example the player might try to sell a worn cursed item.
If you haven't written medium size JavaScript projects before, it might be best to start with as simple and non-generic an inventory as you can get away with. Then as the game grows and you notice you're writing similar code multiple times (or going through copy-paste-change cycles), generalize the inventory mechanism to get rid of the duplicate/similar code.
In Start
<<silently>>
<<set $inv = []>>
<<endsilently>>
so set up and inventory
and
<<silently>>
<<set $inv = ["Magic Gloves"] >>
<<endsilently>>
In the passage you find them. but I am not sure if I am doing this right. I might just have to write each item into the story paths instead of having an inventory and just use flags but even then I am still not sure how this works
I assume I start it off as
Passage
Wear gloves
<<set $gloves worn = true >>
The hero decides to wear the gloves
and then when the curse comes into play I then use
<<if $gloves worn = true >>
The hero's grip loosens on his spear and he feels his strength drain away.
I am still confused about this.
If you're using SugarCube or a recent Twine beta, you can use the StoryInit passage instead of Start and you don't need the <<silently>> then.
That will set the inventory to a list of exactly one item: the magic gloves; it will replace any other items that the player was already carrying. What you probably want is to add something to the inventory, which could be done like this:
You cannot have spaces in variable names. Typical solutions are replacing spaces with underscores ($gloves_worn) or camel case ($glovesWorn).
If you want to test for equality, use "==" or "eq". If you write "=", it will change the variable, as if you were doing <<set>>.
If you're working with booleans (true/false truth values), you can omit the equality test altogether though: