Jump to content

Looping my functions


Recommended Posts

This is one of my first scripts so be patient, but it works almost completely until it gets to Call("Attacking") in the function NT. Am i unable to then recall the original function its being called in such as i have done below? Also if I set NT to something greater than one it just does the NT function over and over. Its possible the problem is with my $conf variable and I'm going to be looking into that a bit more. If you have any suggestions they would be greatly appreciated. If all looks ok then its most likely my $conf variable and ill just fool around with that for a bit.

Here's where I'm having the problem.

#include <IE.au3>
#include <String.au3>
#include <array.au3>
$page=_IEAttach("Blacklist")
$body=_IEBodyReadText($page)

$Conf=_StringBetween( $body, "Confidence: " , "/", -1)
$conf=Number($conf[0])


$LF=_StringBetween( $body, "Life force: " , "/", -1)
$NLF=StringReplace( $LF[0], ",", "")
$NLF=Number($NLF)


$MaxLF=_StringBetween( $body, "LF: "&$LF[0]&"/" , "Conf", -1)
$NMaxLF=StringReplace($MaxLF[0], ",", "")
$NMaxLF=Number($NMaxLF)
$NT=1
$used=0

Func Attacking()
    $conf=_StringBetween( $body, "Confidence: " , "/", -1)
    $conf=Number($conf[0])
    While $conf>0
        _IELinkClickByText($page, "attack")
        If $NLF<$NMaxLF/2 then
            _IELinkClickByText($page, "House")
            _IELinkClickByText($page, "Full Heal")
        EndIf
        _IELinkClickByText($page, "Blacklist")
        $body=_IEBodyReadText($page)
        $conf=_StringBetween( $body, "Confidence: " , "/", -1)
        $conf=Number($conf[0])
        $LF=_StringBetween( $body, "Life force: " , "/", -1)
        $NLF=StringReplace( $LF[0], ",", "")
        $NLF=Number($NLF)
        $MaxLF=_StringBetween( $body, "LF: "&$LF[0]&"/" , "Conf", -1)
        $NMaxLF=StringReplace($MaxLF[0], ",", "")
        $NMaxLF=Number($NMaxLF)
    Wend
    If $used<$NT then
        Call("NT")
    Endif
Endfunc

Func NT()
    $used=$used+1
    _IELinkClickByText($page, "--------'s House")
    _IELinkClickbytext($page, "use")
    _IELinkClickByText($page, "Confirm")
    _IELinkClickByText($page, "Blacklist")
    Call("Attacking")
EndFunc

Call("Attacking")
Edited by Lax0450
Link to comment
Share on other sites

The Call() function has a special purpose, It should not be used to call function regularly. To do that, You should use function notation, ie.

MyFunc($MyParameter)

So You should call your NT() function like this:

If $used<$NT then
        NT() ;Calls NT() with no parameters
Endif

Same applies for Attacking()

Link to comment
Share on other sites

Thank you very much, i knew it was odd having a function to call my functions but i saw it there so i thought perhaps it was necessary. And would you look at that I found my error after sitting here for hours trying to figure it out after painful test since it takes about 8 mins of runtime to finally see if i fixed my error.

If youre curious:

Error was in the $conf variable, since its constantly changing as the page refreshes the body needed to be refreshed also. So as i redefined the variable i was really doing absolutely nothing. The body text ($body variable) needs to be redefined each time i'm redefining my $conf variable. The reason I couldnt figure it out is that my while loop the $conf variable is changing, but thats because i redefined $body!

Thanks a lot ---- Lax0450

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...