Howdy, Stranger!

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

Newbie here with a serious question!

Hey everyone!
So I'm going to get straight to the point; I just started using Twine 2.0 a while ago and I've been working on an awesome story with set characters. I've decided that I want to give readers the ability to choose the 'class' of the main character so that they can play with different sets of stats and skills.

There are 4 classes all together, and each class has 5 stats (strength, magical strength, defense, magical defense, speed) that can rank from 1-10.

So for example, the warrior class is (9, 3, 8, 5, 7)

Right now, I'm using simple variables to define each class in one passage, which means I've defined 20 variables.

Here's the question: Is there a way I can 'group' together 5 variables under 1 command/variable, so that the passage can read the specific stats?

Sorry for my writing, I appreciate any help!


  • You should state which format you're using since the syntax will depend on that.

    Assuming you're using Harlowe, you can use a datamap for each class.
    (set: $warrior to (datamap: "strength", 9, "magical_strength", 3, "defence", 8, "magical_defence", 5, "speed", 7))

    You'd access the individual stats like this
    (print: $warrior's strength)
    (print: $warrior's magical_strength)

    I used underscores rather than spaces in magical_strength and magical_defence since otherwise you'd need to remember to put quotes round those stats when accessing them.
  • Apologies, I knew to mention it but forgot to include the fact that it was Harlowe. I have some knowledge of HTML and Harlowe just seems like the easiest way to get a project prototyped.

    Thank you!
Sign In or Register to comment.