;Load both of the meshes for the clothing
Global headpiece1 = LoadMesh("TheFirstHeadPieceHere.b3d")
Global headpiece2 = LoadMesh("TheSecondHeadPieceHere.b3d")
;Hide the second head piece for now
HideEntity headpiece2
;Set up a variable to switch through multiple clothing sets
Global headpieceindex = 1
;And another variable for your maximum headpiece count
Global maxheadpiece = 2 ;Change this number to match the number of headpieces you have
;After your character is loaded, attach it to the 'head' bone as you did in the previous thread
While Not KeyDown(1) ;main loop here
;do all of your game stuff here
;call the function below
UpdateCharacterClothing()
Wend ;End the main loop
;In your functions list, include this:
Function UpdateCharacterClothing()
If KeyDown(LEFTKEY) ;I can't remember the Scancode value for the left key
headpieceindex = headpieceindex - 1 ;Move Index Pointer Left
EndIf
If KeyDown(RIGHTKEY) ;I can't remember the Scancode value for the right key
headpieceindex = headpieceindex + 1 ;Move Index Pointer Right
EndIf
If headpieceindex <= 0
headpieceindex = 0 ;Don't let the pointer fall below 0
EndIf
If headpieceindex >= maxheadpiece
headpieceindex = maxheadpiece ;Don't let the pointer go above the maximum
Endif
If headpieceindex = 1
ShowEntity headpiece1 ;Put on the headpiece1
Else ;If the headpieceindex is NOT equal to 1
HideEntity headpiece1 ;Take off the headpiece1
EndIf
If headpieceindex = 2
ShowEntity headpiece2 ;Put on the headpiece2
Else ;If the headpieceindex is NOT equal to 2
HideEntity headpiece2 ;Take off the headpiece2
EndIf
;Repeat the 'if' statements above as needed for every headpiece
;Note that the code above will take off ALL headpieces if headpieceindex = 0
End Function
Here's one way I just thought of. It may be a lot easier to use types if you have a lot of headpieces. That, or else you could call another function for all of those repeating 'if' statements and pass on the numbers through it to check as arguments.
I'll also have you know that this is probably the first time I've ever used the 'Else' statement, since I can remember that you're especially fond of that command. Due to the fact that I'm so new to that command, it may not work perfectly, but this was more or less to demonstrate concept.
Let me know if it doesn't make sense.
|