Cheat Engine
The Official Site of Cheat Engine

Author Message
MikeNoey
How do I cheat?
Reputation: 0

Joined: 08 Jun 2018
Posts: 7

 Posted: Fri Aug 10, 2018 1:24 am    Post subject: Pythagoras theorem in Lua Help Hi guys. First of all I just want to admit that Math isn't my strong suit. I could use some help with this problem. Now I have the addresses for Z and X coordinates for my current location and the Z and X coordinates for the thing I have targeted in the game I'm playing and I want to be able to calculate the distance in meters between my own character and my target. I believe the way to do this is using Pythagoras Theorem. local MyZCoords = ReadFloat("blablabla") local MyXCoords = ReadFloat("blablabla") local TargetZCoords = ReadFloat("blablabla") local TargetXCoords = readFloat("blablabla") If someone could help me fill in the part of the script involving the Pythagoras theorem I'd appreciate it. I meannnnn really appreciate it. Thanks in advance
Dark Byte
Reputation: 357

Joined: 09 May 2003
Posts: 20894
Location: The netherlands

Posted: Fri Aug 10, 2018 2:37 am    Post subject:

 Code: (Target)  |\  | \ a|  \c  |   \  ------ (MyCoords)    b z ^ | -->x

a=|TargetYCoords-MyYCoords|
b=|MyXCoords-TargetXCoords|
c=√(aČ+bČ)

In lua that'd be:
 Code: a=math.abs(TargetYCoords-MyYCoords) --abs is not really necessary but just to make things understandable) b=math.abs(MyXCoords-TargetXCoords) c=math.sqrt(a*a+b*b)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Corroder
Grandmaster Cheater
Reputation: 17

Joined: 10 Apr 2015
Posts: 653

Posted: Fri Aug 10, 2018 6:13 am    Post subject:

into a function

 Code: function distanceFrom(x1,y1,x2,y2) return math.sqrt((x2 - x1) ^ 2 + (y2 - y1) ^ 2) end

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
 All times are GMT - 6 Hours Page 1 of 1

 Jump to: Select a forum Cheat Engine----------------Cheat EngineCheat Engine Lua ScriptingCheat Engine TutorialsGeneral GamehackingAuto Assembler tutorialsPointer tutorialsGame specific tutorialsWebbrowser stuff related tutorialsConsole ModdingLUA TutorialsLua Extensions General Discussions----------------General DiscussionsArtComputer TalkRandom spamArt RequestsArt TutorialsWillekeurige RotzooiGuestsHorse Excrement Cheat Requests----------------Single player cheat request Cheat Engine Downloads----------------TablesTrainersAuto Assemble scripts Coding----------------Cheat Engine SourceCETC Server and ClientsDBVMPlugin developmentGeneral programmingBinariesCrackmesGeneral programming+Game Development2D Graphics3D ModelingGameplay designWeb Development Games----------------Flash GamesGaia OnlineStick Arena
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum