I assume you want a clientsided script that does something like this:
->
->
So, first off what you're gonna want to do is set each one of these as a favorite at the top of the window. This makes this mod immensely easier to make, and it makes it more modular because if you decide later that you want to change one of them, or add one, it's just as easy as overwriting that favorite.
Second, you need to figure out how to apply a favorite. To do this, you're going to use the
trace() function. The
trace() function prints out
every single function that's called into your console. So you want to be quick when you do this, otherwise your console might get spammed by other stuff going on and you'll lose it. So what you're gonna do is have your Player Appearance window open, then open console. Type
trace(1); into console. Quickly close console, press one of the non-greyed out favorites buttons, then open console again. When you open console, type in
trace(0);.
You should find something in there that looks like
AvatarGui::C******v(AvatarGui, x). I starred out the name so that you can do it yourself, and
x is going to be whatever number you clicked on. The next thing you need to do is figure out is the function that applies this appearance to your player in game when you click the
Done button. So you're going to run a trace again, the exact same way, with
trace(1); and
trace(0); but you're going to click Done this time instead of one of the favorites buttons.
This function looks a little different, it looks something like
A*****_***e().
I recommend using a
Global Variable to store the favorite number for the current look you're using. So define a start point at the top of your script, something like
$CurrentFavorite = 1; that comes before you have any functions.
Then make a function that calls
AvatarGui.C******v($CurrentFavorite);. You can also call this function like it looks in the trace with AvatarGui:: before the function name and AvatarGui as the first parameter, but it's shorter this way.
Then call
A*****_***e(); to apply this look to your player.
Next step, you need to increase the value of
$CurrentFavorite. You can do this a couple of ways,
$CurrentFavorite = $CurrentFavorite + 1; or
$CurrentFavorite += 1; are the two easiest to understand. There's a shorthand for increasing a variable built into most languages (Torque included) that allows you to just do
$CurrentFavorite++;. There's one more thing you have to do with this variable though, you want to reset it once it's bigger than 3 so that it goes back to 1.
if($CurrentFavorite > 3)
{
$CurrentFavorite = 1;
}
Now you've only got one step left. You need to make it so that this function will automatically be called again in five seconds. To do this we have a special function called
schedule() that calls a function after a delay. Convenient! This function returns a number associated with the schedule created, so we want to store this in a different global variable so that we can use the
cancel() function on it if you ever want to stop being a renderpiratehead.
So, the way you use schedule is with a couple of arguments: delay and function to call. There's a third argument that comes second, but wonderfully enough
it doesn't even work so we just set it to zero. So, for you, this call will look something like
$RenderPirateHeadSchedule = schedule(5 * 1000, 0, MyFunctionName);. The delay time is in milliseconds (one thousandth of a second) so we multiply five seconds by a thousand milliseconds to get 5000 milliseconds. In your function, you're probably just going to want to write 5000 instead of 5 * 1000, but I wanted to show you why it's 5000.
So that's pretty much it. You might want to make a second function that calls
cancel($RenderPirateHeadSchedule); so that you don't have to remember the name of that variable, but that's totally optional. To start morphing your avatar, just call the function you made for that and watch it go.
Note to other coders: recursive programming ftw? Hopefully it's not confusing to him.