Hello all!
Let me preface this by saying my coding knowledge is limited. I'm definitely new at this...
Would anyone be able to help me out with how to make an inventory system with a menu function using harlowe?
I have a character with a backpack, and inside the backpack there are several items and some have a number value like ammunition or number of items of food, so forth.
What I'd like to be able to do, is in one broad stroke inside one passage named something like, "Backpack", list all the contents for the player, along with the number of each item.
Throughout the story, the character will either be in a situation when he is using up items, like food or ammo, or he is in situations where he is forced to leave items behind, i.e the entire backpack, or just a knife or a gun or some ammo.
What I have is something like this:
Passage name - "Backpack"
(set: $backPack to true)
(set: $canned_beans to "CannedBeans:16oz canned beans, non-fat", true)
(set: $canned_beans_left to 2)
$canned_beans_left - 16oz canned beans, non-fat
(set: $shotGun to "Shotgun:double-barrel 12 gauge")
(set: $shotGun_shells to 2)
(set: $shotGun to true)
1 - 12 gauge shotgun, double barrel
$shotGun_shells shells
(set: $knives to (datamap: "Machete:Solid carbon steel 38cm fine edge on one side; 46cm high-
performance saw blade on the other; 64cm overall.", true, "Knife:8cm blade; 18cm overall blade,
serrated razor-sharp.", true, "Throwing knife:18cm with piercing points.", true))
(set: $machete to true)
(set: $knife to true)
(set: $throwingKnife to true)
1. I don't know how to show the player this information in a sort of bullet-point list, and the latter part of the code seems redundant since I've already told the datamap that those items are true. But they are super long and don't have short variable names. Which is why I put them in there at the end with shorter names. Is that not necessary? How do I show the player this information in a list in the same passage?
2. I also don't know how to make this a clickable menu item no matter where the player is in the story, the player should be able to reference the list of items and how much ammo and food they have.
Not only is this not really working well, there are huge gaps of white space in the items listed.
Is this possible in harlowe?
Thank you in advance!
(sorry for my ignorance - help me learn!)
Ps. for the future how do I get the code I'm referencing to appear in yellow in here like everyone else is doing?
Comments
I am by no means an expert, so I can't really explain anything, but I can point you to a couple of threads that helped me.
1) This one has explanations for: sidebar, save / load function, and basic inventory:
(with some more info in a link at the bottom of the thread)
http://twinery.org/forum/discussion/comment/11674/#Comment_11674
2 )This one has a downloadable example that you can import in Twine and study:
http://twinery.org/forum/discussion/comment/11551/#Comment_11551
3) This tutorial was also extremely helpful for me:
http://lambdamaphone.blogspot.it/2015/02/using-twine-for-games-research-part-ii.html
(part three is in the March archive of the same blog)
Note:
You can also tag one passage as "header" and one as "footer", and they will always be displayed.
They are both nice places where to put an inventory and the save / load option if it turns out that the sidebar method doesn't give you enough flexibility.
Replace the () with [] in
(code)This text shows up as code(/code)
to get