Posted: Fri May 29, 2020 7:51 am Post subject: Cheat table with GUI for scripts - or as stand alone
Hi,
I am not sure I posted in the correct subforum, as I do not know the name of what i am looking for.
I have a LUA script that runs continously, copying the contents of the cheat table to the clipboard.
I would like to have a simple GUI with buttons to enable/disable the script.
Or if possible, have the cheat table and script run as a stand alone program (if possible), to make it simpler to run.
I have tried to search for this, but as I am not sure what this would be called, I have come up emptyhanded.
It would of course be nice if someone could help with the solution, but I would be gratefull to just know what I am looking for, and maybe be pointed towards a tutorial or similar.
if t then t.destroy() end
t = createTimer()
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
local values=""
for i=0, al.Count-1 do
values=values..al[i].Description.."***"..al[i].Value.." "
VERSION, with newline
end
writeToClipboard(values)
end
When I execute this script, it will run continously. In order to disable it, I have to open another script window, and execute the code "t.enabled = false"
Background:
I currently have a cheat table setup to extract data from Fifa 20.
The data is transferred to an Excel file, where it is then used to update scores, statistics etc. in a Tournament.
So far, the only way I have found to do this, is to have Cheat Engine copy the data from the table to the clipboard, and then have Excel automatically paste it and then process it from there.
If there is a better way (for instance having cheat table write directly to a database or something), I am open for suggestions (but that might be another topic). The biggest issue is that this has to run fast, as the update to the Excel file needs to be live (currently I have a delay of about 5 seconds, which is acceptable)
I read a lot, but I do not understand all.
I give examples below. Get what you need and use it.
First, determine a way to register.
Code:
local sf = TrainerOrigin or getMainForm()
pth = (sf.."MyHackList\\")
if pth then
os.execute([[mkdir "]]..TrainerOrigin..[[\MyHackList"]])
end
Save "Values" in the created file now.
Code:
function ListSave(Values1)
local index = 1
if pth then
local settingsFile = io.open(pth.."Values.txt", "w")
if (settingsFile ~= nil) then
settingsFile:write(Values1)
settingsFile:close()
end
end
end
Another employee version of the code;
Code:
--openProcess("chrome.exe")
local values=""
if t then t.destroy() end
t = createTimer() t.Enabled=true
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
writeToClipboard(values)
print(values)
t.Enabled=false
end
Let's combine the codes with the method I use.
You can edit the code in the timer function by yourself.
Code:
local sf = TrainerOrigin or getMainForm()
pth = (sf.."MyHackList\\")
if pth then
os.execute([[mkdir "]]..TrainerOrigin..[[\MyHackList"]])
end
function ListSave(Values1)
local index = 1
if pth then
local settingsFile = io.open(pth.."Values.txt", "w")
if (settingsFile ~= nil) then
settingsFile:write(Values1)
settingsFile:close()
end
end
end
local values=""
if t then t.destroy() end
t = createTimer() t.Enabled=false --or auto "true"
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
--writeToClipboard(values)
--print(values)
ListSave(values)
t.Enabled=false
end
--[[
Note: Paste the code into the lua script and run it once,
Save as ".CT".
Then continue with the saved CT file.
]]
if f then f.destroy() f = nil end
f = createForm(true)
f.Position=poDesktopCenter f.Width=525 f.Height=240
local m1=createMemo(f)
m1.Height=180 m1.Left=10 m1.Top=50 m1.Width=240
m1.WordWrap=false m1.ScrollBars="ssAutoBoth"
local m2=createMemo(f)
m2.Height=180 m2.Left=275 m2.Top=50 m2.Width=240
m2.WordWrap=false m2.ScrollBars="ssAutoBoth"
local b1=createButton(f)
b1.Left=10 b1.Top=12 b1.caption="Save"
local b2=createButton(f)
b2.Left=439 b2.Top=12 b2.caption="Load"
local e1=createEdit(f)
e1.Left=95 e1.Top=13 e1.Width=155 e1.ShowHint=true e1.TextHint="Your Save Name?"
local e2=createEdit(f)
e2.Left=275 e2.Top=13 e2.Width=155 e2.ShowHint=true e2.TextHint="Your Load Name?"
--##############################################################################
local sf = TrainerOrigin or getMainForm()
pth = (sf.."MyHackList\\")
if pth then
os.execute([[mkdir "]]..TrainerOrigin..[[\MyHackList"]])
end
function ListSave()
local index = 1
local text=pth..e1.Text..".txt"
if text then
local settingsFile = io.open(text, "w")
if (settingsFile ~= nil) then
settingsFile:write(control_getCaption(m1))
settingsFile:close()
end
end
end
function ListLoad() --Memo2
local text2=pth..e2.Text..".txt"
if text2 then
local settingsFile = io.open(text2, "r")
if (settingsFile ~= nil) then
m2.Lines.Text = settingsFile:read("*a")
settingsFile:close()
end
end
end
openProcess("chrome.exe")
local values=""
if t then t.destroy() end
t = createTimer() t.Enabled=false --or auto "true"
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
--writeToClipboard(values)
--print(values)
t.Enabled=false
m1.Lines.Text=values
sleep(300)
ListSave()
end
b1.OnClick=function() if e1.Text=="" then showMessage("Please enter a valid list name!")
else t.Enabled=true end end
b2.OnClick=function() if e2.Text=="" then showMessage("Please enter a valid list name!")
else ListLoad() end end
@When I execute this script, it will run continously. In order to disable it, I have to open another script window, and execute the code "t.enabled = false"
MemoryRecord script type AA script can run Lua, so that you can stop the timer by a click. For instance, this AA script has a Lua block which toggle your timer on/off when clicked.
btw, it is better use a more meaningful name for global variable, eg myTimer, so that it will not be modified unexpected easily.
Code:
{$lua}
if not syntaxcheck then t.enabled = not t.enabled end
[ENABLE]
[DISABLE]
Thanks for the answers to both of you. Unfortunately, they are not that clear to me, probably due to my lack of knowledge.
Could you perhaps provide a little more context?
I think maybe I just need to know on a more highlevel, what type of tutorial or information I need to find and investigate.
I am completely new to LUA script, and this cheat table is the only thing I use cheat engine for.
I am good at VBA coding, and how done some PHP and javascript. So scripting and coding is not foreign to me - although LUA is.
panraven wrote:
MemoryRecord script type AA script can run Lua, so that you can stop the timer by a click. For instance, this AA script has a Lua block which toggle your timer on/off when clicked.
Code:
{$lua}
if not syntaxcheck then t.enabled = not t.enabled end
[ENABLE]
[DISABLE]
I am unsure how to use this script. Is this something I put in the Lua script editor? Or somewhere else? And how would I link it to a simple GUI with buttons for my Cheat Table?
I am sorry Aylin, but most of your post is lost on me. I either need a bit more context to the examples you give, or just some guidelines on a much higher level that the details you have given.
Aylin wrote:
First, determine a way to register.
Code:
local sf = TrainerOrigin or getMainForm()
pth = (sf.."MyHackList\\")
if pth then
os.execute([[mkdir "]]..TrainerOrigin..[[\MyHackList"]])
end
Not sure what I should register and what it even means?
Aylin wrote:
Save "Values" in the created file now.
Code:
function ListSave(Values1)
local index = 1
if pth then
local settingsFile = io.open(pth.."Values.txt", "w")
if (settingsFile ~= nil) then
settingsFile:write(Values1)
settingsFile:close()
end
end
end
What is the purpose of creating a file in this example?
Is this for my last question about alternatives to my current "copy-paste"-method?
Aylin wrote:
Another employee version of the code;
Code:
--openProcess("chrome.exe")
local values=""
if t then t.destroy() end
t = createTimer() t.Enabled=true
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
writeToClipboard(values)
print(values)
t.Enabled=false
end
This looks very similar to my code, but i don't understand what I should use this example for? What am I missing?
Aylin wrote:
Let's combine the codes with the method I use.
You can edit the code in the timer function by yourself.
Code:
local sf = TrainerOrigin or getMainForm()
pth = (sf.."MyHackList\\")
if pth then
os.execute([[mkdir "]]..TrainerOrigin..[[\MyHackList"]])
end
function ListSave(Values1)
local index = 1
if pth then
local settingsFile = io.open(pth.."Values.txt", "w")
if (settingsFile ~= nil) then
settingsFile:write(Values1)
settingsFile:close()
end
end
end
local values=""
if t then t.destroy() end
t = createTimer() t.Enabled=false --or auto "true"
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
--writeToClipboard(values)
--print(values)
ListSave(values)
t.Enabled=false
end
Again, I don't understand the details of the above. You are referencing a form or a trainer, and then the timer code is on the bottom.
It seems you are saving some list to a file, but you are also copying values to the clipboard.
--[[
Note: Paste the code into the lua script and run it once,
Save as ".CT".
Then continue with the saved CT file.
]]
if f then f.destroy() f = nil end
f = createForm(true)
f.Position=poDesktopCenter f.Width=525 f.Height=240
local m1=createMemo(f)
m1.Height=180 m1.Left=10 m1.Top=50 m1.Width=240
m1.WordWrap=false m1.ScrollBars="ssAutoBoth"
local m2=createMemo(f)
m2.Height=180 m2.Left=275 m2.Top=50 m2.Width=240
m2.WordWrap=false m2.ScrollBars="ssAutoBoth"
local b1=createButton(f)
b1.Left=10 b1.Top=12 b1.caption="Save"
local b2=createButton(f)
b2.Left=439 b2.Top=12 b2.caption="Load"
local e1=createEdit(f)
e1.Left=95 e1.Top=13 e1.Width=155 e1.ShowHint=true e1.TextHint="Your Save Name?"
local e2=createEdit(f)
e2.Left=275 e2.Top=13 e2.Width=155 e2.ShowHint=true e2.TextHint="Your Load Name?"
--##############################################################################
local sf = TrainerOrigin or getMainForm()
pth = (sf.."MyHackList\\")
if pth then
os.execute([[mkdir "]]..TrainerOrigin..[[\MyHackList"]])
end
function ListSave()
local index = 1
local text=pth..e1.Text..".txt"
if text then
local settingsFile = io.open(text, "w")
if (settingsFile ~= nil) then
settingsFile:write(control_getCaption(m1))
settingsFile:close()
end
end
end
function ListLoad() --Memo2
local text2=pth..e2.Text..".txt"
if text2 then
local settingsFile = io.open(text2, "r")
if (settingsFile ~= nil) then
m2.Lines.Text = settingsFile:read("*a")
settingsFile:close()
end
end
end
openProcess("chrome.exe")
local values=""
if t then t.destroy() end
t = createTimer() t.Enabled=false --or auto "true"
t.Interval = 1500
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
--writeToClipboard(values)
--print(values)
t.Enabled=false
m1.Lines.Text=values
sleep(300)
ListSave()
end
b1.OnClick=function() if e1.Text=="" then showMessage("Please enter a valid list name!")
else t.Enabled=true end end
b2.OnClick=function() if e2.Text=="" then showMessage("Please enter a valid list name!")
else ListLoad() end end
I tried executing this script, and it created a form, but also gave an error. And I am not sure what to use this form for. I am guessing it is just an example of a form?
When I execute this script, it will run continuously. In order to disable it, I have to open another script window, and execute the code "t.enabled = false"
So, why not make a function to stop the timer?. Example:
Code:
if f then f.Destroy() end
if t then t.destroy() end
-------------------------------------------- GUI
f = createForm()
function execute()
t.Enabled = true
local al=getAddressList()
local values=""
for i=0, al.Count-1 do
values=values..al[i].Description.."***"..al[i].Value.."\n"
--VERSION, with newline
end
writeToClipboard(values)
end
t = createTimer()
t.Interval = 1500
t.OnTimer = execute
function stopExecute()
t.Enabled = false
end
b1.OnClick = execute
b2.OnClick = stopExecute
And @panraven code is using on Auto Assembler script.
Acces by click > Memory view > Tools > Auto Assemble (or CTRL A) _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
I think I'm number 1 in misunderstanding.
Sample code I provided; It allows you to collect the address list manually and save it in a ".txt" file.
This allows you to look at the working order, for example, and get what you need.
Instead of copy-paste, save directly.
You can change the following setting;
Code:
local text=pth..e1.Text..".txt" --.txt or . excel
local text2=pth..e2.Text..".txt"
Just the following code for Timer "True - False"; >> CE >> Table >> Show Cheat Paste into Table Lua Script and activate it once.
Each time "F8" clicks, "t.Enabled" will return false or true.
Code:
if t then t.destroy() end
t = createTimer() t.Enabled=false --or auto "true"
t.Interval=1500
local values=""
t.OnTimer = function(t)
local al=getAddressList()
for i=0, al.Count-1 do
values=values..al[i].Description.." *** "..al[i].Value.."\n"
--VERSION, with newline
end
writeToClipboard(values)
end
function tKey()
if t.Enabled==false then
t.Enabled=true
--print("Timer open")
else
t.Enabled=false
--print("Timer close")
end
end
htk1=createHotkey(tKey, VK_F8)
Just different ideas, different results.
Get what works for you with rich content. _________________
So, why not make a function to stop the timer?. Example:
...
Because i had no idea where to begin, or even what to search for
Your example works perfectly for what I need it to do, it was exactly what I need.
Thank you very much!
One more question: Is there a reason why you (and Aylin I can see) is having the script create the form, rather than designing it manually? Is it more efficient that way?
Or just easier, in this case when all that is needed is 2 buttons?
One more question: Is there a reason why you (and Aylin I can see) is having the script create the form, rather than designing it manually? Is it more efficient that way?
Or just easier, in this case when all that is needed is 2 buttons?
Nothing special reasons. Because we can't imagine what kind of looks the GUI you have and that just to make it easy for you to try the script and get the logic behind the scripts.
In other, I am personally most like creating GUI using scripts than using Form Designer, just because to get the logics and to enhances scripting capabilities in programming. _________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL
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