Author Topic: How to make this script?  (Read 6429 times)

Ok I tweaked my code so its only 1 variable. Is this correct? (Note this is only PART of the code)
Code: [Select]
//Hero
$var = 1;
AvatarGui.Clickfav(1);
Avatar_done();

//Renderman
$var++;
AvatarGui.Clickfav(1);
Avatar_done();

//creepBear
$var++;
AvatarGui.Clickfav(1);
Avatar_done();

if($var > 3)
{
    $var = 1;
}

Ok I tweaked my code so its only 1 variable. Is this correct? (Note this is only PART of the code)
Code: [Select]
//Hero
$var = 1;
AvatarGui.Clickfav(1);
Avatar_done();

//Renderman
$var++;
AvatarGui.Clickfav(1);
Avatar_done();

//creepBear
$var++;
AvatarGui.Clickfav(1);
Avatar_done();

if($var > 3)
{
    $var = 1;
}

Well you're always doing ClickFav(1);, try doing ClickFav($var); And with this setup you're setting the var to one, then two, then three. You don't want that, you want it to go up one every time it's called. So only have one $var++; and don't set it at the beginning. You also forgot to put it in a function, like this format:
Here's a basic logic:

function avatarCycle
   increment variable
   set variable to zero if > 3
   set avatar favorite to variable
   schedule next function call
end


Just replace each line with the proper way to do what that line does

Here's a basic logic:

function avatarCycle
   increment variable
   set variable to zero if > 3
   set avatar favorite to variable
   schedule next function call
end


Just replace each line with the proper way to do what that line does
Alright I just need to do this but I don't know how to convert most of those words into a code kind of languange. Heres what I came up with anyway,
Code: [Select]
function avatarCycle(%cilent)
{
increment variable
set $var to 0 if > 3
set $var to variable
schedule next function call
}
Correct me if i'm wrong with one of the lines.
Well you're always doing ClickFav(1);, try doing ClickFav($var); And with this setup you're setting the var to one, then two, then three. You don't want that, you want it to go up one every time it's called. So only have one $var++; and don't set it at the beginning.
I see, so what should I put here (at the ???)?
Code: [Select]
//Hero
$var = 1;
AvatarGui.Clickfav($var);
Avatar_done();

//Renderman
$var++;
AvatarGui.Clickfav($var);
Avatar_done();

//creepBear
???
AvatarGui.Clickfav($var);
Avatar_done();

You're still trying to do one for each avatar, it cycles through them by adding one. So if Hero is avatar fav 1 when you do ClickFav($var); $var will be 1, then when $var is 2, you get fav 2.
Code: [Select]
function AvatarCycle()
{
   $**r++;
   if($**r>3)
      $**r=1;
   A******ui.*******v($**r);
   A*****_***e();
   s******e(5000,0,A**********);
}

Like so, just change all the *'s to what you believe they should be.

Also, don't use a global variable, use a local variable and pass it through as a function argument: function functionName(%avatar) and schedule(time,0,functionName,%avatar);
All the code you need to replace with the logic lines I gave you, you've already done yourself in your previous attempts
« Last Edit: July 16, 2014, 09:02:28 PM by Headcrab Zombie »

Thanks for being patient and keep telling me the right thing to do guys :D! I'm very sorry if I kept confusing you guys. Here is the final code
Code: [Select]
//Hero
$var = 1;
AvatarGui.Clickfav($var);
Avatar_done();

//Renderman
$var++;
AvatarGui.Clickfav($var);
Avatar_done();

//creepBear
???
AvatarGui.Clickfav($var);
Avatar_done();

function AvatarCycle(%cilent)
{
   $var++;
   if($var > 3)
      $var = 1;
   AvatarGui.Clickfav($var);
   Avatar_done();
   schedule(5000, 0, AvatarCycle);
}
Only problem now is I don't know what to put in ??? (Under //creepbear) and Thorfin25 had said that I should only have one "$var++;" so I don't know what to put there now :(.
« Last Edit: July 16, 2014, 09:07:07 PM by Naked Human »

Everything before the function shouldn't be there.

1. This:
Everything before the function shouldn't be there.

2. You don't need %client as this is a pure clientside script

3.
Don't use a global variable, use a local variable and pass it through as a function argument: function functionName(%avatar) and schedule(time,0,functionName,%avatar);

And then you'll be good

Everything before the function shouldn't be there.

So it should just be
Code: [Select]
function AvatarCycle(%avatar)
{
   $var++;
   if($var > 3)
      $var = 1;
   AvatarGui.Clickfav($var);
   Avatar_done();
   schedule(5000, 0, AvatarCycle);
}
?

Yup. The %avatar is unneeded in what you've scripted, but that'll work none the less. What you should do is change the $var to %avatar, and change the schedule to schedule(5000,0,AvatarCycle,%avatar);
« Last Edit: July 16, 2014, 09:15:02 PM by Thorfin25 »

No
Change all the $var references, and add a %avatar reference in the schedule

The %avatar is unneeded
no
STOP


In what he scripted there, read the whole thing :L
%avatar in the function name is COMPLETELY NEEDED if he does what im trying to get him to do, and what you editted in to tell him to do

I edited in the 2nd sentence.

You guys forgot to set schedule to a variable so the loop can be exited with the cancel function. It seems like something that'd be nice to stop every once in a while.