[Tutorial TyranoBuilder 1.7] Get Random From Array Using Java Script
28
0
0
0
1
ShareFavoritePlaylistsFlag
8oni
8oni
Published
Just really simple ways to use Java Script to get random text from array.
Here is full code :
var myArray = [
"Bob",
"Killua",
"Gon",
"Phoebe",
"Amy",
"Maya",
"Akira"
];

var randomItem = myArray[Math.floor(Math.random()*myArray.length)];

[loadjs storage="fruit.js"]
[eval exp="f.randomfruit=randomItem"]
#8oni
Hi [emb exp="f.randomfruit"]! It's nice to meet you!

Documentation :
https://css-tricks.com/snippets/javascript/select-random-item-array/
http://tyranobuilder.com/tyranoscript-tags-reference/#loadjs
Expand