eref Posted November 14, 2011 Share Posted November 14, 2011 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 = headsthenchange top to tail and bottom to headselsechange top to tails and bottom to heads like i said i am very new to this scriptinghere 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 mismatchsome help please Link to comment Share on other sites More sharing options...
Dora Gustafson Posted November 14, 2011 Share Posted November 14, 2011 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 Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 14, 2011 Share Posted November 14, 2011 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. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted November 14, 2011 Share Posted November 14, 2011 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: Link to comment Share on other sites More sharing options...
eref Posted November 14, 2011 Author Share Posted November 14, 2011 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. Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 14, 2011 Share Posted November 14, 2011 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. Link to comment Share on other sites More sharing options...
Dora Gustafson Posted November 14, 2011 Share Posted November 14, 2011 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. Link to comment Share on other sites More sharing options...
eref Posted November 14, 2011 Author Share Posted November 14, 2011 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 Link to comment Share on other sites More sharing options...
eref Posted November 14, 2011 Author Share Posted November 14, 2011 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. Thanks again for your help greatly appreciated Link to comment Share on other sites More sharing options...
Rolig Loon Posted November 14, 2011 Share Posted November 14, 2011 See http://community.secondlife.com/t5/LSL-Scripting/Coin-Toss/m-p/893467/highlight/true#M2509 Link to comment Share on other sites More sharing options...
Recommended Posts
Please take a moment to consider if this thread is worth bumping.
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now