Random text and pictures

JMC
08 Feb 2014, 20:07
Hello,

I'm very new to this program, so there's a great deal I don't understand. There is something I am trying to do in the gamebook I am writing, but I am not sure if it is possible.

I can get the random text option to work fine, but I am wondering if it is possible to link a picture to each different text possibility. That is, if random text A is displayed, then picture A is displayed, but if random text B is displayed, then picture B is displayed.

I attempted to "nest" the {img} command in the random text command, but that didn't work. Is there a way to make this work or is it simply not doable?

Thanks!

JMC

george
08 Feb 2014, 21:41
Yes this is doable, but I don't think you can do it in the text processor unfortunately.

edit: for what it's worth, this seems like a text processor bug so it'd be worth reporting it.

Here's how I did it in gamebook mode in the web editor:

1. Choose Page type --> Script
2. Add new script --> Variables --> Set a variable or attribute
3. Set variable random = expression GetRandomInt(0, 1)
4. Add new script --> Scripts --> If
5. If expression random = 0
6. Add new script --> Print
7. Print message First choice {img: filename}
8. Add Else If
9. Else if expression random = 1
10. Add new script --> Print
11. Print message Second choice {img: filename}

A couple of notes:

* You can choose Page type Script + text and do basically the same thing to combine this with static text.

* If you want to intertwine random text with static text you can have a series of Print scripts combined with a script like the above. Unfortunately more work than just using plain text with the text processor.

* The above in code view:


random = GetRandomInt(0, 1)
if (random = 0) {
msg ("First choice {img:lava canyon 004.jpg}")
}
else if (random = 1) {
msg ("Second choice {img:lava canyon 006.jpg}")
}

JMC
09 Feb 2014, 01:42
That was perfect! Thank you so much for taking the time to respond. That is exactly what I wanted. I just tried it out and it worked perfectly.