|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
dario3star Newbie cheater Reputation: 0
Joined: 14 Dec 2020 Posts: 23
|
Posted: Thu Sep 22, 2022 8:20 am Post subject: Auto Change Value using AAscript with lua. Need help. |
|
|
I have 1 cheat table, needs automation like auto change value every 10 seconds.
Default value is 0
after 10 seconds, should change to 1
after 10 seconds, should change to 2
after 10 seconds, back to 0 value.
Then always auto repeat the cycle. If i uncheck the script, it should stop the timer.
I don't want to use 'sleep' because it freezes the CE while onsleep.
also uses getMemoryRecordByDescription.
Thank you guys <3
|
|
Back to top |
|
|
LeFiXER Grandmaster Cheater Supreme Reputation: 20
Joined: 02 Sep 2011 Posts: 1053 Location: 0x90
|
Posted: Thu Sep 22, 2022 8:39 am Post subject: |
|
|
This will do the job:
Code: |
if t then t.destroy(); t = nil end
counter = 0
state = false
function getScript(description)
local mr = AddressList.getMemoryRecordByDescription(description)
if mr ~= nil then
return mr
end
end
myscript = getScript('my_script_description')
t = createTimer(getMainForm())
t.Interval = 1000
t.OnTimer = function ()
t.Enabled = state
if state == false then return end
counter = counter + 1
if counter == 10 then myscript.value = '1' end
if counter == 20 then myscript.value = '2' end
if counter == 30 then
myscript.value = '0'
counter = 0
end
end
|
|
|
Back to top |
|
|
dario3star Newbie cheater Reputation: 0
Joined: 14 Dec 2020 Posts: 23
|
|
Back to top |
|
|
panraven Grandmaster Cheater Reputation: 54
Joined: 01 Oct 2008 Posts: 941
|
Posted: Fri Sep 23, 2022 7:35 pm Post subject: |
|
|
May try this.
You can enable Async of the running memory record to avoid freeze.
The first part of the following aa script will force Async of the script mr automatically.
The second part is a sample script to DISABLE the infinite loop by uncheck the Async,ie.
<RIGHT-CLICK the mr and uncheck the Async tick mark>.
Try adapt you code inside the while loop,eg.
-- get target_mr -> m
-- for i,v in ipairs{0,1,2} do m.Value = v ; if memrec.Async then sleep(10000)end end
copy paste to the memory record panel to test
Code: |
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
<CheatEntries>
<CheatEntry>
<ID>0</ID>
<Description>"test async loop"</Description>
<LastState/>
<VariableType>Auto Assembler Script</VariableType>
<AssemblerScript>{$lua}
local cnt, mr, wantAsync = 0, memrec, true -- false if force not async
if not syntaxcheck and wantAsync~=mr.Async then
synchronize(createTimer,1,function()mr.Async = wantAsync; mr.Active = not mr.Active end)
error'reset'
end
-- test code, stop while loop by Disabling Async
local mr, cnt = memrec, 0
while not syntaxcheck and mr.Async do
cnt, mr.Description = cnt+1, 'running '..(not mr.Active and 'ENABLing ' or 'DISABLing ')..cnt
sleep(500)
end
{$asm}
/// aa codes
[ENABLE]
[DISABLE]
</AssemblerScript>
</CheatEntry>
</CheatEntries>
</CheatTable>
|
raw version
Code: |
{$lua}
local cnt, mr, wantAsync = 0, memrec, true -- false if force not async
if not syntaxcheck and wantAsync~=mr.Async then
synchronize(createTimer,1,function()mr.Async = wantAsync; mr.Active = not mr.Active end)
error'reset'
end
-- test code, stop while loop by Disabling Async
local mr, cnt = memrec, 0
while not syntaxcheck and mr.Async do
cnt, mr.Description = cnt+1, 'running '..(not mr.Active and 'ENABLing ' or 'DISABLing ')..cnt
sleep(500)
end
{$asm}
|
_________________
- Retarded. |
|
Back to top |
|
|
AylinCE Grandmaster Cheater Supreme Reputation: 31
Joined: 16 Feb 2017 Posts: 1234
|
Posted: Sat Sep 24, 2022 3:53 am Post subject: |
|
|
Code: |
[ENABLE]
{$lua}
-- if syntaxcheck then return end
if timerFlash then timerFlash.Destroy() timerFlash = nil end
myscript = AddressList.getMemoryRecordByDescription("SLCTR")
counter = 0
timerFlash = createTimer()
timerFlash.Interval = 500
timerFlash.OnTimer = function ()
counter = tonumber(counter) + 1
if counter == 1 then myscript.value = 0 end
if counter == 2 then myscript.value = 4 end
if counter == 3 then myscript.value = 5 end
if counter == 4 then myscript.value = 7
counter = 0
end
end
{$asm}
[DISABLE]
{$lua}
if timerFlash then timerFlash.Destroy() timerFlash = nil end
|
_________________
|
|
Back to top |
|
|
|
|
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
|
|