So I've got several questions I need help with:
- I've encountered the dreaded recursion error in one of my more recent scripts.
- I've almost completely avoided using a GUI since I started using Autoit. Now that I want to use it I need some help with setting it up. I have several questions for this.
Recursion:
This error has caused me a headache. I've spent time googling this issue and the reason always given is: "You're making a function call itself in an infinite loop."
Code:
Hi() Func Hi() Hi() EndFunc
Originally I had part of my script as:
Code:
Func CombatRest() Local $coord = PixelSearch($X1, $Y1, $X2, $Y2, 0xFFFFFF) If Not @error Then Send($HealSpell) Sleep($HealSleep) CombatRest() ElseIf @error Then Sleep(10) EndIf EndFunc ;==>CombatRest
Code:
Func CombatRest() Local $coord = PixelSearch($X1, $Y1, $X2, $Y2, 0xFFFFFF) If Not @error Then Send($HealSpell) Sleep($HealSleep) ElseIf @error Then Sleep(10) EndIf EndFunc ;==>CombatRest
All I had to do was send the actual function ONE time at the start of my script, and it went on an infinite loop of functions calling functions until it crashed (After about 1-2 hours of running the script).
So if this IS why I got the recursion error(please confirm this or not) then the solution would be to put my initial:
Code:
While 1 Function1() Function2() Function3() WEnd
~~~~~
GUI:
This part involves several questions. First, I want to include the ability to keep track of how many monsters are killed. So I'm thinking I need to add in a... counter? To the function that confirms when a monster is dead. I already have the function that knows when the monster is dead, but I'm not sure how to write up the counter to the end of the function to add +1 to a display on the GUI. An example function that the counter would be added to would be:
Code:
Func CombatRest() Local $coord = PixelSearch($X1, $Y1, $X2, $Y2, 0xFFFFFF) If Not @error Then Send($HealSpell) Sleep($HealSleep) ElseIf @error Then Sleep(10) EndIf EndFunc ;==>CombatRest
Next question: I can make a simple GUI that has a button that you press and it runs a function/or whatever I put there. Something like this:
Code:
GUICreate("BitOfHope's Autocombat Bot", 170, 100)
GUISetState(@SW_SHOW);Allows the GUI to be displayed.
$exitbutton = GUICtrlCreateButton("Info", 90, 70, 80) ;Information
$Button1 = GUICtrlCreateButton("Button 1", 0, 0, 80);First button on the GUI.
$Button2 = GUICtrlCreateButton("Button 2", 0, 25, 80);Second button on the GUI.
$Button3 = GUICtrlCreateButton("Button 3", 90, 0, 80) ;Third button on the GUI.
$Button4 = GUICtrlCreateButton("Button 4", 90, 25, 80) ;Fourth button on the GUI.
While 1
$msg = GUIGetMsg()
Select
Case $msg = $exitbutton
MsgBox(1, "Read this.", "Placeholder. Information on the bot goes here.");Information button.
Case $msg = $Button1
ToolTip("Popup before the script starts.");Popup message before the script starts.
Sleep(3000)
ToolTip("");Closes the popup message.
Sleep(10)
WinWaitActive($game)
While 1
Sleep(1000);This is what happens after you click the button this is in.
WEnd
Case $msg = $Button2
ToolTip("Popup before the script starts.");Popup message before the script starts.
Sleep(3000)
ToolTip("");Closes the popup message.
Sleep(10)
WinWaitActive($game)
While 1
Sleep(1000);This is what happens after you click the button this is in.
WEnd
Case $msg = $Button3
ToolTip("Popup before the script starts.");Popup message before the script starts.
Sleep(3000)
ToolTip("");Closes the popup message.
Sleep(10)
WinWaitActive($game)
While 1
Sleep(1000);This is what happens after you click the button this is in.
WEnd
Case $msg = $Button4
ToolTip("Popup before the script starts.");Popup message before the script starts.
Sleep(3000)
ToolTip("");Closes the popup message.
Sleep(10)
WinWaitActive($game)
While 1
Sleep(1000);This is what happens after you click the button this is in.
WEnd
Case $msg = $GUI_EVENT_CLOSE;Closes the GUI.
GUIDelete()
ExitLoop
EndSelect
WEnd
Code:
Func CombatRest() Local $coord = PixelSearch($X1, $Y1, $X2, $Y2, 0xFFFFFF) If Not @error Then Send($HealSpell) Sleep($HealSleep) ElseIf @error Then Sleep(10) EndIf EndFunc ;==>CombatRest
I'm sure through the course of writing this script I'll come up with several more questions, most likely GUI related. I'll post them here if I do think of them.
Any help is appreciated!
~~~~~
If anybody is willing to help me out some more with general questions as I write this script, if you're up for adding me on skype/msn so I don't have to come back to the forums every time, that would be epic. Send me a PM on here with your skype/msn and I'll add you.
Also, if anybody is curious the bot I'm making is for FFXIV:ARR. I already have a working version but it's a bit buggy and has no GUI. So I'm re-writing it to make it much sexier. If you're up for helping me out with this specific script instead of just general Autoit questions then also feel free to send me a PM with your skype/msn.






