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 


Lua Blocks not working when exporting trainer exe (Solved)

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

Joined: 15 Feb 2022
Posts: 7

PostPosted: Sat Mar 12, 2022 6:09 am    Post subject: Lua Blocks not working when exporting trainer exe (Solved) Reply with quote

I created a few auto-assemble scripts (including LUA blocks). The scripts work fine, when they are activated in in Cheat Engine (please see attachment).

When I saved the project as exe, cheat engine warned me about "generating a trainer that does nothing" - And it acutlly does nothing 😅.

I was searching the wiki but I couldn't figure out, how these scripts can be "added" when saving a Cheat-Engine-Trianer.EXE.

What I want is:

- Save project as exe
- Start the exported exe
- The scripts I have created should now work with the game


Thank you very much for your help!

PS: I posted this thread to the Lua Scripting section, since I don't know whether you have to do special stuff to export lua scripts. Please feel free to move this thread if this is not the case @mods


EDIT:

Problem solved:

It's a bug in Cheatengine, but there is a workaround:

If you want to use Lua Codeblocks you have to add the luaclient.dll from the Cheatengine root folder manually.


cheatengine.org/viewtopic.php?t=618886



cheat engine scripts.PNG
 Description:
Enabled Auto Assembly CI Scripts
 Filesize:  7.29 KB
 Viewed:  4538 Time(s)

cheat engine scripts.PNG




Last edited by HotPieOnARack on Sat Mar 12, 2022 5:05 pm; edited 1 time in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1520

PostPosted: Sat Mar 12, 2022 6:49 am    Post subject: Reply with quote

Put this code in your Lua script and save Trainer.

Code:
--When the trainer opens, you'll want to connect it to the game.
--Otherwise, the script will not execute.
local check=false
proc=getProcessIDFromProcessName("yourGame.exe") -- your game.exe
 if proc~=nil then
  check=true
  openProcess(proc)
  else
  check=false
 end

function trainerDoingSomething()
 if check==true then
  addresslist=getAddressList()
  CheatEntry1=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Item Drop")
  CheatEntry1.Active=true
  CheatEntry2=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Room Number Change")
  CheatEntry2.Active=true
  CheatEntry3=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Looking At Item")
  CheatEntry3.Active=true
  showMessage("Trainer has been activated.")
  else
  showMessage("Error! The game is not open!\nTrainer will shut down!!")
  closeCE() return cafree()
 end
end

trainerDoingSomething()

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
HotPieOnARack
How do I cheat?
Reputation: 0

Joined: 15 Feb 2022
Posts: 7

PostPosted: Sat Mar 12, 2022 7:37 am    Post subject: Reply with quote

AylinCE wrote:
Put this code in your Lua script and save Trainer.

Code:
--When the trainer opens, you'll want to connect it to the game.
--Otherwise, the script will not execute.
local check=false
proc=getProcessIDFromProcessName("yourGame.exe") -- your game.exe
 if proc~=nil then
  check=true
  openProcess(proc)
  else
  check=false
 end

function trainerDoingSomething()
 if check==true then
  addresslist=getAddressList()
  CheatEntry1=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Item Drop")
  CheatEntry1.Active=true
  CheatEntry2=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Room Number Change")
  CheatEntry2.Active=true
  CheatEntry3=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Looking At Item")
  CheatEntry3.Active=true
  showMessage("Trainer has been activated.")
  else
  showMessage("Error! The game is not open!\nTrainer will shut down!!")
  closeCE() return cafree()
 end
end

trainerDoingSomething()


Does this go to "Show Cheat Table Lua Script" ?



cheat engine scripts2.PNG
 Description:
 Filesize:  51.7 KB
 Viewed:  4518 Time(s)

cheat engine scripts2.PNG


Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1520

PostPosted: Sat Mar 12, 2022 8:12 am    Post subject: Reply with quote

Yes this step is correct.
Write the game process where you marked in the picture and click the "Execute Script" button to test the code.
If all goes well, create Trainer.exe and test it.

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
HotPieOnARack
How do I cheat?
Reputation: 0

Joined: 15 Feb 2022
Posts: 7

PostPosted: Sat Mar 12, 2022 8:34 am    Post subject: Reply with quote

AylinCE wrote:
Yes this step is correct.
Write the game process where you marked in the picture and click the "Execute Script" button to test the code.
If all goes well, create Trainer.exe and test it.


Thank you, I can't send you a pm yet so I have to ask in this thread:


I added the code that connects to the game + activates the scripts in the lua cheat table.


