SRL Archive - OSR Help

Repeat X Amount Of Times


Deathjoker

2011-01-27 15:24:39

Im trying to get my script to repeat a certain amount of times using
number as a integer
then number is number + 1
then im trying to make the number equal count
then when im using it have easy access to the count, but thats where i get confused. ultimatly im trying to make my script repeat "x" amount of times.


Program New;

Var
Number:Integer;


Const
Attack = 75000; //How Long You Attack Before Moving
T = 1000; //Amount Of MS Before Repeating Script
Move = 104; // Direction One
Moveback = 98; //Direction Two
Count = 100
Number = Number+1;
//Key Codes
//Control 17
//Left 100
//Right 102
//Up 104
//Down 98

Procedure Findwindow;
Begin
Findwindowtitlepart('My Window', False)
Activateclient;
End;


Procedure Kill;
Begin
KeyDown(17);
Wait(Attack)
Keyup(17);
Wait(300)
End;

Procedure Walk;
Begin
Keydown(Move);
Wait(500)
Keyup(Move);
Wait(100)
End;

Procedure Walkback;
Begin
Keydown(Moveback);
Wait(300)
Keyup(Moveback);
Wait(T+(50))
End;

Begin
Findwindow;
Repeat
Kill;
Walk;
Walkback;
Until(Number=Count)
End.

Nava2

2011-01-27 15:27:29

Make number = 0; then increment Number in your loop. Number has to be a Variable, remember.

zeeky111

2011-01-27 16:08:26


Program New;

Var
Number:Integer;


Const
Attack = 75000; //How Long You Attack Before Moving
T = 1000; //Amount Of MS Before Repeating Script
Move = 104; // Direction One
Moveback = 98; //Direction Two
Count = 100
//Key Codes
//Control 17
//Left 100
//Right 102
//Up 104
//Down 98

Procedure Findwindow;
Begin
Findwindowtitlepart('My Window', False)
Activateclient;
End;


Procedure Kill;
Begin
KeyDown(17);
Wait(Attack)
Keyup(17);
Wait(300)
End;

Procedure Walk;
Begin
Keydown(Move);
Wait(500)
Keyup(Move);
Wait(100)
End;

Procedure Walkback;
Begin
Keydown(Moveback);
Wait(300)
Keyup(Moveback);
Wait(T+(50))
End;

Begin
Number := 0;
Findwindow;
Repeat
Kill;
Walk;
Walkback;
Number := (Number + 1);
Until(Number=Count)
End.
^What I would do.
I might be wrong. Can I get a check on that? :P
Also, there are some basic format things that bug me about it, such as the spacing, the indentation, and the lack of double-caps. :P. But otherwise it's a pretty solid idea.

EDIT: Notice the main loop. I took out the "Number" GlobConst and added in
Begin
Number := 0; //THIS.
Findwindow;
Repeat
Kill;
Walk;
Walkback;
Number := (Number + 1); //AND THIS.
Until(Number=Count)
End.

cycrosism

2011-01-28 01:14:58

From: zeeky111

Program New;

Var
Number:Integer;


Const
Attack = 75000; //How Long You Attack Before Moving
T = 1000; //Amount Of MS Before Repeating Script
Move = 104; // Direction One
Moveback = 98; //Direction Two
Count = 100
//Key Codes
//Control 17
//Left 100
//Right 102
//Up 104
//Down 98

Procedure Findwindow;
Begin
Findwindowtitlepart('My Window', False)
Activateclient;
End;


Procedure Kill;
Begin
KeyDown(17);
Wait(Attack)
Keyup(17);
Wait(300)
End;

Procedure Walk;
Begin
Keydown(Move);
Wait(500)
Keyup(Move);
Wait(100)
End;

Procedure Walkback;
Begin
Keydown(Moveback);
Wait(300)
Keyup(Moveback);
Wait(T+(50))
End;

Begin
Number := 0;
Findwindow;
Repeat
Kill;
Walk;
Walkback;
Number := (Number + 1);
Until(Number=Count)
End.
^What I would do.
I might be wrong. Can I get a check on that? :P
Also, there are some basic format things that bug me about it, such as the spacing, the indentation, and the lack of double-caps. :P. But otherwise it's a pretty solid idea.

EDIT: Notice the main loop. I took out the "Number" GlobConst and added in
Begin
Number := 0; //THIS.
Findwindow;
Repeat
Kill;
Walk;
Walkback;
Number := (Number + 1); //AND THIS.
Until(Number=Count)
End.


You don't need to make it Number := (Number + 1); Making it Number := Number + 1; (without brackets) works fine and looks neater

Shady?

2011-01-28 02:06:38

You could also make it
Inc(Number);

Flight

2011-01-28 03:39:38

Hell Shady beat me to the punch.

Begin
Number := 0;
Findwindow;
Repeat
Kill;
Walk;
Walkback;
Inc(Number);
Until(Number=Count)
End.
Although I think when 'Number' is declared as a variable, it's already set to 0, but I may be wrong, it may actually be -1, I don't know what value Scar sets integers to automatically when they're declared.

KingKong

2011-01-28 07:39:41

By default they're all(integers i mean) set to 0.

Flight

2011-01-28 10:12:26

I'm so used to Java where newly declared integers are -1 as opposed to arrays starting at 0, which is a big part of why private servers in the beginning had so many errors and glitches that no one seemed to be able to figure out, maybe some of you know what I'm talking about. ;)

Method

2011-01-28 13:03:11

From: Flight
I'm so used to Java where newly declared integers are -1 as opposed to arrays starting at 0, which is a big part of why private servers in the beginning had so many errors and glitches that no one seemed to be able to figure out, maybe some of you know what I'm talking about. ;)


The default value for integers is 0, not -1.