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 


Need help formatting static address for readFloat function.

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

Joined: 05 Apr 2015
Posts: 11

PostPosted: Sat May 09, 2015 2:54 pm    Post subject: Need help formatting static address for readFloat function. Reply with quote

I'm looking to export the GTA 5 speed value to a .txt file at a certain interval, and then feed that text value into the Processing IDE and then to an Arduino for a speedometer project.

The vehicle speed is present in a static address (GTA5.exe+217A924) as a float value, but I'm not sure how to format that address for the readFloat function.

When I do:
Code:
function readFloat(GTA5.exe+217A924)

it gives the error message
Code:
[string "function readFloat(GTA5.exe+217A924)..."]:1: ')' expected near '.'


If someone could point me in the right direction on formatting the address properly and confirm that I'm on the right track for this project, I'd appreciate it.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat May 09, 2015 3:10 pm    Post subject: Reply with quote

Don't need 'function'. Do need quotes.
Code:
readFloat("GTA5.exe+217A924")
Back to top
View user's profile Send private message
dirtythekid
Newbie cheater
Reputation: 0

Joined: 05 Apr 2015
Posts: 11

PostPosted: Sat May 09, 2015 3:45 pm    Post subject: Reply with quote

Welp, that did it. Thanks. Now I just need to figure out how to set up an interval timer for the value to update to the file.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Sat May 09, 2015 4:31 pm    Post subject: Reply with quote

Code:
t=createTimer(nil)
t.Interval=1000
t.OnTimer=function(t)
  local speed = readFloat("GTA5.exe+217A924")
  -- write to file
end
t.Enabled=true
Back to top
View user's profile Send private message
dirtythekid
Newbie cheater
Reputation: 0

Joined: 05 Apr 2015
Posts: 11

PostPosted: Sat May 09, 2015 5:06 pm    Post subject: Reply with quote

Man, it's so close to working. The only problem now is that it appends the new value after each interval, and I need it to display only the new value and not show the previous intervals. I've tried:
Code:
f = io.open("speed.txt", "w")
t=createTimer(nil)
t.Interval=1000
t.OnTimer=function(t)
  local speed = readFloat("GTA5.exe+217A924")
  f:write(speed)
  f:flush()
  f:close()
end
t.Enabled=true

and it says:
Code:
Error:[string "speed = readFloat("GTA5.exe+217A924")..."]:12: attempt to use a closed file


I guess I'm going about writing to the file the wrong way. It seems like f:close makes that file unusable for the rest of the timer's cycle? I am searching around for a different way to clear the file and write the value to a blank text file. This is my first time dabbling in LUA so you're really helping me out.
Back to top
View user's profile Send private message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Sat May 09, 2015 5:11 pm    Post subject: Reply with quote

Code:
t=createTimer(nil)
t.Interval=1000
t.OnTimer=function(t)
  f = io.open("speed.txt", "w") or error();
  local speed = readFloat("GTA5.exe+217A924")
  f:write(speed)
  f:flush()
  f:close()
end
t.Enabled=true

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
dirtythekid
Newbie cheater
Reputation: 0

Joined: 05 Apr 2015
Posts: 11

PostPosted: Sat May 09, 2015 5:29 pm    Post subject: Reply with quote

Perfect! Thanks to both of you, you definitely sped this whole thing up.
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 Lua Scripting 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