Howdy, Stranger!

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

Show 2 random options among a longer list (Snowman)

Hi everyone,

I am trying to build a very simple CYOA on Twine 2.
As soon as I start the story I would like to have several passages, but I want the users to see only two of them chosen randomly among them every time they reload the page.
By doing that the same user could play more than one time and it will be likely to have different outcomes every time.

At the moment I am using Snowman and I tried to use "print either" or "display either", but the results are both confusing and disappointing (see the pic attached).
I am ok to change story format if necessary, but I was using Snowman as it is more "clean" and it behaves better when embedded inside my website.

Thanks in advance for your help,

Leonardo

Comments

  • edited May 2017
    That code looks like SugarCube code. Something similar in Snowman might look like:
    bla bla bla
    
    <%
    switch (Math.floor(Math.random() * 4)) {
      case 0:
        print('[[Passage 1]]');
        break;
    	
      case 1:
        print('[[Passage 2]]');
        break;
    	
      case 2:
        print('[[Passage 3]]');
        break;
    	
      case 3:
        print('[[Passage 4]]');
        break;
    }
    %>
    
  • I was using Snowman as it is more "clean" and it behaves better when embedded inside my website.
    FYI: Snowman has very limited built-in functionality and is designed to be used by an Author that either already knows how to program using HTML/CSS/Javascript and the related libraries; or by one willing to learn those technologies.

  • klembot wrote: »
    That code looks like SugarCube code. Something similar in Snowman might look like:
    bla bla bla
    
    <%
    switch (Math.floor(Math.random() * 4)) {
      case 0:
        print('[[Passage 1]]');
        break;
    	
      case 1:
        print('[[Passage 2]]');
        break;
    	
      case 2:
        print('[[Passage 3]]');
        break;
    	
      case 3:
        print('[[Passage 4]]');
        break;
    }
    %>
    


    Thank you klembot

    I tried this code and I am getting closer to what I want to do.
    The question now is:
    If I want to print more than one random option, how do I prevent this code to show the same option twice?
Sign In or Register to comment.