I'm a rookie scripter and I'm creating a Tarot card. The card contains the tarot textures and displays each at random on touch. If the owner says "Reset" it rests back to the cardback texture. That much works.
With Tarot, cards can be either way up and the orientation affects the meaning. So...I am trying to further adapt the script so that when the card is touched, it generates a random number 0 or 1. If the random number is 1, then the texture is rotated 180 degrees. I tested the random number generator part out separately, but now i have added it in, it always seems to generate the same number.
This is the script
string texture;
string keyword = "reset";
integer channel = 0;
integer Handle;
default
{
state_entry() {
Handle = llListen (channel, "", llGetOwner(), ""
;}
changed(integer change)
{
if (change & CHANGED_OWNER)
llResetScript();
}
listen(integer chan, string name, key id, string msg)
{
if (msg == keyword) {
llSetTexture("13de8f92-9da6-c5c8-1ca0-48f7446435cb", ALL_SIDES);
llListenRemove(Handle);
Handle = llListen (channel, "", llGetOwner(), ""
;}
}
touch_start(integer total_number)
{
integer number = llGetInventoryNumber(INVENTORY_TEXTURE);
float rand = llFrand(number);
integer choice = (integer)rand;
string name = llGetInventoryName(INVENTORY_TEXTURE, choice);
if (name != ""

llSetTexture(name, ALL_SIDES);
float random = llFrand(1);
integer direction = (integer)random;
if (direction = 0)
llRotateTexture(PI/2, ALL_SIDES);
}
}
I know there is probably redundant code in here, i have cannibalised other scripts. Also, I know that PI/2 only rotates by 90 degrees. I was going to deal with that when I got the other bit to work, but any advice on the correct rotation value would be a great help.
Any help on getting this to work will help save my remaining hairs.
Cheers