Read from text file and input to address
Posted: Sun Jun 05, 2022 1:28 pm
Looking for a script that reads from a text file, and inputs each line in said text file to a certain address every second or so. Does anything know how to do that?
Community Cheat Tables of Cheat Engine
https://fearlessrevolution.com/
It's a relatively trivial task to loop through a file and output the results, nevertheless, I have written a function and provided code on how you can store the data of each line in a table, iterate over that table, and then print the results to the output window:
Code: Select all
function readFile(filename)
local lines = {}
-- if file doesn't exist then just return nil because we don't want to proceed
if filename == nil then return end
-- open a handle to the file
local file = io.open(filename)
-- loop through the file line-by-line
for line in file:lines() do
-- Insert the line into the table
table.insert(lines, line)
end
-- close the handle to the file
file:close()
return lines
end
-- Initialise a table and store the result of the function as its data
local file_table = readFile('C:\\data.txt')
-- loop through the table and print to Output window
for k,v in pairs(file_table) do
if v ~= nil then
print(v)
end
end