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 


[HELP] How to check if a number exist in .txt

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Hadaar
How do I cheat?
Reputation: 0

Joined: 08 May 2020
Posts: 5
Location: Anywhere

PostPosted: Sat Jun 12, 2021 11:00 am    Post subject: [HELP] How to check if a number exist in .txt Reply with quote

Hello friends.
I want to check if a number already exist in a .txt file.

This is my write function

Code:
local v = assert(io.open("SavedVars.txt", "a"))
v:write(123,"\n")
v:close()
 showMessage("Done... Data Saved")


I want to check if "123" already exist in that file on any line.
I am very new to lua
Anyone can help me? Smile
Thanks
Back to top
View user's profile Send private message
HexaG0n
Advanced Cheater
Reputation: 0

Joined: 29 Mar 2021
Posts: 64

PostPosted: Sun Jun 13, 2021 10:15 pm    Post subject: Reply with quote

i think this works

Code:
local h = io.open('SavedVars.txt', 'r')
h2 = h:read('*a')
io.close(h)
i, ii = string.find(h2, '123')

if string.sub(h2, i, ii) ~= nil then
--script
else
--script
end
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