Quantcast
Channel: Help! with 2.0 - Twine Forum
Viewing all articles
Browse latest Browse all 1844

[Harlowe] Displaying Passage INLINE

$
0
0
Alright, so I'm very new to Twine but I'm starting to get it down. I try to steer clear of asking questions and scour the internet for my answer first. This particular problem is one I've been hunting down for about a solid week now so here I am.

I'm using an array for an inventory, and I'd like to have each item be clickable to open up a submenu within the inventory. At first I was using separate passages for each inventory item that held nothing but that item's submenu (and linking to a datamap defined earlier):

::Inventory::
(if: $inv's length > 0)[
You are currently carrying:
(print: $inv.join("\n"))[


(click: "Kaskade Multiband v3.7")[(display: "KMB")]
(click: "Passport Chip")[(display: "PassChip")]
(click: "Time Chip")[(display: "TimeChip")]
(click: "Sandgrain Pouch")[(display: "Sandgrain Pouch")]
(click: "Potion")[(display: "Potion")]
(click: "Transcript of email to mom")[(display: "XmasEmail")]

]]
(else:)[You have nothing of value.]

::PassChip::
(link: " Inspect")[\
	(print: $PassChip's description)]
(if: $multiband's isCarried is true)[\
	(link: " Install")[\
		(goto: "Passport Install")]]

This method works, but these submenus are displayed beneath ALL of the items in the array, and each subsequent submenu is displayed underneath the submenu above it. Not very organized. I assume it's because I am printing the array and defining the click links after the array is printed in full. So I tried a different approach. This time, I have a primary Inventory screen that begins a loop, and references yet another passage that contains the actual printed information. The idea being, I would print each value of the array separately, avoiding printing the whole array before the submenus can be called:

::Inventory::
(if: $inv's length > 0)[
You are currently carrying:
(set: $n to $inv's length)
(set: $count to 0)
(display: "InvCount")


]
(else:)[You have nothing of value.]
::InvCount::
(set: $count to it + 1)
(print: $inv's ($count))[\

(click: "Kaskade Multiband v3.7")[(display: "KMB")]\
(click: "Passport Chip")[(display: "PassChip")]\
(click: "Time Chip")[(display: "TimeChip")]\
(click: "Sandgrain Pouch")[(display: "Sandgrain Pouch")]\
(click: "Potion")[(display: "Potion")]\
(click: "Transcript of email to mom")[(display: "XmasEmail")]\
]
\\
(if: $count < $n)[(display: "InvCount")]
(else:)[]

The good news is that this works just as well, it seems. The bad news is that it works just as well...no better. Is there any way to code the passages inline so that each submenu displays directly below the line item from the inventory array?

Viewing all articles
Browse latest Browse all 1844

Trending Articles