- I open the game
- I start Cheat Engine
- I open the Cheat Engine project (without connecting via "File -> "Open Process")
- I run the cheat table lua script
- Cheatengine is connected to the game. The scripts are being executed! This works like charm

When I create a trainer and execute it, the Dialog will Show "Trainer has been activated.". But the Scripts will not work. Maybe I am missing a config? I attached a screenshot of the setup I have to create a trainer.

Could you please look at it? Maybe you see why its not working...

PS:
My lua scripts require external scripts which I placed in Cheat Engines lua folder. May this be the cause?



trainer generator.PNG
 Description:
 Filesize:  20.18 KB
 Viewed:  4505 Time(s)

trainer generator.PNG


Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1520

PostPosted: Sat Mar 12, 2022 9:13 am    Post subject: Reply with quote

This works in my case.
I left the "print(hack)" instruction to the address list scripts.

But this "exe" table won't do you any good.
Let's give it a "Form" and give the Trainer steps to open, start, close. Otherwise the Trainer will still remain open.

If you wait a bit, I will give you a handsome code that will solve this problem..


EDIT :
In your case, this form might work.
Paste this code into your Lua script, test it, and if it's working properly, register it as a Trainer.

Note: Replace "yourGame.exe" with your game process. (In my case "chrome.exe")
Also watch out for "Target" in Trainer Generator.
In your picture, Target 32 bit is selected. In my case it's 64 bit.

good games.. Wink

Code:
if form then form.destroy() form = nil end
form = createForm()
form.Popupmode=0;
form.Position=poDesktopCenter form.Width=240 form.Height=180
form.BorderStyle="bsNone" form.ShowInTaskBar="stAlways"
form.setLayeredAttributes(0x000100, 255, LWA_COLORKEY | LWA_ALPHA )
form.Color=0x000100

local RpTitle = createPanel(form)
RpTitle.Left=0 RpTitle.Top=0 RpTitle.Height=35 RpTitle.Width=240
RpTitle.Font.Size=14 RpTitle.Font.Style='fsBold' RpTitle.Cursor= -22
RpTitle.OnMouseDown = function() form.DragNow() end
RpTitle.BevelWidth=5 RpTitle.Color=4259328

RpTitle.Caption=[[By  AylinCE  Trainer]]

local RpTbl = createPanel(form)
RpTbl.Left=0 RpTbl.Top=40 RpTbl.Height=135 RpTbl.Width=240
RpTbl.BevelWidth=5 RpTbl.Color=4259328

local RpBtn1 = createPanel(RpTbl)
RpBtn1.Left=10 RpBtn1.Top=15 RpBtn1.Height=26 RpBtn1.Width=220

local RpBtn2 = createPanel(RpTbl)
RpBtn2.Left=10 RpBtn2.Top=55 RpBtn2.Height=26 RpBtn2.Width=220

local RpBtn3 = createPanel(RpTbl)
RpBtn3.Left=10 RpBtn3.Top=95 RpBtn3.Height=26 RpBtn3.Width=220

function panelClickEffect(item2, text)
local color1=clDefault
item2.BevelColor=color1
item2.BevelWidth=3
item2.Font.Size=10 --item2.BevelInner="bvRaised" item2.BevelWidth=3 item2.Font.Color="0x000000"
item2.Font.Style="fsBold" item2.ShowHint=true item2.OptimalFill=true
item2.Font.Name="Georgia" item2.Cursor=-21 item2.Color="16760576"
item2.caption = text

item2.OnMouseMove=function() item2.BevelColor=0 end
item2.OnMouseLeave=function() item2.BevelColor=color1 end

item2.OnMouseDown=function() item2.Color="0x00ffff" end
item2.OnMouseUp=function() item2.Color="16760576" end
end

panelClickEffect(RpBtn1, "Click if the game is open!")
panelClickEffect(RpBtn2, "Hack Enable (is) [OFF]")
panelClickEffect(RpBtn3, "Close  Trainer")

RpBtn2.Enabled=false

--########################## func ...
local check=true

RpBtn1.OnClick=function()
proc=getProcessIDFromProcessName("yourGame.exe") -- your game.exe
 if proc~=nil then
  RpBtn2.Enabled=true
  openProcess(proc)
  else
  showMessage("Error! The game is not open!")
 end
end

RpBtn2.OnClick=function()
  addresslist=getAddressList()
  CheatEntry1=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Item Drop")
  CheatEntry2=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Room Number Change")
  CheatEntry3=addresslist_getMemoryRecordByDescription(addresslist,"SCRIPT - LOG - Looking At Item")
 if check==true then
  CheatEntry1.Active=true
  CheatEntry2.Active=true
  CheatEntry3.Active=true
  RpBtn2.caption="Hack Enable (is) [ON]"
  showMessage("Hack has been activated.")
  check=false
  else
  CheatEntry1.Active=false
  CheatEntry2.Active=false
  CheatEntry3.Active=false
  RpBtn2.caption="Hack Enable (is) [OFF]"
  showMessage("The hack is not active.")
  check=true
 end
end

RpBtn3.OnClick=function()
  closeCE()
  return cafree()
end

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past


Last edited by AylinCE on Sun Mar 13, 2022 11:39 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
HotPieOnARack
How do I cheat?
Reputation: 0

Joined: 15 Feb 2022
Posts: 7

PostPosted: Sat Mar 12, 2022 1:09 pm    Post subject: Reply with quote

Thank you very much, but the scripts still won't do anything if I run this as a standalone exe Sad

Usually this should write a logfile (to console and to a target location)
Please see the screenshot of the result when I execute the script directly in Cheat Engine.


If I export it as standalone, I can connect the trainer with the app, I can activate the scripts ("Hack has been activated" msg shows) but then nothing happens anymore.


Last edited by HotPieOnARack on Sat Mar 12, 2022 5:06 pm; edited 2 times in total
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1520

PostPosted: Sat Mar 12, 2022 3:09 pm    Post subject: Reply with quote

I think I completed the task.

I think another master on duty who understands asm can take a look at this.

Sorry, I don't use asm encoding. Smile

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
HotPieOnARack
How do I cheat?
Reputation: 0

Joined: 15 Feb 2022
Posts: 7

PostPosted: Sat Mar 12, 2022 5:04 pm    Post subject: Reply with quote

Problem solved:

It's a bug in Cheatengine, but there is a workaround:

If you want to use Lua Codeblocks you have to add the luaclient.dll from the Cheatengine root folder manually.


cheatengine.org/viewtopic.php?t=618886
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