View previous topic :: View next topic |
Author |
Message |
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Sun Jun 05, 2022 3:46 pm Post subject: hotkey *temporarily* disable a script? (solved) |
|
|
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 |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Sun Jun 05, 2022 4:05 pm Post subject: |
|
|
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 |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Sun Jun 05, 2022 4:42 pm Post subject: |
|
|
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 |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1053 Location: 0x90
|
Posted: Sun Jun 05, 2022 5:17 pm Post subject: |
|
|
Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg')
|
|
Back to top |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Sun Jun 05, 2022 5:24 pm Post subject: |
|
|
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 |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Sun Jun 05, 2022 6:43 pm Post subject: |
|
|
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 |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Sun Jun 05, 2022 6:53 pm Post subject: |
|
|
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 |
|
|
ParkourPenguin I post too much Reputation: 138
Joined: 06 Jul 2014 Posts: 4275
|
Posted: Sun Jun 05, 2022 7:13 pm Post subject: |
|
|
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 |
|
|
Devon999 Newbie cheater Reputation: 0
Joined: 03 May 2022 Posts: 23
|
Posted: Sun Jun 05, 2022 7:26 pm Post subject: |
|
|
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 |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1053 Location: 0x90
|
Posted: Mon Jun 06, 2022 7:19 am Post subject: |
|
|
ParkourPenguin wrote: |
LeFiXER wrote: | Fix the typo:
local memrec = assert(AddressList.getMemoryRecordByDescription('ggg') | Not a typo
|
My apologies. I stand corrected.
|
|
Back to top |
|
|
|