someone was asking for help on this (probably have an idea of what you're thinking or going to say about that but anyway...)
they wanted to make it so whenever they pressed a key, a random image would be selected every time. I suggested putting the images in an array and using random(); referencing the array list. but what i attempted actually didn't work. and i'm not sure why. any clue on what happened? here is my attempt
i won't use their actual image for this example since they're all strings anyway.
PHP Code:
function onCreated(){
temp.images = { "test1", "test2"};
temp.random = int(random(temp.images[0], temp.images[1]));
echo(temp.random);
}
i also tried something a friend of mine did. which was
PHP Code:
function onCreated(){
temp.images = { "test1", "test2" };
temp.random = int(random(0, temp.images.size() ));
echo(temp.random);
}
i also put the data in echo directly. but no matter how i did it they all came out as: -1, 0, -1
or: 1, 0.
are those correct outputs? was i wrong in expecting it to output the images name or whats happening?