Jump to content
Sign in to follow this  
zutto

abs problems

Recommended Posts

zutto

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

Share this post


Link to post
Share on other sites
DaRam

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}")

Share this post


Link to post
Share on other sites
zutto

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

Share this post


Link to post
Share on other sites
DaRam

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 :/

Share this post


Link to post
Share on other sites
PsaltyDS

$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

Share this post


Link to post
Share on other sites
zutto

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

Share this post


Link to post
Share on other sites
BlackScorpion

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?

Share this post


Link to post
Share on other sites
zutto

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

Share this post


Link to post
Share on other sites
PsaltyDS

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

Share this post


Link to post
Share on other sites
zutto

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

:D

yeah < :o

but got everything to work now, my pathing system is succesful now :D

ty to everyone.

Share this post


Link to post
Share on other sites
Nahuel

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

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.