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 


Disable/enable ASM with hotkey?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Foxculated
Newbie cheater
Reputation: 0

Joined: 26 Mar 2020
Posts: 11

PostPosted: Fri Apr 03, 2020 1:03 pm    Post subject: Disable/enable ASM with hotkey? Reply with quote

Hello,
So i managed to get it working when pressing F1 once, but how can i disable it when i press F1 again?

Code:
function Antibounce(sender)
UDF1.CELabel8.Font.Color = 0x00FEEC4B
  autoAssemble [[
  -- assemble code --
  {$ASM}
  ]]
end
createHotkey(Antibounce, VK_F1)
Confused
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Fri Apr 03, 2020 1:13 pm    Post subject: Reply with quote

use the 2nd parameter that autoAssemble returns as 2nd parameter for autoAssemble to run the [disable] script
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
Foxculated
Newbie cheater
Reputation: 0

Joined: 26 Mar 2020
Posts: 11

PostPosted: Fri Apr 03, 2020 1:17 pm    Post subject: Reply with quote

Dark Byte wrote:
use the 2nd parameter that autoAssemble returns as 2nd parameter for autoAssemble to run the [disable] script


so how can i update the label then? but i quite didnt understand you
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Fri Apr 03, 2020 3:34 pm    Post subject: Reply with quote

something like:
Code:

local script=[[
[enable]
  -- assemble code --
  {$ASM}

[disable]
  -- disable code --
]]

local disableInfo
function Antibounce(sender)
  if disableInfo==nil then
    UDF1.CELabel8.Font.Color = 0x00FEEC4B
    result, disableInfo=autoAssemble(script)
  else
    UDF1.CELabel8.Font.Color = 0x004BECFE
    autoAssemble(script,disableInfo)
    disableInfo=nil
  end
 
end
createHotkey(Antibounce, VK_F1)

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Apr 03, 2020 4:14 pm    Post subject: Reply with quote

@Foxculated, maybe this will be clearer for you:
Code:
AntibounceScript = [[
[ENABLE]
//your script - enable part

[DISABLE]
//your script - disable part

]]
-- global Lua variables for this cheat: AntibounceScriptEnabled, AntibounceScriptDisableInfo

function Antibounce(sender)
  local succeded
  local secondReturnValue -- can have DisableInfo or errorText

  if not AntibounceScriptEnabled then  --script not enabled
    --enable it
    succeded,secondReturnValue = autoAssemble(AntibounceScript)
    -- if succeded, secondReturnValue now contains DisableInfo
    if succeded then
      AntibounceScriptEnabled = true
      AntibounceScriptDisableInfo = secondReturnValue
      UDF1.CELabel8.Font.Color = 0x00FEEC4B -- cyan (cheat enabled)
    end
  else
    --disable it
    succeded,secondReturnValue = autoAssemble(AntibounceScript,AntibounceScriptDisableInfo)
    if succeded then
      AntibounceScriptEnabled = false
      UDF1.CELabel8.Font.Color = 0 -- black (cheat disabled)
    end
  end

  if not succeded then
     UDF1.CELabel8.Font.Color = 0x000000FF -- red (script error)
     showMessage('Antibounce'..'\r\n'..secondReturnValue) -- show error
  end

end

if AntibounceHotkey~=nil then AntibounceHotkey.destroy() AntibounceHotkey=nil end -- just in case Lua script is executed multiple times
AntibounceHotkey = createHotkey(Antibounce, VK_F1)

_________________
Back to top
View user's profile Send private message MSN Messenger
Foxculated
Newbie cheater
Reputation: 0

Joined: 26 Mar 2020
Posts: 11

PostPosted: Sat Apr 04, 2020 4:45 am    Post subject: Reply with quote

Thanks. @Dark Byte's version worked.
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