View previous topic :: View next topic |
Author |
Message |
dirtythekid Newbie cheater Reputation: 0
Joined: 05 Apr 2015 Posts: 11
|
Posted: Sat May 09, 2015 2:54 pm Post subject: Need help formatting static address for readFloat function. |
|
|
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 |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat May 09, 2015 3:10 pm Post subject: |
|
|
Don't need 'function'. Do need quotes.
Code: | readFloat("GTA5.exe+217A924") |
|
|
Back to top |
|
|
dirtythekid Newbie cheater Reputation: 0
Joined: 05 Apr 2015 Posts: 11
|
Posted: Sat May 09, 2015 3:45 pm Post subject: |
|
|
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 |
|
|
Zanzer I post too much Reputation: 126
Joined: 09 Jun 2013 Posts: 3278
|
Posted: Sat May 09, 2015 4:31 pm Post subject: |
|
|
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 |
|
|
dirtythekid Newbie cheater Reputation: 0
Joined: 05 Apr 2015 Posts: 11
|
Posted: Sat May 09, 2015 5:06 pm Post subject: |
|
|
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 |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat May 09, 2015 5:11 pm Post subject: |
|
|
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 |
_________________
|
|
Back to top |
|
|
dirtythekid Newbie cheater Reputation: 0
Joined: 05 Apr 2015 Posts: 11
|
Posted: Sat May 09, 2015 5:29 pm Post subject: |
|
|
Perfect! Thanks to both of you, you definitely sped this whole thing up.
|
|
Back to top |
|
|
|