Touch script to flip textures using UUID for the textures......
|
|
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
|
08-01-2006 05:59
Hello, I recently got help to make it so only the owner can flip though textures using a simple touch script. After realizing the buyer could steal all my textures even if its set to no copy or no transfer I tried to make the script work with only UUID texture code. I got it to work, sorta. At first if I touched the prim with the script, it would flip through all the textures without stopping up till the last one and then stop. So then I figured something out after that where it would stop after each flip but once it got to the last UUID it wouldnt restart back to the first UUID in the script.
Basicly, how would I have the script restart back to the first UUID after the last UUID to make it an contiunos cycle?
Any help would greatly be apprecaited as always. =)
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-01-2006 06:41
It depends a bit on precisely how you've scripted it. But basically you must have some sort of pointer for which texture you're displaying, whether straight from inventory, from a list or whatever.
All the various size functions (llListLength(), llGetInventoryNumber() for this application) return the number as we'd count them (starting from 1), but lsl numbers them from 0.
So, when your pointer equals the count of the textures to display you reset it to 0 and the loop starts again.
|
|
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
|
08-01-2006 06:56
I would be using textrues sraight from my inventory (not the prims inventory). I keep re-reading the advise you gave me. Looking at the script I have here. Playing with a few ideas, but I'm shooting blanks. Would it be possible to give an example that I could maybe learn from. That would help a lot. I appreaciate your reply. =)
|
|
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
|
08-01-2006 08:33
list UUIDs = ["UUID1","UUID2","UUID3"]; // Insert UUIDs here integer length = llGetListLength(MyList); // Find the number of UUIDs given integer textureNum = 0; // Get ready to start running through textures integer side = 0; // The side of the prim to texture
default { state_entry() { llSetTexture(llList2String(UUIDs, textureNum), side); // Set the texture to the first UUID listed }
touch_start(integer total_number) { if(textureNum != length) { // If we haven't reached the end of the list... ++textureNum; // ...find the next UUID and... llSetTexture(llList2String(UUIDs, textureNum), side); // ...load the next texture } else { // Otherwise... textureNum = 0; // ...go back to the first texture and... llSetTexture(llList2String(UUIDs, textureNum), side); // ...load it } } }
I haven't logged in to test this, but it should work fine. To make it only allow the owner to change it, change this: touch_start(integer total_number) { if(textureNum != length) { // If we haven't reached the end of the list... llSetTexture(llList2String(UUIDs, textureNum), side); // ...load the next texture } else { // Otherwise... textureNum = 0; // ...go back to the first texture and... llSetTexture(llList2String(UUIDs, textureNum), side); // ...load it } }
...to this: touch_start(integer total_number) { if(llDetectedKey(0) == llGetOwner) { // If the owner touches it if(textureNum != length) { // If we haven't reached the end of the list... llSetTexture(llList2String(UUIDs, textureNum), side); // ...load the next texture } else { // Otherwise... textureNum = 0; // ...go back to the first texture and... llSetTexture(llList2String(UUIDs, textureNum), side); // ...load it } } }
That should do the trick 
|
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
08-01-2006 08:37
OK, if you're doing it that way, you need a list of the keys in your script. I won't put in real keys, but something so you can see what it should like. list textures=["0", "1", "2"]; //This bit needs your texture keys rather than 0, 1, 2! integer num; integer pointer=0;
default { state_entry() { num=llGetListLength(textures); llSetTexture(llList2String(textures, 0), ALL_SIDES); llSetTimerEvent(5.0); } timer() { pointer++; if(pointer >= num) pointer = 0; llSetTexture(llList2String(textures, pointer), ALL_SIDES); } } Not tested in world but it should do the job. There are ways to automatically grab the textures from full perms textures and not keep the texture in the object's inventory too, but we'll leave, it's extra to your request.
|
|
Xixao Dannunzio
Owner, X3D Enterprises
Join date: 20 Mar 2006
Posts: 114
|
08-01-2006 08:39
From: Eloise Pasteur OK, if you're doing it that way, you need a list of the keys in your script. I won't put in real keys, but something so you can see what it should like. list textures=["0", "1", "2"]; //This bit needs your texture keys rather than 0, 1, 2! integer num; integer pointer=0;
default { state_entry() { num=llGetListLength(textures); llSetTexture(llList2String(textures, 0), ALL_SIDES); llSetTimerEvent(5.0); } timer() { pointer++; if(pointer >= num) pointer = 0; llSetTexture(llList2String(textures, pointer), ALL_SIDES); } } Not tested in world but it should do the job. There are ways to automatically grab the textures from full perms textures and not keep the texture in the object's inventory too, but we'll leave, it's extra to your request. Bear in mind, this will continue to flip through the textures. Not sure which way you're wanting to go. Use my script if you want to touch it for each change, or this way to have it cycle through automatically.
|
|
Jordan Carnot
Registered User
Join date: 9 Apr 2006
Posts: 4
|
08-01-2006 10:59
you could always use the above code to have it flip thru the textures every 10 seconds, and then have "Next" and "Previous" buttons that would stop that timer event and create a new 'timeout'. Example outline...
1) Textures flip every 10 seconds 2) User comes up and presses next/previous, or touches the vendor 3) 10 second Flip timer stops, and a timeout timer of 30 seconds begins 4) After 30 seconds, the flip timer restarts.
This effect could be achieved via states, or simply variables with TRUE or FALSE, and then use an if else conditional in the timer() event to handle it.
if (textureLoop == TRUE) { loop timer } else { 30 second timeout }
and remember to reset the 30 second timer every time the unit is touched and every time a button on the unit is pressed, that way the user has longer than 30 seconds to browse
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
08-01-2006 17:35
just becuase list textures = ["uuid1","uuid2","uuid3"];
integer count = 3; // usually ill use llGetListLength integer place;
default { touch_start(integer t) { llSetTexture((key)llList2String(textures, place), ALL_SIDES); if (place != (count - 1)) ++place; else place = 0; } }
|
|
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
|
08-01-2006 18:37
Slightly smaller: list Textures = ["uuid1","uuid2","uuid3"];
integer Texture;
default { touch_start (integer t) { llSetTexture (llList2Key (Textures, Texture++), ALL_SIDES); Texture %= llGetListLength (Textures); } }
|
|
JR Breed
Registered User
Join date: 17 Jan 2006
Posts: 49
|
08-01-2006 19:04
You guys KICK ASS! I learned quit a bit from here. Thank you so much for all this support. VERY apprecaited!!
Edit
Problem; Only 1 side of the prim flips through the texture. I tried changing the "integer side = 0;" number to everthing. It only changed 1 side no matter what. Im starting to think that I shoulda added that bit of detail into my original post.
Edit
I figured it out.. just changed "side" to "ALL_SIDES" Once again thanks for all the great help!
|