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 


readInteger & writeInteger

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

Joined: 13 Aug 2022
Posts: 13

PostPosted: Thu Aug 18, 2022 4:35 pm    Post subject: readInteger & writeInteger Reply with quote

I can write values to a notepad text file.

Write script:
Code:
local file = io.open("shared.txt","w")
local val = readInteger("166E7A0A3E0")
file:write(val)
file:close()
print(file)

Read script:
Code:
local file = io.open("shared.txt", "r")
local read = file:read("*all")
file:close()
print(read)

How would I send the value to a different address?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri Aug 19, 2022 1:05 am    Post subject: Reply with quote

writeInteger(different address)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Quarter187
Newbie cheater
Reputation: 0

Joined: 13 Aug 2022
Posts: 13

PostPosted: Fri Aug 19, 2022 7:06 am    Post subject: Reply with quote

Dark Byte wrote:
writeInteger(different address)

Could you possibly show me an example of applying writeInteger it to the read script? I can't seem to get it to work. I am attempting to read the value from the text file and send it to the address. With trainers you can send text so I figured somehow do the same thing but with a .txt file.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4297

PostPosted: Fri Aug 19, 2022 10:45 am    Post subject: Reply with quote

writeInteger needs a value too

Again, see the CE wiki, celua.txt, or search the forums for examples.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Quarter187
Newbie cheater
Reputation: 0

Joined: 13 Aug 2022
Posts: 13

PostPosted: Fri Aug 19, 2022 11:06 am    Post subject: Reply with quote

ParkourPenguin wrote:
writeInteger needs a value too

Again, see the CE wiki, celua.txt, or search the forums for examples.


How would I make the value the number that was read from the txt?
I have looked far and wide for what I am trying to do. I have found no example of writing values from a txt, only writing to one. I have been looking deep into I/O Library for solutions. Maybe if I get the linecount of the file and iterate through it based on the linecount then I could update the address according to the loop? I'm really asking for help on this one.

This is what I have got so far:
Code:
local open = io.open
local function read_file(path)
    local file = open(path, "r")
    if not file then return nil end
    local content = file:read "*a"
    writeInteger("179F34935A0", 100) --need to change to read value
    file:close()
    return content
end

print(read_file("shared.txt"))

I just cant figure out how to make the value what was read.
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 11

Joined: 04 May 2016
Posts: 717

PostPosted: Fri Aug 19, 2022 1:06 pm    Post subject: Reply with quote

You will get more help if you demonstrate that you made progress. And if you can demonstrate you made progress you would actually solve your problem.

Here, you want to perform a sequence of steps:

Read a file
Use something read from the file

Have you read the file? Did you prove to yourself that the file is getting read? What is the function returning as read?

If you can't read a file, then Google how to read a file and follow those steps until you can.

If you read the file, why can't you use what you read? What did it give you and why didn't it work.

Is there a format problem, is it a cleanup issue, or is it a type mismatch? Once you figure that out, you will be able to Google the solution.

I have been ignoring most of your posts because you are asking for trivial programming assistance that has nothing to do with cheat engine. But I wager you are reading text from the file and need to supply integers to the function. Or you never even got that far. No one knows how far you got because you arent troubleshooting your problem and describing exactly what you can't get to work. If you were you wouldn't be asking for help because you would realize what the mistake was and googled the solution.

From an outside perspective you are tossing your hands in the air and saying nothing works.

You have received a lot of advice but you are getting resistance because this style of troubleshooting is fundamental to ever getting anything working in programming.

Just take a deep breath, look at the problem one step at a time, and ensure you are getting exactly what you expect, and need, for each step. If you aren't, that is your problem. Describe it to Google and 100 other people have asked and solved those issues.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 140

Joined: 06 Jul 2014
Posts: 4297

PostPosted: Fri Aug 19, 2022 3:22 pm    Post subject: Reply with quote

Quarter187 wrote:
Code:
local content = file:read "*a"
writeInteger("179F34935A0", 100) --need to change to read value
Have you tried changing `100` to `content`? You don't even need to convert that string to a number. CE will automatically do that in writeInteger.
I have a really hard time understanding your situation and why you're having so much difficulty with this. Maybe you just need to take a break? I've been in situations before where I couldn't figure out why something wasn't working. I left it, came back to it after a few days, and found the problem in under a minute.

Also, you shouldn't use the asterisk in `file:read'*a'`. Lua accepts it anyway for backwards compatibility.

_________________
I don't know where I'm going, but I'll figure it out when I get there.
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