0

I'm actually trying to do a random image picker to make the game more real.

here is the actual code

<<set $randomimage = random(5)>>

[img["home" + $randomimage.jpg]]

I'm only an amateur but it seemed logic to do it that way for me but it appears that in chrome my variable $randomimage is undefined. Getting this error:

<img src="homeundefined">
Linda Paiste
  • 38,446
  • 6
  • 64
  • 102
volen
  • 23
  • 3
  • That's not PHP though. That's TwineScript, which is based on JavaScript. It just happens that the variables start with `$` just like PHP. – M. Eriksson Feb 28 '19 at 13:03
  • I know but it's quite similar to php http://www.motoslave.net/sugarcube/2/docs/ – volen Feb 28 '19 at 13:25
  • Similar !== same – M. Eriksson Feb 28 '19 at 14:38
  • When I tried to put "sugarcube" or "twine" as a tag it didn't work telling me I was needing more reputation to create a tag, so I put the langage that was for me the most similar. (I'm not arguing) – volen Feb 28 '19 at 14:55

1 Answers1

0

Here is the solution:

<<set $randomimage = random(5)>>

[img["home" + $randomimage + ".jpg"]]
volen
  • 23
  • 3