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 


hotkey *temporarily* disable a script? (solved)

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
Devon999
Newbie cheater
Reputation: 0

Joined: 03 May 2022
Posts: 23

PostPosted: Sun Jun 05, 2022 3:46 pm    Post subject: hotkey *temporarily* disable a script? (solved) Reply with quote

I named an auto assembler script XYZ which I enable and leave turned on 99% of time, but there are instances I would like to push a hotkey and temporarily disable script XYZ for exactly 5 seconds while I continue playing. As of now I have to disable it with a hotkey then re-enable it myself again once I know 5 secs passed but the problem is that it's easy for me to mess up the timing on re-enabling it because I'm also in mid-play of a challenging part of game by then.

Can CE automate it so hotkey disables script XYZ for only 5 secs and if so how do I program that type of hotkey?


Last edited by Devon999 on Sun Jun 05, 2022 7:27 pm; edited 1 time in total
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sun Jun 05, 2022 4:05 pm    Post subject: Reply with quote

Code:
local memrec = assert(AddressList.getMemoryRecordByDescription'My Script')

if hk then hk.destroy(); hk = nil end
hk = createHotkey(function()
  if memrec.Active then
    memrec.Active = false
    createTimer(5000, function()
      memrec.Active = true
    end)
  end
end, VK_MENU, VK_F4)

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Devon999
Newbie cheater
Reputation: 0

Joined: 03 May 2022
Posts: 23

PostPosted: Sun Jun 05, 2022 4:42 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Code:
local memrec = assert(AddressList.getMemoryRecordByDescription'My Script')

if hk then hk.destroy(); hk = nil end
hk = createHotkey(function()
  if memrec.Active then
    memrec.Active = false
    createTimer(5000, function()
      memrec.Active = true
    end)
  end
end, VK_MENU, VK_F4)


When saving this as a new script I get an error not all code is injectable and the reason is: assertation failed.

This is the line w/ the error
Code:
local memrec = assert(AddressList.getMemoryRecordByDescription'ggg')

And ggg is the name of the script I want it to disable for 5 secs, did I add the name in wrong?
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Sun Jun 05, 2022 5:17 pm    Post subject: Reply with quote

Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')
Back to top
View user's profile Send private message
Devon999
Newbie cheater
Reputation: 0

Joined: 03 May 2022
Posts: 23

PostPosted: Sun Jun 05, 2022 5:24 pm    Post subject: Reply with quote

LeFiXER wrote:
Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')


Then new error is created because now it wants a second closing parenthesis somewhere. When I tried adding another one it goes back to the assertion failed error.

For example your recommended fix:
Code:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')

creates the error wanting a new second closing parenthesis

so then when I tried adding another like this, it goes back to the assertion failed error:
Code:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg'))
*second ) added at very end
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sun Jun 05, 2022 6:43 pm    Post subject: Reply with quote

Devon999 wrote:
And ggg is the name of the script I want it to disable for 5 secs, did I add the name in wrong?
Yes.

If you're putting that in the script you want to disable / enable, CE sets a local variable "memrec" in {$lua} blocks for you to use:
Code:
[ENABLE]
{$lua}
if syntaxcheck then return end

if hk then hk.destroy(); hk = nil end
hk = createHotkey(function()
  if memrec.Active then
    memrec.Active = false
    createTimer(5000, function()
      memrec.Active = true
    end)
  end
end, VK_MENU, VK_F4)

return ''
{$asm}
...

LeFiXER wrote:
Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')
Not a typo
Code:
-- these are equivalent function calls
print'yes'
print('yes')

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Devon999
Newbie cheater
Reputation: 0

Joined: 03 May 2022
Posts: 23

PostPosted: Sun Jun 05, 2022 6:53 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Devon999 wrote:
And ggg is the name of the script I want it to disable for 5 secs, did I add the name in wrong?
Yes.

If you're putting that in the script you want to disable / enable, CE sets a local variable "memrec" in {$lua} blocks for you to use:
Code:
[ENABLE]
{$lua}
if syntaxcheck then return end

if hk then hk.destroy(); hk = nil end
hk = createHotkey(function()
  if memrec.Active then
    memrec.Active = false
    createTimer(5000, function()
      memrec.Active = true
    end)
  end
end, VK_MENU, VK_F4)

return ''
{$asm}
...

LeFiXER wrote:
Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')
Not a typo
Code:
-- these are equivalent function calls
print'yes'
print('yes')


I've gotten it to work when I add code into the same script that gets disables and re enabled but what I am trying is to have a separate script that is solely used to disable a different script. So I think the first example you gave earlier was closer but can't get the assert line/issue worked out...? But yeah it's 2 different scripts. The new one I'm making from this thread just exists to disable the other script which in my test earlier I named ggg and tried using the new script to disable the ggg script but got assertion error. ggg is the name of the external target that I want to disable for 5 seconds.

My goal is to not have to add code into the target script that will be disabled for 5 seconds, if possible.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 138

Joined: 06 Jul 2014
Posts: 4275

PostPosted: Sun Jun 05, 2022 7:13 pm    Post subject: Reply with quote

Devon999 wrote:
The new one I'm making from this thread
You shouldn't access the GUI (AddressList, timers, hotkeys...) in a separate thread. Use `synchronize` if you must use a separate thread. This can also be caused by executing a memory record asynchronously (right click menu).

If that's not it, I don't know what to tell you other than "ggg" isn't the name of the script. `AddressList.getMemoryRecordByDescription` looks through every memory record and returns the first one it finds with the specified description. Maybe it has leading or trailing spaces?

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Devon999
Newbie cheater
Reputation: 0

Joined: 03 May 2022
Posts: 23

PostPosted: Sun Jun 05, 2022 7:26 pm    Post subject: Reply with quote

ParkourPenguin wrote:

If that's not it, I don't know what to tell you other than "ggg" isn't the name of the script. `AddressList.getMemoryRecordByDescription` looks through every memory record and returns the first one it finds with the specified description. Maybe it has leading or trailing spaces?


That was it. I don't know what was wrong with the name but just to be sure I re-made it with the same name and now it's working. My only guess could be maybe because it was colored red originally? But now I colored the new one's name red and it's still working fine even when its colored so idk. Thx for the help.
Back to top
View user's profile Send private message
LeFiXER
Grandmaster Cheater Supreme
Reputation: 20

Joined: 02 Sep 2011
Posts: 1053
Location: 0x90

PostPosted: Mon Jun 06, 2022 7:19 am    Post subject: Reply with quote

ParkourPenguin wrote:

LeFiXER wrote:
Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')
Not a typo


My apologies. I stand corrected.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking 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