Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Lua script to calculate floats

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
Magusmarisa
Newbie cheater
Reputation: 0

Joined: 03 May 2015
Posts: 10

PostPosted: Mon Jun 20, 2022 10:12 pm    Post subject: Lua script to calculate floats Reply with quote

Hi. I start by saying that I really suck with lua and math and I have no idea how to even implement what I'm trying to achieve.

I'm trying to have a teleport tool but the game uses weird system where teleporting by just with 12 bytes of XYZ is not "possible". Instead need to calculate difference and write this value to player XYZ.

So script is going to have label where we put desired 12 bytes of player coordinates.
Then script would read current player position from: [[[[[BaseA]+B658]+0*10]+190]+68]+70

and then it would add X, Y, Z of player position to to the pasted X, Y, Z and then write final value to the pointer above.


So example: player coordinates are:

X: 100
Y: 5
Z: 200

The desired destination:

X:500
Y:10
Z:300

So after map the result would be:

X:600
Y:15
Z:500.

Then write a new value [[[[[BaseA]+B658]+0*10]+190]+68]+70
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1069
Location: 0x90

PostPosted: Tue Jun 21, 2022 6:04 am    Post subject: Reply with quote

Well, with Lua you can just use arithmetic operators.
Code:

local x = 100.0
local y = 5.0
local z = 200.0

local x2 = 500
local y2 = 10.0
local z2 = 300.0

function addValues(a,b)
  local n1 = a
  local n2 = b
  if a == nil or b == nil then return end
  return n1 + n2
end

print('X = ' .. addValues(x,x2))
print('Y = ' .. addValues(y,y2))
print('Z = ' .. addValues(z,z2))


Output:
Code:

X = 600.0
Y = 15.0
Z = 500.0
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites