Loop logic trouble

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
donttort
Newbie
Posts: 2
Joined: Wed May 12, 2010 10:04 pm

Loop logic trouble

Post by donttort » Wed May 12, 2010 10:10 pm

Below is a bot for a website i play, essentially my problem is that the if then statements disregard the actual limits I've given them.

No matter what the from or to numbers that i collect from my dialog box are the if then statements run.

They are only supposed to run when timesran is in between the from and two values.

The if then statements i am refering to look like this

Code: Select all

If>%timesran%>%oilfrom% and %timesran%<oilto>Selling Oil on base %timesran%
To my knowledge nothing is wrong :(

Code: Select all

MouseMove>90,1000
LClick
wait>1

Dialog>Dialog1
   Caption=Prompt
   Width=370
   Height=248
   Top=530
   Left=330
   Edit=bases,192,16,145,
   Label=How many bases do you have?,20,17,true
   Button=Start Script,192,176,145,25,1
   Edit=econfrom,192,103,57,0
   Edit=oilto,280,64,57,0
   Edit=barracksfrom,192,146,57,0
   Edit=econto,280,103,57,0
   Edit=oilfrom,192,64,57,0
   Edit=barracksto,280,146,57,0
   Label=Sell oil from:,66,60,true
   Label=Upgrade barracks from:,39,146,true
   Label=Upgrade economy from:,38,103,true
   Label=to,260,72,true
   Label=to,260,108,true
   Label=to,260,148,true
EndDialog>Dialog1

Show>Dialog1

Label>ActionLoop

    GetDialogAction>Dialog1,r
    If>r=1
        Goto>Prompt
    Else
        Goto>ActionLoop
    Endif

Label>Prompt

CloseDialog>Dialog1
    
Let>numberofbases=Dialog1.bases

Let>oilfrom=Dialog1.oilfrom
Let>oilto=Dialog1.oilto
Add>oilto,1

Let>econfrom=Dialog1.econfrom
Let>econto=Dialog1.econto
Add>econto,1

Let>barracksfrom=Dialog1.barracksfrom
Let>barracksto=Dialog1.barracksto
Add>barracksto,1

Let>timesran=0

Let>tabpresses=13
Let>tabcontrol=-1

Label>MainLoop
If>timesran<numberofbases>timesran,1

If>tabcontrol=0
Sub>tabpresses,1
Endif

//******************************************************

//Base Button
MouseMove>445,180
LClick
Wait>1

WaitPixelColor>6195658,20,118,0

//Base Selection
Wait>1
Press Tab * tabpresses
Wait>1
Press Enter
Wait>1

WaitPixelColor>6195658,20,118,0

//Oil
If>%timesran%>%oilfrom% and %timesran%<oilto>Selling Oil on base %timesran%
Endif

//Economy
If>%timesran%>%econfrom% and %timesran%<econto>upgrading economy on base %timesran%
Endif

//Barracks
If>%timesran%>%barracksfrom% and %timesran%<barracksto>upgrading barracks on base %timesran%
Endif
Add>tabcontrol,1
Add>tabpresses,1
Goto>MainLoop

Else
MessageModal>Script exited

Code: Select all



sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Wed May 12, 2010 10:33 pm

Your syntax for multiple conditions is incorrect.

Here is a simple example of multiple condition statements

Also note that when you are comparing text you need to put quotes around it. The second condition is an example of that.

Code: Select all

let>variable1=5
let>variable2=text
IF>{(%variable1% = 5) AND (%variable2% = "text")}
messagemodal>The conditions were met.
endif

donttort
Newbie
Posts: 2
Joined: Wed May 12, 2010 10:04 pm

Post by donttort » Thu May 13, 2010 3:15 am

oh cool thanks :D

sarver311
Pro Scripter
Posts: 84
Joined: Tue Jun 17, 2008 6:37 pm

Post by sarver311 » Thu May 13, 2010 5:42 am

Sure thing =)

I had a hard time with that syntax at first too but once you get an example it isn't to bad.

Good luck with it!

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts