Help with a counting script

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Help with a counting script

Post by Nico » Fri Jul 11, 2008 8:47 pm

Okay, so im kinda stuck with this, i have a script with i want to add a value everytime it goes trough a loop, then when the values equals the number set in the dialog, it will go to another label.. Okay so here is a piece of my script. I hope anyone can help my out as this really bothers me.

I marked the counting part with a red color so you don't get too confused with this

Label>solobot3
Let>Count=0
wait>2
mousemove>380,153
wait>1
lclick
wait>2
press enter
wait>0.1
press enter
waitpixelcolor>0,620,748,2
IF>{%WPC_RESULT%=False}
goto>solobot3
endif
Wait>%dialog1.Delay1%
press enter
Send>%dialog1.msEdit4%
press enter
wait>%dialog1.Delay2%
press enter
send>%dialog1.msEdit5%
press enter
wait>%dialog1.Delay3%
press enter
send>%dialog1.msEdit6%
press enter
wait>1
press F10
wait>1
send>%dialog1.msEdit2%
wait>1
send>%dialog1.msEdit3%
wait>3
press enter
wait>1
mousemove>100,100
waitpixelcolor>3735552,720,716,0
IF>{%WPC_RESULT%=True}
If>dialog1.msCheckBox1=True,comp

Srt>comp
add>Count,1
If>Count=%dialog1.msEdit10%
goto>ShutDown
end>comp


endif
goto>solobot3
endif
label>end

Label>ShutDown
press alt
send>x
wait>3
send>q
release alt
label>end


Okay, so my problem is that if the checkbox ISN'T checked, it doesn't go to: Label>Solobot3

Also if i run the loop 3 times with the number 3 in the editbox the bot doesn't go to: Label>ShutDown

Any help would be greatly apreciated! ;)

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Sun Jul 13, 2008 4:19 pm

Sorry that im impatient, but can anyone help me with this? :/

User avatar
pgriffin
Automation Wizard
Posts: 460
Joined: Wed Apr 06, 2005 5:56 pm
Location: US and Europe

Post by pgriffin » Mon Jul 14, 2008 4:37 am

If you want your code to go to a specific label when it is NOT checked, then just tell it to do so.

IF>SomeStatement=True
goto>DoTrueLabel
else
goto>DoFalseLabel
endif

Your code is not easy to follow and it is not clear what you are trying to do.

Also, if you want to do something while incrementing a counter, you should use Repeat> Until> loops to do so....there are plenty of examples in the help file as well as here on the forum.

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Mon Jul 14, 2008 7:08 pm

Okay so here is my dialog box:

Image

IF the box at the bottom is checked, the script will run as many times as shown in the edit box, when it hits the number, it jumps to another label called shutdown. (it will shutdown the game when the number is reached)

I took a look on the repeat> function, but it seems like it only works with numbers, and not entire loops?

So its very simple, the number in the box is the number the loop has to continue until it jumps to another label...

I just don't know how to code it, :(

Nico
Newbie
Posts: 19
Joined: Tue Jul 08, 2008 3:15 pm

Post by Nico » Wed Jul 16, 2008 7:42 pm

sorry for bumping, but.. any help?

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jul 16, 2008 7:55 pm

Every time you return to Label>solobot3, the first thing the script does is set variable "Count" back to zero. Therefore you will never increment past 1. Move the Let>Count=0 line up to the top of your script so that it only executes once. Other than that and an extra endif I don't see why your code would fail to increment. Of course I can't test your mousemoves and pixel colors nor do I know whether you are calling the correct dialog object names. I rearranged things a little and added indenting for clarity.

Code: Select all

  Let>Count=0

Label>solobot3
  wait>2
  mousemove>380,153
  wait>1
  lclick
  wait>2
  press enter
  wait>0.1
  press enter
  waitpixelcolor>0,620,748,2
  IF>{%WPC_RESULT%=False}
    goto>solobot3
  endif
  Wait>%dialog1.Delay1%
  press enter
  Send>%dialog1.msEdit4%
  press enter
  wait>%dialog1.Delay2%
  press enter
  send>%dialog1.msEdit5%
  press enter
  wait>%dialog1.Delay3%
  press enter
  send>%dialog1.msEdit6%
  press enter
  wait>1
  press F10
  wait>1
  send>%dialog1.msEdit2%
  wait>1
  send>%dialog1.msEdit3%
  wait>3
  press enter
  wait>1
  mousemove>100,100
  waitpixelcolor>3735552,720,716,0
  IF>{%WPC_RESULT%=True}
    If>dialog1.msCheckBox1=True,comp
  endif
  goto>solobot3

Label>ShutDown
  press alt
  send>x
  wait>3
  send>q
  release alt

label>end


Srt>comp
  add>Count,1
  If>Count=%dialog1.msEdit10%
  goto>ShutDown
end>comp
Also, might be beneficial for you to read this post on using the debugger.

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