Help with setSkinName
by Will Burgers · in Technical Issues · 08/03/2005 (9:30 am) · 37 replies
I am not exactly clear on how setSkinName() works. I need to be able to select the texture to use for the player model. At the moment in the GameConnection:createPlayer function I am attempting to set the player's skin with the following line:
%player.setSkinName("TEX0");
and it appears to work in that %player.getSkinName returns "TEX0" afterward, however the texture is unchanged. I am a bit hazy on the naming convention for this system as well. I've tried naming it TEX0.png, TEX0.PLAYER.png, and a few others, but none seem to work. It'd be great if someone could shed some light on this for me.
Thanks,
Will Burgers
%player.setSkinName("TEX0");
and it appears to work in that %player.getSkinName returns "TEX0" afterward, however the texture is unchanged. I am a bit hazy on the naming convention for this system as well. I've tried naming it TEX0.png, TEX0.PLAYER.png, and a few others, but none seem to work. It'd be great if someone could shed some light on this for me.
Thanks,
Will Burgers
#2
Is there anyway I can find exactly what texture the model is looking for, and the path? I have a texture in the same directory called tex0.player.png, and %player.getSkinName(); returns tex0. However the texture is not being loaded, which makes me think perhaps the engine isn't calling it 'player' but something else...
Does anyone know of a way I can get it to echo the exact path it's looking for?
Thanks,
Will
08/03/2005 (10:26 am)
It should, but it doesn't.Is there anyway I can find exactly what texture the model is looking for, and the path? I have a texture in the same directory called tex0.player.png, and %player.getSkinName(); returns tex0. However the texture is not being loaded, which makes me think perhaps the engine isn't calling it 'player' but something else...
Does anyone know of a way I can get it to echo the exact path it's looking for?
Thanks,
Will
#3
Would seem to me that the most logical place would be the onAdd() fucntion.
Also, did you notice the absence of quotes in Matts example?
08/03/2005 (10:35 am)
Will, where are you trying to do this/Would seem to me that the most logical place would be the onAdd() fucntion.
Also, did you notice the absence of quotes in Matts example?
#4
At the moment I am setting it in "createPlayer" as I mentioned above.
I have also tried changing it manually during gameplay in the console.
Is there something I must do in 3DS Max to set up the player/texture to be changed? Leave it textureless, or name it something special?
Thanks,
Will
08/03/2005 (10:45 am)
Yes, the quotes are no matter - the name is changed to "tex0" whether the quotes are there or not.At the moment I am setting it in "createPlayer" as I mentioned above.
I have also tried changing it manually during gameplay in the console.
Is there something I must do in 3DS Max to set up the player/texture to be changed? Leave it textureless, or name it something special?
Thanks,
Will
#5
08/03/2005 (10:52 am)
When you export, the texture assigned to the model should be named base.something.png (or .jpg).
#6
08/03/2005 (10:55 am)
In 3DS Max I think you need to set up the player/texture to base.player.png. I had to do that in milkshape.
#7
08/03/2005 (10:56 am)
They're right, just skimmed through resources and came to the same conclusion
#8
Cheers,
Will
08/03/2005 (1:50 pm)
Ah yes, that was it. I changed the texture in Max to base.[charactername].png and now it works fine. Thanks!Cheers,
Will
#9
What's strange is I couldn't find this thread via the advanced search here on garagegames. I found it via google.
Thanks a bunch!
09/03/2005 (8:38 pm)
Thanks guys... I have been tearing my out what little hair I have left trying to figure this naming convention out. What's strange is I couldn't find this thread via the advanced search here on garagegames. I found it via google.
Thanks a bunch!
#10
I'm having a similar issue. I'm trying to get my objects to change skins when shot for a puzzle game, they would cycle through. However, I'm at a loss at how to the the code structured.
Right now I've got this:
function brick::damage(%this, %obj, %sourceObject, %position, %damage, %damageType){
%obj.getSkinName(skinName);
if(%obj.skinName = "base")
%obj.setSkinName("red");
else if(%obj.skinName = "red")
%obj.setSkinName("blue");
else if(%obj.skinName = "blue")
%obj.setSkinName("yellow");
else if(%obj.skinName = "yellow")
%obj.setSkinName("red");
}
Of course it doesn't work or I wouldn't be asking about it. Can somebody give me a hint?
Thanks,
Nate
05/24/2006 (7:18 am)
Hello all,I'm having a similar issue. I'm trying to get my objects to change skins when shot for a puzzle game, they would cycle through. However, I'm at a loss at how to the the code structured.
Right now I've got this:
function brick::damage(%this, %obj, %sourceObject, %position, %damage, %damageType){
%obj.getSkinName(skinName);
if(%obj.skinName = "base")
%obj.setSkinName("red");
else if(%obj.skinName = "red")
%obj.setSkinName("blue");
else if(%obj.skinName = "blue")
%obj.setSkinName("yellow");
else if(%obj.skinName = "yellow")
%obj.setSkinName("red");
}
Of course it doesn't work or I wouldn't be asking about it. Can somebody give me a hint?
Thanks,
Nate
#11
05/24/2006 (8:34 pm)
Try this.function brick::damage(%this, %obj, %sourceObject, %position, %damage, %damageType){
%curSkin = %obj.getSkinName();
if(%curSkin $= "base")
%obj.setSkinName("red");
else if(%curSkin $= "red")
%obj.setSkinName("blue");
else if(%curSkin $= "blue")
%obj.setSkinName("yellow");
else if(%curSkin $= "yellow")
%obj.setSkinName("red");
}You can't pass values by reference in script, and there is no real OO setup either (you will always have to explicitly reference member variables of an object with the obj.variable format). Also you need to use the $= or !$= operators for string comparisons.
#12
%curSkin = %obj.getSkinName();
if(%curSkin $= "base")
%obj.setSkinName("red");
else if(%curSkin $= "red")
%obj.setSkinName("blue");
else if(%curSkin $= "blue")
%obj.setSkinName("yellow");
else if(%curSkin $= "yellow")
%obj.setSkinName("red");
else if(%curSkin !$= "yellow")
%obj.setSkinName("red");
Then it would work, and it does. Does that make sense to you?
n8
05/25/2006 (12:05 am)
Wow, you're really close for just firing it out there. Kudos! So, here's what happened: Nothing at first. But then I read your comments about needing "to use the $= or !$= operators for string comparisons", so I started experimenting with putting in some ! here and there. The best result I found is that by putting !$= "yellow" it will cycle all the way through, but stop on yellow. So, it occured to me that if I did this:%curSkin = %obj.getSkinName();
if(%curSkin $= "base")
%obj.setSkinName("red");
else if(%curSkin $= "red")
%obj.setSkinName("blue");
else if(%curSkin $= "blue")
%obj.setSkinName("yellow");
else if(%curSkin $= "yellow")
%obj.setSkinName("red");
else if(%curSkin !$= "yellow")
%obj.setSkinName("red");
Then it would work, and it does. Does that make sense to you?
n8
#13
I would like to change the orc skin when the player connect to the game. In my ~/data/player/orc/ folder I have to skin "player.png" and "a.player.png".
I wrote these lines :
%ok=%player.getSkinName();
echo("----------------------------test before------------------"@%ok);
%skin= "a";
%player.setSkinName(%skin);
%ok=%player.getSkinName();
echo("----------------------------test after------------------"@%ok);
and here is the result :
----------------------------test before------------------
----------------------------test after------------------a
So, why the result of %player.getSkinName is "" and why it doesn't work (the second texture is not applied to my orc model) ?
Could someone help me ?
06/05/2006 (6:14 am)
Hello, I have a similar problem : I would like to change the orc skin when the player connect to the game. In my ~/data/player/orc/ folder I have to skin "player.png" and "a.player.png".
I wrote these lines :
%ok=%player.getSkinName();
echo("----------------------------test before------------------"@%ok);
%skin= "a";
%player.setSkinName(%skin);
%ok=%player.getSkinName();
echo("----------------------------test after------------------"@%ok);
and here is the result :
----------------------------test before------------------
----------------------------test after------------------a
So, why the result of %player.getSkinName is "" and why it doesn't work (the second texture is not applied to my orc model) ?
Could someone help me ?
#14
The reason is that you have to skin the character with "base.player.png". You might have to re-export it with your 3D software to get it to take, I had to using Maya (at least it solved my problem).
You can see my code above where my first getSkin is: if(%curSkin $= "base")
n8
06/05/2006 (8:21 am)
I think I can actually answer a question for once!The reason is that you have to skin the character with "base.player.png". You might have to re-export it with your 3D software to get it to take, I had to using Maya (at least it solved my problem).
You can see my code above where my first getSkin is: if(%curSkin $= "base")
n8
#16
now replace player with base.p and you should be set. To change to the skin you want use the code
Hope thats helped anyone who doesnt have access to an exporter!
06/21/2006 (3:10 pm)
Sorry to bring up an old post here but there is another way around re exporting a model. First you need a HEX editor. Personally i use this one (since its free!). If the texture name of the file you want to texture is called for example: player.png, you can rename this base.p.PNG, (just make sure the base texture has the same number of characters in its name, the reason will become clear in a minute). Now open up the DTS you want to reskin using the HEX editor. Scroll right to the bottom and in the bottom right corner you should see some text like:......playerC.. .....someother weird symbols...
now replace player with base.p and you should be set. To change to the skin you want use the code
%player.setSkinName('red'); (justusing red as an example but if it were a file it would be called red.p). Notice how i used 'red' instead of "red". Also notice how red has a different character length to base. It doesnt matter how many characters are in the changed to skin name only in the original.Hope thats helped anyone who doesnt have access to an exporter!
#17
06/21/2006 (10:42 pm)
Hey, good resource, thanks!
#18
06/23/2006 (2:32 pm)
Thanks, I was given that link by a friend a while back and since then its been invaluable! Incase anyone doesnt know, a HEX editor can be used to veiw any kind of file in binary format ( I think). It just so happens that in .DTS files the texture name is in the bottom right of the file. Its different for .dif shapes but the textures could still be changed you would just have to search for them in the HEX editor.
#19
05/06/2007 (6:07 pm)
Thanks for the hex editor tip, that is awesome. I found though that the new name had to be the same length as the original, or the engine(1.5) crashes. I was using it on the default blue guy, which looked for texture player_blue, so I changed it to base.player which is the same length. I was able to swap the skin with the setSkinName method.
#20
e.g: if the text you see as the texture name is base.item.jpg you'll see that there's a 0D right before the first b. If you change it to base.red.jpg you just need to change that 0D to 0C and you're set
06/26/2007 (1:15 pm)
Uhm.. the value right before the name is it's lenght, so you can change the byte right before it so it matches, and voilae.g: if the text you see as the texture name is base.item.jpg you'll see that there's a 0D right before the first b. If you change it to base.red.jpg you just need to change that 0D to 0C and you're set
Torque 3D Owner Matthew Langley
Torque
and
%player.setSkinName(tex0);
should work, I think ?