forked from JasonGoemaat/CheatEngineMonoHelper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.lua
More file actions
51 lines (49 loc) · 1.57 KB
/
bootstrap.lua
File metadata and controls
51 lines (49 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
function loadTextFile(name, useTableFile)
if useTableFile then
local tableFile = findTableFile(name)
if not tableFile then return nil, 'Unable to open table file "'..tostring(name)..'"' end
local ss = createStringStream()
ss.Position = 0 -- recommended on wiki: https://wiki.cheatengine.org/index.php?title=Lua:Class:TableFile
ss.CopyFrom(tableFile.Stream, 0)
local text = ss.DataString
ss.destroy()
return text
else
local path = getMainForm().openDialog1.InitialDir..name
local f, err = io.open(path, "r")
-- fall back to table file if disk file error (doesn't exist)
if f == nil then return loadTextFile(name, true) end
local text = f:read("*all")
f:close()
return text
end
end
--[[
Save a string to a text file. If useTableFile is true it will be saved as
a TableFile. The directory should be where the cheat file is, it is the
initial directory for the dialog when you are saving your cheat table.
--]]
function saveTextFile(name, text, useTableFile)
if useTableFile then
local tf = findTableFile(name)
if tf ~= nil then
tf.delete()
tf = nil
end
tf = createTableFile(name)
local ss = createStringStream(text)
tf.Stream.CopyFrom(ss, 0)
ss.destroy()
return true
else
local path = getMainForm().saveDialog1.InitialDir..name
local f, err = io.open(path, "w")
if f == nil then return nil, err end
f:write(text)
f:close()
return true
end
end
loadstring(loadTextFile('util.lua'))()
loadstring(loadTextFile('notes.lua'))()
loadstring(loadTextFile('mono.lua'))()