Reply
Honored Resident
eref
Posts: 14
0 Kudos

type Mismatch error

I am very new to second life scripting and thought i would try to make a script that changes the textures on the top and bottom of a cylinder (modeling a coin)

the idea is "If top side = heads

then

change top to tail and bottom to heads

else

change top to tails and bottom to heads

 

like i said i am very new to this scripting

here is the script i am trying:

 

default
{
    touch_start(integer x)
    {
     if(llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",0)==TRUE)

 {
     llSetTexture("49ee2c06-3eb4-3979-c72d-ca71ffa8e435",0);
     llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",2);
 
   
    }
    else
    {llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",0);
 llSetTexture("49ee2c06-3eb4-3979-c72d-ca71ffa8e435",2);
}
}
}

I am getting type mismatch   - (4,68) Error type mismatch

some help please

 

 

 

 

Dora Gustafson
Posts: 1,869
Registered: ‎10-05-2009
0 Kudos

Re: type Mismatch error

Reply to eref - view message

Try this:

default
{
    touch_start(integer x)
    {
        if ("c69a44a2-8bef-641f-50b5-790737a4bd3a"==(string)llGetTexture(0))
        {
            llSetTexture("49ee2c06-3eb4-3979-c72d-ca71ffa8e435",0);
            llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",2);
        }
        else
        {
            llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",0);
            llSetTexture("49ee2c06-3eb4-3979-c72d-ca71ffa8e435",2);
        }
    }
}

 llSetTexture does not return anything so you can't compare it to anything

Rolig Loon
Posts: 24,905
Registered: ‎10-05-2009
0 Kudos

Re: type Mismatch error

[ Edited ]

Reply to eref - view message

The statement

if(llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",0)==TRUE)

doesn't make any sense at all.  You are asking llSetTexture to place the texture named "c69a44a2-8bef-641f-50b5-790737a4bd3a" on the top face of your object, but that action is not something that has a TRUE/FALSE outcome.  It's not a testable condition.  I imagine that you are trying to ask whether that texture is on face 0 of your object. If so, you'd need to ask something like

 

if (llGetTexture(0) == "c69a44a2-8bef-641f-50b5-790737a4bd3a")
{
    //Do stuff if that if statement evaluates to TRUE
}
else
{
    //Do other stuff if it's FALSE
}

 Even though that's syntactically correct, of course, it won't do what you want.  After all, face 0 remains on the same part of the object even if the object is turned upside down.

 

Not as dumb as I look
Dora Gustafson
Posts: 1,869
Registered: ‎10-05-2009
0 Kudos

Re: type Mismatch error

Reply to Rolig Loon - view message


Rolig Loon wrote:

 Even though that's syntactically correct, of course, it won't do what you want.  After all, face 0 remains on the same part of the object even if the object is turned upside down.


Yes but the textures are swapped so it will look like it is flipped:smileyvery-happy:

Honored Resident
eref
Posts: 14
0 Kudos

Re: type Mismatch error

Reply to Dora Gustafson - view message

thank you for your help.

I tried your correction. I also feel that if i can swap the textures it will looked fliped.  unfortunately i cant get it to work.

i set the cylinder with the head and tail face on the top and bottom and put the textures into contents and  tried the script as suggested but as far as i can see nothing happened

i would appreciate any suggestions on how to make it work like a coin tossed.

 

 

Rolig Loon
Posts: 24,905
Registered: ‎10-05-2009
0 Kudos

Re: type Mismatch error

Reply to eref - view message

All I did was show you how an if test works.  You need to fit that idea into the logic of your own script.  If you want to switch the textures randomly, you'll need......

(1) A trigger to make the textures change  (Touch.  That part's pretty straightforward.)

(2) A way to choose which end is up, at random (See llFrand)

(3) A way to actually paint the correct textures on the top and bottom of your "coin." (This is the part you already have).

So what you need to do is write step #2.  The result of that step is what you will have to test with your if statement.

Once you have that done, you'll have your basic coin and you can think about bells and whistles to make it look more exciting.

Not as dumb as I look
Dora Gustafson
Posts: 1,869
Registered: ‎10-05-2009
0 Kudos

Re: type Mismatch error

Reply to eref - view message


eref wrote:

I tried your correction. I also feel that if i can swap the textures it will looked fliped.  unfortunately i cant get it to work.

i set the cylinder with the head and tail face on the top and bottom and put the textures into contents and  tried the script as suggested but as far as i can see nothing happened

i would appreciate any suggestions on how to make it work like a coin tossed.


It works fine for me because I do not "put the textures into contents" like you do:smileywink:

llGetTexture(integer face) returns the texture name if the texture is contained, otherwise it returns the UUID and that is why it works for me and not for you.

Every time you touch the coin the textures are flipped like you suggested in the OP

default
{
    touch_start(integer x)
    {
        if ("c69a44a2-8bef-641f-50b5-790737a4bd3a"==(string)llGetTexture(0))
        {
            llSetTexture("49ee2c06-3eb4-3979-c72d-ca71ffa8e435",0);
            llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",2);
        }
        else
        {
            llSetTexture("c69a44a2-8bef-641f-50b5-790737a4bd3a",0);
            llSetTexture("49ee2c06-3eb4-3979-c72d-ca71ffa8e435",2);
        }
    }
}

To toss the coin, turn to what Rolig said about that subject.

 

Honored Resident
eref
Posts: 14
0 Kudos

Re: type Mismatch error

Reply to Rolig Loon - view message

thank you for your help i appreciate it.

you are a little ahead of me as in this version of the coin i am just trying to swap faces when clicked.

I will next ry to make one that swaps faces randomly . Thank you again for your tips and advice :smileyhappy:

Honored Resident
eref
Posts: 14
0 Kudos

Re: type Mismatch error

Reply to Dora Gustafson - view message

thank you so much for your help. I will take out the textures and try it. My next step is a coin that is random   but then i want one that always come down heads for me alone. :smileyhappy:

Thanks again for your help greatly appreciated

 

 

Rolig Loon
Posts: 24,905
Registered: ‎10-05-2009
0 Kudos

Re: type Mismatch error

Reply to eref - view message