gnollwood Posted November 7, 2006 Posted November 7, 2006 Can anyone tell me what's causing the recursion error / how to fix it? expandcollapse popupFunc startFishing() GUIDelete() If WinExists('World of Warcraft') Then WinActivate('World of Warcraft') $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '') Send('1') Global $timerstart = TimerInit(); tt('Casting Fishing Rod!') $pos = MouseGetPos() sleep(3000) tt('Looking for bobber!') $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3) If Not @Error Then tt('Bobber successfully located!') MouseMove($pos[0], $pos[1], 0) Global $bobx = $pos[0] Global $boby = $pos[1] waitForBite() Else startFishing() EndIf Else MsgBox(0, 'Error', 'World of Warcraft MUST be running.') Exit EndIf EndFunc Func waitForBite() $splashl = $bobx - 30 $splasht = $boby - 30 $splashr = $bobx + 30 $splashb = $boby + 30 tt('Waiting for fish to bite!') While TimerDiff($timerstart) < 30000 $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2) If Not @Error Then tt('Line has been bitten!') getLoot() $timerstart = 30000 EndIf WEnd startFishing() EndFunc Func getLoot() Send('{shiftdown}') MouseMove($bobx, $boby, 0) MouseClick('right') Send('{shiftup}') tt('Fish has been caught & looted succesfully!') sleep(1500) startFishing() EndFunc Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!
Uten Posted November 7, 2006 Posted November 7, 2006 Func StartFishing() ;..... Else startFishing() EndIf ;.... EndFunc Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
gnollwood Posted November 7, 2006 Author Posted November 7, 2006 thanks, i didn't even noticed that! i fixed it by making a separate function for getting the bobber colour and did it that way, here's my fixed code: expandcollapse popupFunc startFishing() GUIDelete() If WinExists('World of Warcraft') Then WinActivate('World of Warcraft') $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '') Send('1') Global $timerstart = TimerInit(); tt('Casting Fishing Rod!') $pos = MouseGetPos() sleep(3000) getBobber() Else MsgBox(0, 'Error', 'World of Warcraft MUST be running.') Exit EndIf EndFunc Func getBobber() tt('Looking for bobber!') $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3) If Not @Error Then tt('Bobber successfully located!') MouseMove($pos[0], $pos[1], 0) Global $bobx = $pos[0] Global $boby = $pos[1] waitForBite() Else startFishing() EndIf EndFunc Func waitForBite() $splashl = $bobx - 30 $splasht = $boby - 30 $splashr = $bobx + 30 $splashb = $boby + 30 tt('Waiting for fish to bite!') While TimerDiff($timerstart) < 30000 $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2) If Not @Error Then tt('Line has been bitten!') getLoot() $timerstart = 30000 EndIf WEnd startFishing() EndFunc Func getLoot() Send('{shiftdown}') MouseMove($bobx, $boby, 0) MouseClick('right') Send('{shiftup}') tt('Fish has been caught & looted succesfully!') sleep(1500) startFishing() EndFunc Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!
ChrisL Posted November 7, 2006 Posted November 7, 2006 thanks, i didn't even noticed that! i fixed it by making a separate function for getting the bobber colour and did it that way, here's my fixed code:Do you not still have problems with this?You have just added a new function but that function still calls the first function and the functions don't return. [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
tresa Posted November 7, 2006 Posted November 7, 2006 (edited) gnollwood, You find a solution but your code is bug risky as you're doing what I call 'Moebius bandage' coding >>>startFishing() startFishing() >>> getBobber()>>>waitForBite()>>>getLoot()>>> startFishing() >>>startFishing() oÝ÷ Ù8^më-Á¬¡«èÛaȬ¶n¶Ú¥ª^®Ø^jX(¯+a*.Á©í¶hN(*.û§rب¬nÞv¬ßÙírW®ÆZxz¨» .ØZ½ëayùhÂX¤y«¢+Ø)Ý¡¥±]½É±]½ÉÉÑ%ÍIÕ¹¹¥¹ ¤)¥ÑÍÐ:ÀÄÑ¡¸½Ñ¥½¸:ÀÄ줼Ìäí¹Ð¹½Üݽɱ½]½ÉÉÐÌÌì)¥ÑÍÐ:ÀÈÑ¡¸½Ñ¥½¸:ÀÈ(¸¸¸¸¸)ͱÀ ÄÀ¤)ݹ( then after this you code placing the tests and doAction as functions Edited November 7, 2006 by tresa
ChrisL Posted November 7, 2006 Posted November 7, 2006 This isn't tested at all but I'm thinking you need something like this. expandcollapse popup;Return 1 to startfishing ;Return 2 to getBobber ;return 3 to waitforbite ;return 4 to getloot $job = StartFishing() While 1 Switch $job Case 1 $job = StartFishing() Case 2 $job = GetBobber() Case 3 $job = WaitForBite() Case 4 $job = getLoot() EndSwitch WEnd Func startFishing() GUIDelete() If WinExists('World of Warcraft') Then WinActivate('World of Warcraft') $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '') Send('1') Global $timerstart = TimerInit(); tt('Casting Fishing Rod!') $pos = MouseGetPos() sleep(3000) Return 2 ;getBobber() Else MsgBox(0, 'Error', 'World of Warcraft MUST be running.') Exit EndIf EndFunc Func getBobber() tt('Looking for bobber!') $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3) If Not @Error Then tt('Bobber successfully located!') MouseMove($pos[0], $pos[1], 0) Global $bobx = $pos[0] Global $boby = $pos[1] Return 3 ;waitForBite() Else Return 1 ;startFishing() EndIf EndFunc Func waitForBite() $splashl = $bobx - 30 $splasht = $boby - 30 $splashr = $bobx + 30 $splashb = $boby + 30 tt('Waiting for fish to bite!') While TimerDiff($timerstart) < 30000 $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2) If Not @Error Then tt('Line has been bitten!') Return 4 ;getLoot() $timerstart = 30000 EndIf WEnd Return 1 ;startFishing() EndFunc Func getLoot() Send('{shiftdown}') MouseMove($bobx, $boby, 0) MouseClick('right') Send('{shiftup}') tt('Fish has been caught & looted succesfully!') sleep(1500) Return 1 ;startFishing() EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
tresa Posted November 7, 2006 Posted November 7, 2006 ChrisL, your code is better. I would have auto documented it like this expandcollapse popup$doStartFishing=1 $doGetBobber=2 $doWaitForBite=3 $doGetLoot=4 GUIDelete() $followingJob = StartFishing() While WinExists('World of Warcraft') WinActivate('World of Warcraft') Switch $followingJob Case $doStartFishing $followingJob = StartFishing() Case $doGetBobber $followingJob = GetBobber() Case $doWaitForBite $followingJob = WaitForBite() Case $doGetLoot $followingJob = getLoot() EndSwitch WEnd Func startFishing() $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '') Send('1') Global $timerstart = TimerInit(); tt('Casting Fishing Rod!') $pos = MouseGetPos() sleep(3000) Return $doGetBobber EndFunc Func getBobber() tt('Looking for bobber!') $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3) If Not @Error Then tt('Bobber successfully located!') MouseMove($pos[0], $pos[1], 0) Global $bobx = $pos[0] Global $boby = $pos[1] Return $doWaitForBite Else Return $doStartFishing EndIf EndFunc Func waitForBite() $splashl = $bobx - 30 $splasht = $boby - 30 $splashr = $bobx + 30 $splashb = $boby + 30 tt('Waiting for fish to bite!') While TimerDiff($timerstart) < 30000 $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2) If Not @Error Then tt('Line has been bitten!') Return $dogetLoot $timerstart = 30000 EndIf WEnd Return $dostartFishing EndFunc Func getLoot() Send('{shiftdown}') MouseMove($bobx, $boby, 0) MouseClick('right') Send('{shiftup}') tt('Fish has been caught & looted succesfully!') sleep(1500) Return $dostartFishing EndFunc
gnollwood Posted November 7, 2006 Author Posted November 7, 2006 i don't know.. no recursive error has presented itself now that i changed it Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!
gnollwood Posted November 8, 2006 Author Posted November 8, 2006 haha and there it was.. i'm trying to fix it now.. Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!
gnollwood Posted November 8, 2006 Author Posted November 8, 2006 I tried your way, and when I Return 2 to go to the next action, nothing happens ( Put your link in my signature for just $1,000,000.00 USD! PM me for arrangements!
Uten Posted November 8, 2006 Posted November 8, 2006 Put some traces in your code and I predict you will soon be able to spot the problem (hmm, I don't know what it is so I'm not pulling your leg) Traces is your friend. ConsoleWrite or search for +dbg +assert. Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
tresa Posted November 8, 2006 Posted November 8, 2006 (edited) I made modifications in the code (untested I have not world of wordcraft!) - the timer is done in the general loop to improve clarity - when actions are done in a row I change the functions to look for a success with an if test - I put a sleep(10) in the timer loop so as Autoit do'nt overcharge the processor expandcollapse popupGlobal $bobx, $boby GUIDelete() While WinExists('World of Warcraft') WinActivate('World of Warcraft') StartFishing() sleep(3000) if GetBobber()=false then continueLoop tt('Waiting for fish to bite!') $timerstart = TimerInit(); $looted=false While TimerDiff($timerstart) < 30000 and $looted=false if IHaveBite=true then getLoot() $looted=true endif sleep(10) Wend WEnd Func startFishing() $bobbercolor = iniRead($pagle_conf_file, 'settings', 'bobber', '') Send('1') tt('Casting Fishing Rod!') EndFunc Func getBobber() tt('Looking for bobber!') $pos = PixelSearch($areal, $areat, $arear, $areab, $bobbercolor, $pagle_tolerance, 3) If Not @Error Then tt('Bobber successfully located!') MouseMove($pos[0], $pos[1], 0) $bobx = $pos[0] $boby = $pos[1] Return true Else Return false EndIf EndFunc Func IHaveBite() $splashl = $bobx - 30 $splasht = $boby - 30 $splashr = $bobx + 30 $splashb = $boby + 30 $pos = PixelSearch($splashl, $splasht, $splashr, $splashb, '0xffffff', $splsh_tolerance, 2) If Not @Error Then tt('Line has been bitten!') return true EndIf Return false EndFunc Func getLoot() Send('{shiftdown}') MouseMove($bobx, $boby, 0) MouseClick('right') Send('{shiftup}') tt('Fish has been caught & looted succesfully!') sleep(1500) EndFunc Edited November 8, 2006 by tresa
ChrisL Posted November 8, 2006 Posted November 8, 2006 I tried your way, and when I Return 2 to go to the next action, nothing happens ( It must be something your doing but only having a small part of the code it's not very easy to see what. The basics of what I wrote earlier works, in the simple version of the code below works fine if you run it in scite you can see it returning and calling the next function, I've put a bit of randomness in to it too so that different functions are called. expandcollapse popup;Return 1 to startfishing ;Return 2 to getBobber ;return 3 to waitforbite ;return 4 to getloot $job = StartFishing() While 1 Switch $job Case 1 $job = StartFishing() Case 2 $job = GetBobber() Case 3 $job = WaitForBite() Case 4 $job = getLoot() EndSwitch Sleep (Random (1000, 2000)) WEnd Func startFishing() ConsoleWrite ("Start Fishing" & @crlf) Return 2 EndFunc Func getBobber() ConsoleWrite ("getBlobber" & @crlf) $sec = StringRight (@Sec, 1) If $sec = 1 or $sec = 3 or $sec = 5 then Return 3 Else Return 1 EndIf EndFunc Func waitForBite() ConsoleWrite ("WaitforBite" & @crlf) $sec = StringRight (@Sec, 1) If $sec = 1 or $sec = 3 or $sec = 5 then Return 4 Else Return 1 EndIf EndFunc Func getLoot() Consolewrite ("Getloop" & @crlf) Return 1 EndFunc [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now