Howdy, Stranger!

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

Dice Roll Macro

Hello,
I'm new and I'm not a programmer, so sorry if my request is stupid!
I need a macro that allow dice rolls. I've searched around internet and also in this forum but I didn't find anything.

I need something like:
A monster want to kill you.


[[I try to run away]]
MACRO (in case he tries to runaway) If the player rolls 6, 5 or 4 (using 1d6) so go to this paragraph, if he rolls 1, 2 or 3 go to to this other paragraph.


Comments

  • It's always a good idea to state which story format you're using.

    Anyway.  For your stated use case, you could simply use the either() function, which randomly returns one of the arguments it's passed.  For example:

    [[I try to run away|either("Place A", "Place B")]]
    Alternatively, you could use the random() function.  For example:

    <<if random(1, 6) lt 4>>[[I try to run away|Place A]]<<else>>[[I try to run away|Place B]]<<endif>>
  • Hi TheMadExile,
    Thank you very much! I'm running version 1.4.2 sorry!
    The function either seems good, is there a way to apply some modifier to the random result? Just to add more probability to one result to
    Anyway thank you, you have definitely helped me a lot :))
  • LaStregona wrote:

    I'm running version 1.4.2 sorry!


    That's the Twine version, not the story format.  If you've changed nothing, then the story format you should be using is Sugarcane.


    LaStregona wrote:

    The function either seems good, is there a way to apply some modifier to the random result? Just to add more probability to one result to


    Using either(), the way would be to add more entries to the list it's picking from.  For example:

    75% / 25%
    either("Place A", "Place A", "Place A", "Place B")
    As long as you don't have too many entries, it's not a bad way to handle it.

    Alternatively, using random() might be a tad nicer when you would need lots of entries.  For example:

    90% / 10%
    <<if random(1, 10) lt 10>>[[I try to run away|Place A]]<<else>>[[I try to run away|Place B]]<<endif>>
  • SugarCube sorry again, I'm so noob!
    Thanks for your answer. I have tried it and it works perfectly.

    Last question when i test play I see the sentence: [[I try to run away|either("Place A", "Place B")]] highlighted in red.
    Do you know how can I change this in my stylesheet passage?

    Ok it was my fault :P

    Thank you, everything runs perfectly!

    We should create a topic with all the functions available in Twine and how to use it. I think it would be very useful for other noob like me!
  • LaStregona wrote:

    We should create a topic with all the functions available in Twine and how to use it. I think it would be very useful for other noob like me!


    Well, for story formats in general there's the Twine wiki.  Additionally, SugarCube has its own documentation, as there are parts which differ from the vanilla story formats.
Sign In or Register to comment.