SRL Archive - OSR Help

While Do Loop Question


YoHoJo

2011-11-17 19:36:54

Let's say you got

While Ugly Do
Begin
Shower;
Shave;
Makeup;
//Let's say you turn pretty here (Ugly=False)
DressSkanky;
End;

Once Ugly=False would the loop stop?
Or would it complete the ENTIRE loop (as in DessSkanky) before stopping even if you turned pretty in the middle of the loop?

Method

2011-11-17 19:40:29

The condition is only checked at the top of the loop (i.e. before each iteration). In your example, DressSkanky would be executed before the program exited that loop.

YoHoJo

2011-11-17 19:45:57

Damn.
Check this out here Method:
http://villavu.com/forum/showthread.php?p=845935#post845935

Since it doesn't work well in SMART I want to do something like

While Not GameTab=25 Do
Begin
KeyDown(VK_F1);
Wait(100 + Random(100));
KeyUp(VK_F1);
Wait(1000+Random(500));
End;

Problem being, I don't want that extra wait right there to happen IF we are in the correct gametab. I like my script to be fast and optimized.
I guess before the wait I could just put If GameTab=25 Then Break and that would work fine?

Get me? Any better way or is this just fine?

HyperSecret

2011-11-17 19:47:52

Since when was there a wile loop?

(I felt like trolololol'ing)

YoHoJo

2011-11-17 20:08:33

Answer my latest post ^?

Yago

2011-11-17 20:20:43

From: YoHoJo
Answer my latest post ^?


if not ugly then break…

Grief Seeds

2011-11-17 20:22:45

I don't know this language but will look at it soon, but there must be some sort of Break statement. Do While loops executes the code first then it checks the condition/

YoHoJo

2011-11-17 20:28:03

Thanks buddy, yeah I have it break in the middle of the code in my condition is satisfied.

TomTuff

2011-11-17 21:16:14





function FKeyGameTab(Tab: Integer): Boolean;
var
T, Key: Integer;
begin
case Tab of
tab_Inv: Key := VK_F1;
tab_Equip: Key := VK_F2;
tab_Prayer: Key := VK_F3;
tab_Magic: Key := VK_F4;
tab_Equip: Key := VK_F5;
else
begin
srl_Warn('FKeyGameTab', 'tab was not valid to fkey to. Using gametab instead.', warn_AllVersions);
Result := GameTab(Tab);
Exit;
end;
end;
T := GetSystemTime + 3000;
KeyDown(Key);
while not(Result) and (T <= GetSystemTime) do
begin
Wait(100 + Random(50));
Result := (GetCurrentTab = Tab);
end;
KeyUp(Key);
Wait(100 + Random(50));
end;
I've used this :)

YoHoJo

2011-11-17 21:23:24

Is that in SRL already, or did someone just whip that up?
Does it work with SMART properly? I think yes because the while do. Cool thanks.

TomTuff

2011-11-17 23:58:02

From: YoHoJo
Is that in SRL already, or did someone just whip that up?
Does it work with SMART properly? I think yes because the while do. Cool thanks.


Me.

DeSnob

2011-11-20 12:09:58

From: TomTuff
Me.


Make a post in the SRL Additions forum, I'm sure it would be accepted. :)

Coh3n

2011-11-20 15:00:55

Looks neat, if it works in both SMART and the browser (which I'm assuming it does) I'd love to add it to SRL.

Nava2

2011-11-20 17:05:34

I think its already in SRL.. >.>

Yago

2011-11-20 17:21:57

From: Nava2
I think its already in SRL.. >.>


I couldn't find it(fkey-tab function thing)…

TomTuff

2011-11-20 17:28:59

It shouldn't be because I wrote it :p

weequ

2011-11-20 17:49:36

From: TomTuff
It shouldn't be because I wrote it :p

Your version presses presses fkey and waits until you are in the correct gametab and then releases the key. Wouldn't it be more human-like to pres it, release it and then wait until you are in the correct gametab.

I personally never hold the key until the correct gametab. I just press it quickly and wait for it to open.

Also your version would press the key even when you already are in the correct gametab.

YoHoJo

2011-11-20 17:54:45

^Agree with Annti.
<3 You though Tom, thanks for the idea!

Annti, the one I ended up writing basically does that (no fail safe for if that tab is (for some off reason) never reached though, but it waits 500+Random(500) after each press before pressing again.

Begin
While (Not(GetCurrentTab=25)) Do
Begin
KeyDown(VK_F1);
Wait(100 + Random(100));
KeyUp(VK_F1);
If GetCurrentTab=25 Then Break;
Wait(500+Random(500));
End;
End;