AvatarCycle Help

Author Topic: AvatarCycle Help  (Read 700 times)

I was looking at the AvatarCycle script recently in attempt to learn a bit of scripting, but as usual, I failed.

Can anyone tell me what to change here to make it auto-cycle between avatar favorites and use the given key to only turn it on and off?

$avatarplace = -1;
$AvatarNum = -1;
function logavatarsaves() {
$AvatarNum = -1;
for(%i = -1; %i <= 9; %i++)
 Â if(isfile("base/config/client/AvatarFavorites/" @ %i @ ".cs"))
 Â   $AvatarList[$AvatarNum++] = %i;
}
logavatarsaves();
function cycleavatars(%val) {
if(%val) {
 Â $avatarplace++;
 Â if($avatarplace > $AvatarNum) $avatarplace = 0;
 Â exec("base/config/client/AvatarFavorites/" @ $AvatarList[$avatarplace] @ ".cs");
 Â clientcmdupdateprefs();
}
}

if (!$avatarcyclebind)
{
   $remapName[$remapCount] = "Cycle Saved Avatars";
   $remapCmd[$remapCount] = "cycleavatars";
   $remapCount++;
   $avatarcyclebind=true;
}
moveMap.bind(keyboard, "v", cycleavatars);

Looping it is easy, use schedules in the cycleavatars function to loop itself over.
Toggling that, however, is a little bit harder; have to use If/else logic & a variable to keep track of it.

I'd do it for ya but I'm on a Wii & typing is painful. :(

if (!$avatarcyclebind)
{
   $remapName[$remapCount] = "Cycle Saved Avatars";
   $remapCmd[$remapCount] = "cycleavatars";
   $remapCount++;
   $avatarcyclebind=true;
}
moveMap.bind(keyboard, "v", cycleavatars);

This means that Cycle Avatars is bound to 'V' every time you start the game, whether you set a bind or not. If you want a default keybind (only does it if one isn't set) then look at Team DM v4's GUI - auto binds to Ctrl M or leaves what you have set.

I understand the keybinding part, but what would have to change so it has an auto-cycle? Basically I'd just like it so you hit "V" to begin the avatar cycling, and hit "V" again to stop the cycling

Executing is a bad idea, you'll get console spam saying executing blah every time it executes.