Howdy, Stranger!

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

Either and Images

edited September 2014 in Help! with 1.x
Can you use the Either command to display from a random selection of images in the story? I can't figure out the syntax for how to do that, if it can be done.  Something like <<display either ([img[1]].[img[2]],[img[3]])>>, though that doesn't work.

Comments

  • <<set $image to either(1,2,3)>>
    <<if $image is 1>>[img[1]]<<elseif $image is 2>>[img[2]]<<elseif $image is 3>>[img[3]]<<endif>>

    edit: added the missing <  in <<endif>>
    typed it up quick, glad you caught it
  • Muze wrote:

    <<set $image to either(1,2,3)>>
    <<if $image is 1>>[img[1]]<<elseif $image is 2>>[img[2]]<<elseif $image is 3>>[img[3]]<endif>>

    That does not seem to work... I can vaguely see whats going on here; trying to set a variable as a random number and then to display the connected image if that number is chosen.  I'm not sure why it isn't working cause that makes sense, to me at least.

    It says that <<if $image is 1>> does not have a matching end tag. I think there's a syntax error here somewhere.

    Found it. The last tag was <endif>> instead of <<endif>>. Those little errors, right?

    Anyways, it works just fine now. Thank you!

    Is there a good way to use the "Random" function to select a random number between two variables rather then listing every variable?
  • piecewise wrote:

    Something like <<display either ([img[1]].[img[2]],[img[3]])>>, though that doesn't work.


    In addition to what Muze has already suggested, this should also work:

    <<print either("[img[1]]", "[img[2]]", "[img[3]]")>>

    piecewise wrote:

    Is there a good way to use the "Random" function to select a random number between two variables rather then listing every variable?


    If by "variable" you mean value, then yes.  For example, to get a number within the range 13 you'd do:
    random(1, 3)
  • TheMadExile wrote:


    In addition to what Muze has already suggested, this should also work:

    <<print either("[img[1]]", "[img[2]]", "[img[3]]")>>


    That's a more efficient way to do it, thanks
Sign In or Register to comment.