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 script as trainer

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

Joined: 14 Oct 2023
Posts: 4

PostPosted: Sat Oct 14, 2023 2:14 pm    Post subject: lua script as trainer Reply with quote

hello all together. I am a beginner in cheat Engine and need help.

I take a lua script from a friend for a game. The code is something like this:


monster = 4392

monster1_address = 0x143497C40 + 0x4c
object1_id = readSmallInteger(monster1_address + 0x4) >> 3 & 0x3B
object1_address = 0x143499798 + (2 * object1_id) * 6
writeSmallInteger(monster1_address, monster); writeSmallInteger(object1_address, monster);

All the time i must open it and execute the table. Monster is a value which i can choose by my selfe.

I want make a trainer with cheat engine where i have a Textbox. In the Textbox i can give the number for the monster i want and activate it with a button.

Can anybody tell me how i could do that. Or a tutorial which can help me?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1478

PostPosted: Sun Oct 15, 2023 12:49 pm    Post subject: Reply with quote

Code:

if testForm then testForm.Destroy() testForm=nil end
testForm=createForm()
testEdit1=createEdit(testForm)
testEdit1.Left=10 testEdit1.Top=10
testBtn1=createButton(testForm)
testBtn1.Left=testEdit1.Width + 20
testBtn1.Top=9
testBtn1.Caption="Enable"

testBtn1.OnClick=function()
 if testEdit1.Text=="" then
  print("Monster not found!")
 else
  monster = testEdit1.Text
  monster1_address = 0x143497C40 + 0x4c
  object1_id = readSmallInteger(monster1_address + 0x4) >> 3 & 0x3B
  object1_address = 0x143499798 + (2 * object1_id) * 6
  writeSmallInteger(monster1_address, monster);     
  writeSmallInteger(object1_address, monster);
 end
end


It is a usage example. You can get ideas from this.
Copy the code and click CE >> Table >> Lua Table and paste it there, click the "Execute" button and test the created form.

(If you already know the steps in the description, that's okay.
Details are provided as archives for novices. )

_________________
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
sky88
How do I cheat?
Reputation: 0

Joined: 14 Oct 2023
Posts: 4

PostPosted: Sun Oct 15, 2023 4:12 pm    Post subject: Reply with quote

Thanks its function Smile.

But is boring with this style Very Happy. So i do it with

,,Generate generic trainer lua script from table" and design maually

use a background and
3 edit box name : (CEEdit1,CEEdit2, CEEdit3) and
a button name: (CECustomButton1).

I can have three monsters in the game. But really can not must. So if the boxes are empty so it shall happen nothing. Otherwise i take many ,,Monster not found" Error Very Happy.

But for the first time i use coding only for one editbox

Code:
function CETrainer_CECustomButton1Click(sender)

monster = CEEdit1.Text
  monster1_address = 0x143497C40 + 0x4c
  object1_id = readSmallInteger(monster1_address + 0x4) >> 3 & 0x3B
  object1_address = 0x143499798 + (2 * object1_id) * 6
  writeSmallInteger(monster1_address, monster);     
  writeSmallInteger(object1_address, monster);

end


But take this from trainer:

Error:[string "function CETrainer_CECustomButton1Click(sende..."]:2: attempt to index a nil value (global 'monster')


can you or anybody tell me what my mistake is. This type of coding is still new for me
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1478

PostPosted: Mon Oct 16, 2023 3:53 am    Post subject: Reply with quote

Trainer name >> Edit name >> Text

Code:
monster = CETrainer.CEEdit1.Text


Button name?

Code:
CETrainer_CECustomButton1 -- ?

-- or

CETrainer_CEButton1 -- ?

_________________
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 Mon Oct 16, 2023 10:43 am; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
sky88
How do I cheat?
Reputation: 0

Joined: 14 Oct 2023
Posts: 4

PostPosted: Mon Oct 16, 2023 8:56 am    Post subject: Reply with quote

i did it again. Name is MyBox1,MyBox2,MyBox3,MyButton

if i generate the trainer i take a exe file. But if i want use it after i click on button.

I take this:

Error:[string "function CETrainer_MyButtonClick(sender)
..."]:3: attempt to index a nil value (global 'MyBox1')

so it must be now i think this:

canavar = CETrainer.MyBox1.Text. Where i must put this?



myscreenshot1.gif
 Description:
 Filesize:  104.09 KB
 Viewed:  3169 Time(s)

myscreenshot1.gif


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

Joined: 16 Feb 2017
Posts: 1478

PostPosted: Mon Oct 16, 2023 10:41 am    Post subject: Reply with quote

I apologize, it's my fault.. Sad
Here, change this line of code.

Code:
monster = MyBox1.Text


-- new
Code:
monster = CETrainer.MyBox1.Text

_________________
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
sky88
How do I cheat?
Reputation: 0

Joined: 14 Oct 2023
Posts: 4

PostPosted: Mon Oct 16, 2023 11:47 am    Post subject: Reply with quote

thanksss its function Smile. One last question. I want if the box are empty, the programm should do nothing i mean he should skip the code. How could i do that?
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 35

Joined: 16 Feb 2017
Posts: 1478

PostPosted: Mon Oct 16, 2023 1:27 pm    Post subject: Reply with quote

Code:

function CETrainer_MyButtonClick(sender)
if CETrainer.MyBox1.Text=="" then
   showMessage("Monster not found!")
 else
  monster = CETrainer.MyBox1.Text
  monster1_address = 0x143497C40 + 0x4c
  object1_id = readSmallInteger(monster1_address + 0x4) >> 3 & 0x3B
  object1_address = 0x143499798 + (2 * object1_id) * 6
  writeSmallInteger(monster1_address, monster);     
  writeSmallInteger(object1_address, monster);
 end
end


Text check : Numbers!

Code:

CETrainer.MyBox1.OnChange=function(sender)
 nr = tonumber(sender.Text)
 if nr==nil then
  showMessage("Just numbers!")
  sender.Text=""
 end
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
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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