Page 1 of 1
Error in setting variable?
Posted: Tue Jul 26, 2005 6:46 am
by oompaloompa
hello
I posted in the wiki at the bottom of this page
http://www.macroquest2.com/wiki/index.php/MQ2DataVars
I have been at trying to solve it for 3 hours now lol
but im trying to make something that will run me to the zone using a specific path cause my mom always wants me to do something and i dont like just standing in the middle of the zone some times
here is what i have so far
Code: Select all
Sub Main
/declare RT int outer
:FirstDestination
/Face loc -1680,-3400
/look 50
/delay 3
/vardata RT Math.Calc[((${My.X}--1680)^2+(${My.Y}--3400)^2)^(1/2)/(4.5)]
/delay 5
/keypress forward hold
/delay RT
/keypress back
/endmacro
okay when i tried to set a variable for the locs it used 0 0 and i did Varset, so something is wrong with my var set is what i am guessing
for the var data im guessing its doing the same thing, ignoring the value i put and keeping it at 0
can some one please help?
for the formula its distance/speed cause our toons go about 31everquestmilesperhour at run 5 which i have. so about 4.5 feet per centisecond.
and also if there is an easier way of doing this please tell me lol thanks for the help guys
Posted: Tue Jul 26, 2005 7:33 am
by blueninja
Use move.inc or advpath.inc ..
Or, if you want to use the stuff you already wrote change the vardata command to:
Code: Select all
/varset RT ${Math.Calc[((${My.X}--1680)^2+(${My.Y}--3400)^2)^(1/2)/(4.5)]}
Posted: Tue Jul 26, 2005 10:57 am
by dman
Only thing that it looks like to me is the double '--', try using just one minus sign in your formula, or instead of /vardata'ing the formula (which will fail silently) just /echo the statement and see what output you get. so
Code: Select all
/vardata RT Math.Calc[((${My.X}-1680)^2+(${My.Y}-3400)^2)^(1/2)/(4.5)]
edit: bah, ignore me, as usual Lax outthinks the normal people at this time of morning.
Posted: Tue Jul 26, 2005 11:49 am
by Lax
Why are you using vardata or discussing varset when clearly, varcalc is intended for exactly this purpose...
and subtracting a negative works fine.
but... your edit did not belong on the MQ2DataVars syntax page so I removed it (thanks for trying).
Now.. are you aware that ^ is XOR, not a power? You need to use two to make it power.
Code: Select all
/varcalc RT ((${My.X}--1680)^^2+(${My.Y}--3400)^^2)^^(1/2)/(4.5)
Also, you can make that 1/2 ".5" and then add parentheses to make it clear to humans whether you want to divide the .5 by 4.5, or power by .5 and then divide the entire thing by 4.5
Posted: Tue Jul 26, 2005 4:12 pm
by oompaloompa
blueninja dman and lax, thank you for your input. sorry about not knowing ^^ was a power, lol im only 16 and ive only programmed in Basic some C script some c++ lots of HTML some javascript PHP... and some other crap lol, thank you so much for pointing this out to me... i want to be a coding genius like you when i grow up =P.
Thank you for the answers guys, i owe you guys =)
gona try lax's code and see if it works (it will unless i make another stupid mistake =))
laterz
Posted: Tue Jul 26, 2005 4:36 pm
by oompaloompa
Okay well... My ram seems like it doesnt want to store variables or something, this is the code
Code: Select all
Sub Main
/declare RT int outer
/declare Destonex float outer
/declare Destoney float outer
:FirstDestination
/varset Destonex -3400
/varset Destoney -1680
/Face loc Destonex,Destoney
/delay 3
/varcalc RT ((${My.X}--1680)^^2+(${My.Y}--3400)^^2)^^(1/2)/(4.5)
/delay 5
/keypress forward hold
/delay RT
/keypress back
/endmacro
and i changed the face loc to variables so i could see if it was storing variables, and just as i had suspected it faced me towards 0,0. is there a rule i'm missing here? cause this should work lol
Edit: is there an easier way to tell it to run to a location on the map?
Posted: Tue Jul 26, 2005 5:52 pm
by drzoon
How about this:
Code: Select all
Sub RunToLoc (int XLoc, int YLoc)
:run_to
/if (${Math.Distance[${YLoc},${XLoc}]}<10) {
/echo At location, returning!
} else {
/if (${Math.Distance[${YLoc},${XLoc}]}<20) {
/keypress forward
/delay 2s !${Me.Moving}
} else {
/face nolook loc ${YLoc},${XLoc}
/keypress forward hold
/goto :run_to
}
}
/return
PS: I believe I stole most of this from Rusty's Autoenc mac, certainly the idea.
Posted: Tue Jul 26, 2005 6:59 pm
by oompaloompa
Thank you, it works like a charm bud! My way was entirely too complicated lol

im too inexperienced i guess =)
laterz