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 Button On/Off

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
KalasWD
Expert Cheater
Reputation: 0

Joined: 29 May 2016
Posts: 237

PostPosted: Tue Jul 11, 2017 3:01 pm    Post subject: Lua Button On/Off Reply with quote

Hello, so I recently learned how to add the Button function to work with my script, I wanted to know how do I add a function when I click the button to turn my script on and off an option to see If the script is on or off, even a sound would be great.

This is my code I use for the Script:

Code:
local tag = sender.Tag;
   if (tag == 0) then
      sender.Tag = 1;
      autoAssemble([[//enable script]])
   else
      sender.Tag = 0
      autoAssemble([[//disable script]])
   end
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 339

Joined: 09 May 2003
Posts: 19899
Location: The netherlands

PostPosted: Tue Jul 11, 2017 3:40 pm    Post subject: Reply with quote

you can put a label on your form and just set the state
e.g: myform.labelname.caption="On"

or use a checkbox where you set the checked state to true if it's on

and for sound you can add a sound use playSound (e.g playSound(findTableFile("Activate")) ) , or even text: speakEnglish("Cheat active")

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
KalasWD
Expert Cheater
Reputation: 0

Joined: 29 May 2016
Posts: 237

PostPosted: Tue Jul 11, 2017 3:46 pm    Post subject: Reply with quote

That's for example a button, OnClick event code:

Code:

function CEButton1Click(sender)
local tag = sender.Tag;
   if (tag == 0) then
      sender.Tag = 1;
      autoAssemble([[
        aobscan(PlayerStatsAOB,00 83 C4 10 D9 87 18 01 00 00)
alloc(newmem,$100,PlayerStatsAOB)

label(code)
label(return)

newmem:

code:
  fld dword ptr [edi+00000118]
  mov [edi+0000010C],(float)37 // BodyTemp
  mov [edi+00000110],(float)70 // HeartRate
  mov [edi+00000118],(float)100 // Stamina
  mov [edi+0000011C],(float)100 // Health
  mov [edi+00000124],(float)100 // Energy
  mov [edi+00000134],(float)100 // BatteryCharge
  mov [edi+00000150],(float)1 // Fullness
  mov [edi+00000154],(float)0 // Thirst
  mov [edi+00000231],0 // IsBloody
  mov [edi+00000232],0 // IsRed
  mov [edi+00000233],0 // IsCold
  jmp return

PlayerStatsAOB+04:
  jmp newmem
  nop
return:
registersymbol(PlayerStatsAOB)
]])
   else
      sender.Tag = 0
      autoAssemble([[
        PlayerStatsAOB+04:
  db D9 87 18 01 00 00

unregistersymbol(PlayerStatsAOB)
dealloc(newmem)
]])
   end
end


where exactly do I add the line you said? the sound for Activated + Di activated

Ok so I know how to add the speakEnglish("Activated"), but when I disable the Script I want it to say Diactivated as well.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 339

Joined: 09 May 2003
Posts: 19899
Location: The netherlands

PostPosted: Tue Jul 11, 2017 3:54 pm    Post subject: Reply with quote

right after the autoAssemble instruction(s). (Not inside the autoAssemble instruction)

for disable you just put speakEnglish("Cheat Disabled") behind the disable autoAssemble

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
KalasWD
Expert Cheater
Reputation: 0

Joined: 29 May 2016
Posts: 237

PostPosted: Tue Jul 11, 2017 3:56 pm    Post subject: Reply with quote

Oh haha awesome, do you perhaps know a good site to learn Lua from just the basics, I use cheat engine to read some codes but It's not really what I'm looking for, maybe a video or in dept text ?
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