Howdy, Stranger!

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

Slideshow

I want to do an image slideshow using a java script.  I have got the following to work in HTML, But I have no idea how to implement that into Twine.

I understand I need to put the java in the script passage and call it in my passage.  Just not 100% sure how to go about that.

Or is there an easy way to do this using just Twine

Thanks for any help.
<SCRIPT LANGUAGE="JavaScript">

var num=1
img1 = new Image ()
img1.src = "information.gif"
img2 = new Image ()
img2.src = "interference.gif"
img3 = new Image ()
img3.src = "message.gif"
img4 = new Image ()
img4.src = "nervous.gif"

text1 = "Text for Picture One"
text2 = "Text for Picture Two"
text3 = "Text for Picture Three"
text4 = "Text for Picture Four"

function slideshowUp()
{
num=num+1
if (num==5)
{num=1}
document.mypic.src=eval("img"+num+".src")
document.joe.burns.value=eval("text"+num)
}

function slideshowBack()
{
num=num-1
if (num==0)
{num=4}
document.mypic.src=eval("img"+num+".src")
document.joe.burns.value=eval("text"+num)
}

</SCRIPT>

HTML
<CENTER>
<IMG SRC="information.gif" NAME="mypic" BORDER=0 HEIGHT="100" WIDTH="100">
<p>

<FORM NAME="joe">
<INPUT TYPE="text" WIDTH="100" NAME="burns" VALUE="Text For Picture One">
</FORM>

<A HREF="JavaScript:slideshowBack()"> Back</A>

<A HREF="JavaScript:slideshowUp()"> Next</A>

Comments

  • OK this can be done pretty easily without Javascript.

    1: Create a new passage in Twine and call it "actualstart" without the quotes.

    2: Enter the following code in Start...
    <<silently>>
    <<set $picnum = 1>>
    <<endsilently>>
    <<display "actualstart">>
    3: Enter the following code in actualstart...
    <<silently>>
    <<if $picnum eq 5>>
    <<set $picnum = 1>>
    <<elseif $picnum eq 0>>
    <<set $picnum = 4>>
    <<endif>>

    <<if $picnum eq 1>>
    <<set $pictext = "The Oreo Generation">>
    <<set $piclink = "[img[oreo.jpg]]">>
    <<elseif $picnum eq 2>>
    <<set $pictext = "I want to eat the pizza!">>
    <<set $piclink = "[img[pizza.jpg]]">>
    <<elseif $picnum eq 3>>
    <<set $pictext = "The slinky of doom...">>
    <<set $piclink = "[img[slinkie.jpg]]">>
    <<elseif $picnum eq 4>>
    <<set $pictext = "Cat trips owner.">>
    <<set $piclink = "[img[wanted.jpg]]">>
    <<endif>>
    <<endsilently>>
    <<print $piclink>>
    [[Back|actualstart][$picnum = $picnum - 1]] | <<print $pictext>> | [[Next|actualstart][$picnum = $picnum + 1]]
    4: Job done.  Click here to see the example.

    Obviously substitute the variable names for your own and whatever else.  Hope it helps :)
  • Thank you for the help.  Only been using twine a few days.  Still learning the ropes.

Sign In or Register to comment.