0

I'm reasonably comfortable with JavaScript, but new to Twine, which is sort of a shortcut platform for making interactive, branching stories/games. The Twine forum does not appear to be heavy on coders, so I'm hoping someone over here can help me. I want to have a player draw three tarot cards, and have the game show the title and text for each one. The cards can't repeat. I also want to manipulate the deck artificially so the player won't draw 2 10s in a row, for example.

I've been through the documentation, but I'm not figuring out how to declare and manipulate variables in a way that I can use them in JavaScript and Twine both. In plain JavaScript, I'd make an array deck with elements that look like,

1 = {
   cardName: "Ace of Cups"
   cardTxt: "Unexpected little bit of hope.  As though a stranger buys you a cool drink in the middle of a hot day.",
   cardType: pip,
   cardNbr: 1,
};

Twine uses this such that in examples I've seen, scripts refer to variables as this.title or this.power. I'm not sure what it's pointing to, though, and therefore I don't know whether I need this.deck or something else or what.

There isn't a lot online as far as examples or tutorials; I've been looking at http://eturnerx.blogspot.com/2012/12/how-to-use-parameters-and-variables-in.html and http://twinery.org/forum/index.php?topic=1472.0 . Twine's explanation of how to write macros (lightweight functions, more or less) is at http://twinery.org/wiki/custom_macro and their treatment using JavaScript with Twine is at http://twinery.org/wiki/script .

Once I know how to reference variables, I think I can display material in the story as [whatever???].1.cardName and [???].1.cardTxt, without having to do anything else, but if I'm wrong there, please feel free to advise me.

JJJ
  • 32,902
  • 20
  • 89
  • 102
poetiscariot
  • 189
  • 1
  • 2
  • 12
  • Please explain what you've tried when you've tried something, and how it doesn't work if it doesn't work. Some links to the examples you're considering would be helpful as well. – hcs Nov 06 '14 at 22:56
  • I haven't been able to try anything because I don't know how to name variables in the Twine passage and in JavaScript to get them to deal with the same data. I added links I've found to the original question, but they're of fairly limited use. Twine itself outputs projects in a format that isn't human-readable, so you can't pull up a story and look at the source to see how it works. – poetiscariot Nov 07 '14 at 04:30
  • @poetiscariot "Twine itself outputs projects in a format that isn't human-readable" is exactly the reason these "no coding required frameworks" are the worst thing that can happen to anyone. – Winchestro Nov 07 '14 at 04:41
  • Believe me, I know. I've been messing with this for a couple days, and my impression so far is that while it does make certain things that are difficult in JavaScript easy, its other capabilities are so limited that I'm not even sure it's possible to do things in it that would be easy in JavaScript (I can't wait til I get to the part where I need to make something happen on a mouseover instead of a click, oh boy). But that's what this project needs to be built in, so here I am. – poetiscariot Nov 07 '14 at 19:49
  • Since this question is more specific to Twine than JavaScript, I think you'd be more likely to get an answer if you posted on the [Twine forums](https://twinery.org/forum/). (If you do get an answer there, please also [post an answer here](http://stackoverflow.com/help/self-answer) with a copy or link!) – Malcolm Mar 26 '16 at 01:20

0 Answers0