Howdy, Stranger!

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

Array of links

So I'm trying to build an inventory system in Harlowe, but I've hit a bit of a snag. I want it so players can go to the inventory screen, then click on the items to do things with them and learn about them. However, something is going wrong. The end result is not displaying. It is defnitely recording items, but they are not displaying. Am I doing something wrong or can harlowe not do this?

Here is the code involved:
set: $inventory = (a: ((click: "Space Suit")[(go-to: "Space Suit")])

(print: $inventory.join("
"))

It won't display anything, but this code:
(print: $inventory's length) says 1 so it's being added to the array.

Comments

  • It's because a (click:) macro doesn't display anything. It just looks for the specified words in the passage and makes them into links. You need a (link:) macro instead, I believe.
  • In fact, further to my last comment (if it appears) you might be better off just putting plain text in your array, and then having your (click:)[] bits in a big list underneath in a pair of curly braces so they don't make a load of whitespace appear. A little crude maybe but I'm sure it would be a robust solution.
  • I originally had it under a (link:) macro and that wouldn't show up either.
  • It won't display anything...
    Please use the C button on the comment field's toolbar to wrap your examples in code tags, it makes them easier to find and read.

    There are a number of issues with your example:

    a. As explained by @SuperSibbers and shown in the (click: ) macro documentation that macro based link attached to either an named hook or to existing text, a (link: ) macro would be a better fit for what you're trying to do.

    b. There are a number of syntax errors in your first example: missing parenthesis, parenthesis in the wrong place, etc..

    c. You are trying to store a Changer command directly in an array, it would be better if you converted it to a String first.

    Try the following:
    (set: $inventory to (a: '(link: "Space Suit")[(go-to: "Space Suit")]' ))
    
    (print: $inventory.join("
    "))
    
    note: the usage of both single and double quotes to distinguish the inner String parameters of the (link:) and (go-to:) macros from the outer/overall String being added to the array.
  • That worked perfectly. Thank you.
Sign In or Register to comment.