Twine 2 status?

191 views
Skip to first unread message

Martin Ellison

unread,
Sep 28, 2014, 10:24:13 AM9/28/14
to twee...@googlegroups.com
Hello everyone, how is Twine 2 going?

Also, is there more documentation. I cannot work out how to use arrays. How do I add a new member to an array? Can I join arrays to make a string? (I was trying to make an inventory list).

Tory H

unread,
Sep 29, 2014, 12:28:52 PM9/29/14
to twee...@googlegroups.com
Hi, Martin! Good to have you here.

Turns out Twine arrays are handled like standard Javascript arrays--which are themselves a little strange IMO. Here's how to add something to a list (within a Twine passage):

    <<set $currentLoops = [] >>
    <<set $march = "march.mp3">>
     
    Add a parade...

    <<set $currentLoops.push($march)>>

    Now remove it...

   <<set $currentLoops.splice($currentLoops.indexOf($march),1)>>

If there's a simpler way to remove a given item from a list in Twine, I haven't seen it.

I'll look into adding this to the Twine wiki under "Scripts."

I hope this helps. Holler! if it doesn't.

Stormrose

unread,
Sep 29, 2014, 1:46:13 PM9/29/14
to twee...@googlegroups.com
You should be able to join arrays for printing using Javascript.

<<print $myarray.join(", ")>>

Change the bit in the double quotes to get a different list seperator.

Tory H

unread,
Sep 29, 2014, 2:01:47 PM9/29/14
to twee...@googlegroups.com
Ahhh, I left out that bit! Thank you, Stormrose!

WIll add to the wiki...

Martin Ellison

unread,
Oct 4, 2014, 4:13:13 AM10/4/14
to twee...@googlegroups.com
I was asking about Twine 2 specifically, and your remarks appear to be about Twine 1.x.

Regards,
Martin

--
You received this message because you are subscribed to a topic in the Google Groups "Tweecode / Twine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tweecode/B4hzTHB4he8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tweecode+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Stormrose

unread,
Oct 4, 2014, 12:06:21 PM10/4/14
to twee...@googlegroups.com, m...@acm.org
Correct. My bad.

Martin Ellison

unread,
Oct 5, 2014, 3:47:44 AM10/5/14
to twee...@googlegroups.com
@Stormrose: no need to apologise; I'm sure someone will find your comments useful. But I'd like to know if Twine 2 is still actively under development.l

Tory H

unread,
Oct 5, 2014, 11:41:08 AM10/5/14
to twee...@googlegroups.com

It sure is! You can follow updates on the Twine 2.0 story format Harlowe at bitbucket: https://bitbucket.org/_L_/harlowe/commits

Hope this helps.

@Stormrose: no need to apologise; I'm sure someone will find your comments useful. But I'd like to know if Twine 2 is still actively under development.l

Miguel Garza

unread,
Dec 21, 2014, 11:19:25 PM12/21/14
to twee...@googlegroups.com
You can make the syntax from removing items from an array simpler by adding this code to a passage tagged [script]:

// Removes an element from an array.
// String value: the value to search and remove.
// return: an array with the removed element; false otherwise.
Array.prototype.remove = function(value) {
var idx = this.indexOf(value);
if (idx != -1) {
    return this.splice(idx, 1); // The second parameter is the number of elements to remove.
}
return false;
}

Then you can remove an item like this:  <<set $currentLoops.remove($march)>>

I stole that code from http://www.simonewebdesign.it/how-to-remove-element-from-array/

:)
Reply all
Reply to author
Forward
0 new messages