Howdy, Stranger!

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

Help with array push in Twine 2 *answered*

*answered*

Comments

  • edited May 2015
    I’d guess that this is because the array always only holds 1 value, which is a combination of the first and last names…?

    Essentially:
    (a: "John Doe","Joe Fawn","Etc.")
    
    I think you’d have to create a Data Map in order to hold first and last names to accomplish what you want.
  • $nameholder is a string that includes both first and last name (and a space in between.) So the string I'm trying to push into the $recruits array is "joe fawn", not two separate strings of "joe" and "fawn."

    Basically the problem is that the push isn't working. You can ignore the $nameholder thing. If you try and push a simple string, like "dumbo" without using the $nameholder variable in the push function, it still doesn't work.
  • note: the following is just for informational purposes.

    Leon has suggested in a previous posting that the default way to add items to an array in Harlowe is to concatenate / add two arrays together:
    Initialize the list array
    (set: $list to (a: "cat"))
    
    initial list: (print: $list)
    count: (print: $list's length)
    
    Adding Dog to the list.
    (set: $list to it + (a: "dog"))
    
    amended list: (print: $list)
    count: (print: $list's length)
    
Sign In or Register to comment.