Howdy, Stranger!

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

Data mapping with Twine 2 (Harlowe... I think)

So I am TOTALLY new at this. Please take that as an excuse for my ignorance. I am really interested in getting proficient with this engine, and have a question regarding data maps.

I'm trying to set up an automatic link between hyper-linked item names in my game (like [sword]) and a single "Item Description" passage that utilizes data maps. So I've set up an item's data map like this:

(set: $sword to (datamap: "name", "sword", "desription", "The ruby sunk into the hilt of your family's sword was said to come from the Old World. When your great-great-great grandfather was but a boy, before the Great Exodus, he had snuck it out of the jewel mine he was forced to work in. Now it sat neatly above your fist. Every time you stab the blade through a ne'er-do-well's skull, your ancestor surely smiles in his grave.", "pickupText", "The blade feels good in your hand. It hums in the wind, as though it is cutting the very air as it passes over the sword's edge.", "isCarried", false))

And I've set up the "sword" item description link like this:

(if: $sword's isCarried is false) [ Your (link: "sword") [ set:$selectedItem to $sword)(goto: "Item Description") ] stands upright, its notched and gnarled edge still fearsomely honed and half-buried in the earth. ]

And I've set up the "Item Description" passage like this:

(print: $selectedItem's description)

This all looks OK based on the minimal understanding I have, but every time I click on "sword" I get this message:

You can only use positions ('4th', 'last', '2nd-last', etc.) and 'length' with a the string "".


Can someone tell me what's going on here? I would really appreciate the help. Thanks in advance for reading the above!

This Twine 2 thing is excellent!!!

Cptn Ack

Comments

  • I changed the typo concerning "desription" to no avail!
  • Yeah... and now I see the missing brackets. Sheesh. Sorry to the 3 people that actually read this.
  • A couple of suggestions:

    When including code examples in a question/comment use the built-in code wrap feature. You use the feature by selecting all of your code example using either the mouse or cursor keys and then click on the C button on the toolbar. The output when preview will look like this:
    (print: $selectedItem's description)
    

    Using the above feature allows you to format your code examples making them easier to read like so:
    {(set: $sword to 
    	(datamap:
    		"name", "sword",
    		"description", "The ruby sunk into the hilt of your family's sword was said to come from the Old World. When your great-great-great grandfather was but a boy, before the Great Exodus, he had snuck it out of the jewel mine he was forced to work in. Now it sat neatly above your fist. Every time you stab the blade through a ne'er-do-well's skull, your ancestor surely smiles in his grave.",
    		"pickupText", "The blade feels good in your hand. It hums in the wind, as though it is cutting the very air as it passes over the sword's edge.",
    		"isCarried", false
    	)
    )}
    

    You can also do something similar in your story's setup code by using curly braces { } to remove unwanted white space and line-breaks like I have done in the above example. This can help find mistakes.

    You can also do this with your passage logic but because the output is visible to the Reader you need to watch out for extra white spaces.
    {(if: $sword's isCarried is false) [
    Your (link: "sword") [
       	(set: $selectedItem to $sword)
    	(goto: "Item Description")
    ] stands upright, its notched and gnarled edge still fearsomely honed and half-buried in the earth.
    ]}
    
  • I was trying to get your example of this to work. I am new at this too :)

    This is what I did....

    In the link, use this instead:

    (set: $selectedItem to $sword's description)

    {(if: $sword's isCarried is false) [
    Your (link: "sword") [
    (set: $selectedItem to $sword's description)
    (goto: "Item Description")
    ] stands upright, its notched and gnarled edge still fearsomely honed and half-buried in the earth.
    ]}

    and then use this on the description page
    (print: $selectedItem)
Sign In or Register to comment.