fewtcher Posted June 9, 2015 Share Posted June 9, 2015 (edited) Hello, so I'm trying to make a script for one browser game but I am stuck because I don't know how to define the "repeat until" command. Here's my script: program FindItem;var x1, y1: Integer; begin wait(5000); repeat if FindColor(x1, y1, 8077125, 940, 375, 1000, 430) then begin WriteLn('found it') MoveMouse(x1, y1); ClickMouse(x1, y1, false); end else begin WriteLn('couldnt find it, trying again'); wait(500); MoveMouse(950, 325); ClickMouse(950, 325, false); wait(200); MoveMouse(1050, 325); ClickMouse(1050, 325, false); until WriteLn = (found it); end; end. So basically I want it to look like this: Repeat Action1 Action2 Until Action1 is complete/true (I don't know). If it still doesn't make sense here's an explanation - so the first action is the script searching for an item (color) in a small area of the screen. If it doesn't find it the second action is to refresh the window with the items (items change when their window is refreshed). I want the script to repeat itself until it finds the item (complete action 1). I hope that's a detailed enough explanation... I just don't know how to define the "Until" condition... PS: Ok found how to do it. I added a new integer and just changed the first action from clicking (I don't need it to click) to increasing the value of the integer to 1. So if the action is executed my integer will change it's value to 1 and the script will stop ^^ Also saw that I put "until" before the 1st "end" while I should've put it after it. program FindItem;var x1, y1: Integer; i: Integer; begin wait(500); repeat if FindColor(x1, y1, 8077125, 940, 375, 1000, 430) then begin WriteLn('found it') Inc(i); end else begin WriteLn('couldnt find it, trying again'); wait(500); MoveMouse(950, 325); ClickMouse(950, 325, false); wait(200); MoveMouse(1050, 325); ClickMouse(1050, 325, false); end; until i = 1; end. Edited June 9, 2015 by fewtcher Quote Link to comment Share on other sites More sharing options...
Creator Posted June 9, 2015 Share Posted June 9, 2015 Yes, you've solved it nicely Remember to format your code so that when it becomes larger it is easier to find faults and fix them. I also recommend you post with the tags... You can find them as a "#" in the toolbar when creating a Thread. Best of luck programming. [code]program FindItem; var x1, y1: Integer; i: Integer; begin Wait(500); repeat if FindColor(x1, y1, 8077125, 940, 375, 1000, 430) then begin WriteLn('found it') Inc(i); end else begin WriteLn('couldnt find it, trying again'); Wait(500); MoveMouse(950, 325); ClickMouse(950, 325, false); Wait(200); MoveMouse(1050, 325); ClickMouse(1050, 325, false); end; until (i = 1); end. Quote Link to comment Share on other sites More sharing options...