Join us in Outworldz at www.outworldz.com:9000 or follow us:
This is Part 12 - Adding a texture server to your Xs Pet
Previous: New eyes!
You can now make your pet breed with textures! This has been the most requested feature for XS_Pets for some time now. There is a plug-in script that goes into your pet, and a script that goes into any old prim somewhere in Second Life.
This new feature allows you to both color and apply any texture to any prim in your pet, and do it remotely. You can add more textures for rare breeds at any time. And it's easy to operate remotely.
How Texture Breeding works:
When a pet breeds, the color of one parent is averaged with the color from the other parent. A little randomness (+/- 5%) is thrown in, too. The egg calculates this number, the result will be from from 0 to 1.0, and fetches the textures from a texture server. This texture is then applied to any prim with the same Object Name as the texture (not the Description, that is used for color). This is a neat trick, as it also lets you color your textures by putting the text 'color1' or 'color2' into the Description along with the texture name in the Name field.
Example: A pet colored <1,0,0> (red) breeds with a dark red pet <0.5,0,0>. The resulting breed number will be (1 + .5) /2, plus or minus a small random number. The result is 0.75, give or take 5%.
Normally, this would give you some red color, but not a pure red.
But we are applying this color to a texture. So how does that work? It depends upon how many textures you have loaded into the server.
If there were 10 textures in the server, they would represent numbers of 0 to 0.1,.1 to 0.2, 0.3 to 0.4 and so on. So we would get the texture in the 0.75 slot. This is the 7th texture.
If you had 100 textures ranging from red to violet , like this spectrum below, the above breeding of a pet wirth 1.0 (purple texture) with a 0.5 (green) would give you the 75th texture, which is a blue.
But you can have any texture in the server, so it is not limited to just a single color like the simple example above.
You can add many textures for each part of your pet, or just use one texture for all of it. It's totally flexible. All you have to do is give the texture the same name as the prim you wish to be painted with that texture. You can add textures the the server at any time and any pets that are born anywhere in world will be able to get those new breeds. You can have many different textures, too, by numbering the textures with a series of numbers. It's easy, flexible and fast. I'll cover how you name and number the textures in the section on "Naming Your Textures".
The texture server is made from one script plus all the textures for your
pet. You put these pieces into any prim somewhere in Second Life. This ONE
prim will handle any pets, anywhere on any sim. The script will always
need to be running, as the textures that appear on your pet will always come
from this server whenever they are born.
If you do not have land to put the texture server prim on, ask a friend with land to let you put the script and textures into a prim. The texture server is very low lag and will not affect any sim's operation. You can also get a single 4 X 4 (16 M) parcel which can hold a few prims for very little money (and no tier payment if you are a premium user).
The texture server is fast, simple to use and flexible. The speed comes from using the HTTP commands of Second Life. These commands let the pet talk directly to the texture server for quick and reliable communications. But there is a twist. A third server, a proxy server needs to be located outside Second Life. This server will 'tie' the pet to your in-world server:
Luckily, there is a really nice and simple to use proxy server made just for this purpose by Latif Khalifa at http:gridurl.appspot.com. This is a wonderful and useful service and it's free!
So how do we use it? Its easy as the script does all the work. The one thing you will need to do is to get a UUID for your texture server. Click this link and you will see a unique string of numbers and letters. It will look like "39635c95-736c-4d44-b7ed-aecf9b84fe91". This is your unique, random UUID. You will need to copy the UUID that you see into the script for the server and into a new plug-in script for your pet.
Each pet texture server must have it's own unique UUID. If you have two different pets with different textures, you will need to have two different server scripts, each with a unique UUID in them.Server script
Put the server script into your 'always rezzed' prim. You will also need to change this line to your unique UUID:
string UUID = "48246356-a7c5-474b-a6fe-f2cec98926b2"; do not use this number, use your own number from this link. You can change this number and the one in the server for each type of pet. One Server prim is used for each breedable pet species.
When you save the server script, you will see it connect to the proxy server and announce that it is 'ok'.
Pet Plug-in script
You need to add the pet plug in for textures to the root prim of your pet. You can download the script from here:
Put this script in your pet body, and change the UUID to your own unique UUID. This UUID is in the Pet texture plug in script.
If you are updating a older pet, you need to change to a new copy of the xs_brain script. Rez a pet container, unpack the pet, and replace the xs_brain script with the latest version from this zip file. You must be using version 0.36 or higher for this to work. Remember to change the Secret number and password to mat
You must put any textures you want to send to your pets in the same prim as
the server script.
The names must match the following pattern:
Where PrimName is the name you put in the prim to be textured, and N is a number from 0 to however many sets of skins you have.
Putting textures in the server forces the server to rescan the inventory automatically. There is no need to reset the server script.
Assume your pet has one texture, and you named this texture "pettexture". You made 5 different colors of this texture.
Now name any prims that you want to be colored with a single one of the above textures as 'pettexture'. if you wish to also color the root prim, add one more copy and call this texture root 0
Here is a 2-prim example, where you have a head and a body, and you want two different skins. So name the textures like this:
In this case, there should be two (or more) prims in the pet whose prim name is Body or Head. Now you will end up with two possible breeds for your pets, using either the first or second set of textures.
Lets assume you have a pet with 3 sets of breedable skins, made up of 4 different types of prims, such as 'head', 'body', 'leg' and 'tail'. There can be more prims that are not textured (they could be colored) but in this case we want specific textures to apply to each of the 4 parts.
So you will need 3X4, or 12 textures in all. You do not have to have them all at once, as you can add textures at any time to the server prim.
Now edit the pet, and change the name of the head to 'head', change the body name to 'body'. The body N texture will be applied to the body, and the head N texture will be applied to the head. Which one is chosen depends upon the sex of the parent.
Each texture must also a single digit after it to represent the breed type:
head 0, head 1 and head 2 would be three different head textures.
body 0, body 1, and body 2 are three different body textures. The 0th one should match the 0th head, and so on.
The same logic applies to the leg texture.
You may have up to 256 items in the server, including the script. In the above example, there are 4 textures per skin set, so you can have 255/4, or 63 skin sets for your 4-texture pet. A single texture pet can have up to 255 skins.
What about the root prim?
The last prim you link to is the root prim. It holds the xs_pet scripts. Normally, it is invisible, but not always. Since your pets can have any name stored in the root prim, this would change the name of the root prim and break this system.
So I made a special reserved name in the texture server
'root' which is reserved for the texture for the root prim. Just use "root
0" for of the first root prim texture, "root 1" for the second, and so on.
If your root prim is an invisible prim or is not to be textured, you can ignore
this 'root' name.
How can I test this?
There is a special test script you can put in your pet or into a box as a test.
Test Texture server script
An easy way to test your server is to make a set of boxes, link them together and then add the Texture Plug in and the Test Script to it. Set the names of each prim to match the names of your textures that you saved in the texture server. Touch the prim, and it should change textures on each prim. You should see the hover text above the server prim change, as it reports the progress, and the textures should appear on your set of boxes.
The number it sends ranges from 0 to 1.0, randomly. If you have two textures in the server, it will respond with the first texture of the number is less than 0.5 and the second if it is greater than 0.5.
Server does not connect to the proxy or chats an error:
Check that your UUID is in the proper format. It must be a unique UUID.
My pet does not change colors but the server is responding:
Check that you have at least one non-root prim named 'something', and at least one texture named 'something 0', where 'something' is any name. There should be no spaces on the texture name except between the name and the number. There is a space between the 'something' and the '0' in the texture name. You can use any name for the 'something', and there must be at least one prim named 'something'.
Some textures are mixed up, I get the wrong head and the correct body:
Be sure you have the same number of textures in each texture set. If you have a body 0 texture and a body 1 texture, you must also have a head 0 and a head 1 texture. The numbers are breeds: 0 is the first breed, 1, the second, and so on. The names represent where the textures go.
What are the chances of getting texture XXX?
The rarest textures are the ones next to the first and last texture. First generation pets always have either a 0 or a 1 when they are first rezzed, so the server sends the first or last texture in the server. Generation 1 will be slightly below or slightly above the number 0.5, so the texture will be the one either directly below, or just above the middle of the texture list. There is a 50/50 chance it will be above or below 1/2, and it will vary by +/- 5%. If you have 3 textures, it will be the middle one, if you have four textures, it may be the second or the third, because there is no exact middle texture. The next Generation 2 will be somewhere near the 0.25 or 0.75 mark. If you had 100 textures in the server, Gen 3 will probably end up with near the 25 or 75th texture, give or take about 5%.
This means that you can do a nice trick: Copy a texture multiple times but change the number so that the texture is used many times in different generation numbers, making them very common. If there were 100 textures in the prim and 90 of them were and identical, then the remaining 10 textures, if scattered around, would be rare breeds. You can always go back and delete some of the common ones and add new textures whenever you want.
Back to the Best Free Tools in Second Life and OpenSim.