Jump to content

abs problems


Recommended Posts

yep

i am having problems with this, it should change the negative numbers to positive, but for some reason, it keeps them negative

i cant see any problems by myself so i decided to ask from here, since these are actually helpfull forums :D

i got this same code to work on c++ but not on autoit :/ [ofcourse, not exactly same, converted to c++ from autoit]

anyone got tips where i am going wrong?

EDIT:

X, Y is destination if you wonder what they are.

Do
        $Xss = _MEMORYREAD($PTRPLAYERX, $HPROCESS, "float")
        $Yss = _MEMORYREAD($PTRPLAYERY, $HPROCESS, "float")
        Send("{w down}")
        $x = abs($x)
        $y = abs($y)
        $xss1 = $xss
        $yss1 = $yss
        $dx = $x - $xss
        $dy = $y - $yss
        $dx = StringLeft($dx, 4)
        $dy = StringLeft($dy, 4)
        $distance = sqrt($dx^2 + $dy^2)
    Until  $dx < 4 & $dy < 4 
    send("{W UP}")

Pythogorean theorem, ftw!.. if anyone noticed :o

Edited by zutto
Link to comment
Share on other sites

I have no idea where $x and $y are being assigned, but I have added Msgbox code to Monitor the variables, run it and see...

Do
        $Xss = _MEMORYREAD($PTRPLAYERX, $HPROCESS, "float")
        $Yss = _MEMORYREAD($PTRPLAYERY, $HPROCESS, "float")
        Send("{w down}")
Msgbox(0, "X and Y Values", "$x=" & $x & @CRLF & "$y=" & $y)
        $x = abs($x)
        $y = abs($y)
Msgbox(0, "X and Y Values", "$x=" & $x & @CRLF & "$y=" & $y)
        $xss1 = $xss
        $yss1 = $yss
        $dx = $x - $xss
        $dy = $y - $yss
        $dx = StringLeft($dx, 4)
        $dy = StringLeft($dy, 4)
        $distance = sqrt($dx^2 + $dy^2)
    Until  $dx < 4 & $dy < 4 
    send("{W UP}")
Link to comment
Share on other sites

I have no idea where $x and $y are being assigned, but I have added Msgbox code to Monitor the variables, run it and see...

Do
        $Xss = _MEMORYREAD($PTRPLAYERX, $HPROCESS, "float")
        $Yss = _MEMORYREAD($PTRPLAYERY, $HPROCESS, "float")
        Send("{w down}")
Msgbox(0, "X and Y Values", "$x=" & $x & @CRLF & "$y=" & $y)
        $x = abs($x)
        $y = abs($y)
Msgbox(0, "X and Y Values", "$x=" & $x & @CRLF & "$y=" & $y)
        $xss1 = $xss
        $yss1 = $yss
        $dx = $x - $xss
        $dy = $y - $yss
        $dx = StringLeft($dx, 4)
        $dy = StringLeft($dy, 4)
        $distance = sqrt($dx^2 + $dy^2)
    Until  $dx < 4 & $dy < 4 
    send("{W UP}")

$x & $y is assigned on the function..

i call the function with $x & y.. but i try with MSGboxes

edit: abs fails :/

Edited by zutto
Link to comment
Share on other sites

Abs() of nothing will result in nothing. :D

You need to assign something to $x and $y before attempting an Abs on them.

$x & $y is assigned on the function..

i call the function with $x & y.. but i try with MSGboxes

edit: abs fails :/

Link to comment
Share on other sites

$x & $y is assigned on the function..

i call the function with $x & y.. but i try with MSGboxes

edit: abs fails :/

Fails with what input? What did the MsgBox() show? You can't expect help with a supposedly failing function without explaining what inputs it received.

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Fails with what input? What did the MsgBox() show? You can't expect help with a supposedly failing function without explaining what inputs it received.

:D

it gave me the numbers as they we're.. as negative ;/

but yeah, i'll use other way :o

if $number > 0 then $number * -1

should do the job

Link to comment
Share on other sites

you abs($x)

you read ($xss) raw from memory and subtract it from $x

its your $x - $xss (if $xss is > $s you will get a negative in $x)

This is obviously waypoint bot code, and you are moving towards the waypoint, what game you writing a bot for?

:D good good, someone found out its for bot.. pythogorean theorem is kinda obvious tho..

trying to find out where it fails..

this is for wow.. :|

Link to comment
Share on other sites

it gave me the numbers as they we're.. as negative ;/

but yeah, i'll use other way :o

if $number > 0 then $number * -1

should do the job

Abs() works fine, but yours would have to be: if $number < 0 then $number * -1

:D

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

$dx = $x - $xss
        $dy = $y - $yss
        $dx = StringLeft($dx, 4)
        $dy = StringLeft($dy, 4

That leads me to believe that you are working with both numbers and strings... Perhaps that's where your problem is.

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...