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 


[Solved]Update tcheat components

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Y.A.K.E
Advanced Cheater
Reputation: 0

Joined: 15 Jul 2019
Posts: 56

PostPosted: Sun Oct 01, 2023 12:23 am    Post subject: [Solved]Update tcheat components Reply with quote

trainer cannot update the tchat component in real time.



cheat0 F1 Init (--option : moDeactivateChildrenAsWell)
cheat1 F2 inf. HP
cheat2 F3 inf. MP





I have activated all of them.
When I press F1 to deactivate 'Init'.
All memory records are deactivated.
But the trainer has not been updated.



test table:
Code:

<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"Init    (--option : moDeactivateChildrenAsWell) "</Description>
      <Options moDeactivateChildrenAsWell="1"/>
      <LastState/>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>{$lua}
[ENABLE]
_G['init']=1
[DISABLE]
_G['init']=0
</AssemblerScript>
      <Hotkeys>
        <Hotkey>
          <Action>Toggle Activation</Action>
          <Keys>
            <Key>112</Key>
          </Keys>
          <ID>0</ID>
          <ActivateSound>Activate</ActivateSound>
          <DeactivateSound>Deactivate</DeactivateSound>
        </Hotkey>
      </Hotkeys>
      <CheatEntries>
        <CheatEntry>
          <ID>1</ID>
          <Description>"Inf. HP"</Description>
          <LastState/>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>{$lua}
[ENABLE]
print('+ inf. hp')
[DISABLE]
print('- inf. hp')
</AssemblerScript>
          <Hotkeys>
            <Hotkey>
              <Action>Toggle Activation</Action>
              <Keys>
                <Key>113</Key>
              </Keys>
              <ID>0</ID>
              <ActivateSound>Activate</ActivateSound>
              <DeactivateSound>Deactivate</DeactivateSound>
            </Hotkey>
          </Hotkeys>
        </CheatEntry>
        <CheatEntry>
          <ID>2</ID>
          <Description>"Inf. MP"</Description>
          <LastState/>
          <VariableType>Auto Assembler Script</VariableType>
          <AssemblerScript>{$lua}
[ENABLE]
print('+ inf. mp')
[DISABLE]
print('- inf. mp')
</AssemblerScript>
          <Hotkeys>
            <Hotkey>
              <Action>Toggle Activation</Action>
              <Keys>
                <Key>114</Key>
              </Keys>
              <ID>0</ID>
              <ActivateSound>Activate</ActivateSound>
              <DeactivateSound>Deactivate</DeactivateSound>
            </Hotkey>
          </Hotkeys>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
</CheatTable>








I try usee the timer component, but it not working.



Code:

function CETrainer_CETimer1Timer(sender)
   addresslist=getAddressList()
   local t_index = 0
   for i = 0, addresslist.getCount()-1 do
      local tmp_mem = addresslist.getMemoryRecord(i)
      local tmp_key = tmp_mem.getHotkeyByID(0)  -- how to get  getHotkeyByID(1) getHotkeyByID(n)
         if tmp_key ~= nil then
            local cheat= CETrainer.findComponentByName("CHEAT" .. t_index)
            cheat.setActive(tmp_mem.Active)
            t_index = t_index + 1
         end
   end
end



Screenshot 2023-10-01 140046.png
 Description:
deactivate 'Init'
 Filesize:  39.54 KB
 Viewed:  2396 Time(s)

Screenshot 2023-10-01 140046.png



Screenshot 2023-10-01 135726.png
 Description:
activated all
 Filesize:  24.98 KB
 Viewed:  2396 Time(s)

Screenshot 2023-10-01 135726.png




Last edited by Y.A.K.E on Wed Oct 11, 2023 12:06 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 471

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

PostPosted: Sun Oct 01, 2023 12:49 am    Post subject: Reply with quote

instead of tcheat it's better to use 2 labels and adjust the color manually on activate/deactovate

anyhow, does the timer even run and what interval? (try adding some prints to see if it works)

_________________
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
lontongmalam
Newbie cheater
Reputation: 0

Joined: 13 Apr 2022
Posts: 17

PostPosted: Thu Oct 12, 2023 10:42 am    Post subject: Reply with quote

Try this

Code:

function createCustomTimer(callback)
   local t = createTimer()
   t.Interval = 200
   t.onTimer = function()
      if readInteger(process) == nil then -- destroy if no process
         if t ~= nil then
            t.Enabled = false
            t.destroy()
            t = nil
         end
         getAddressList().disableAllWithoutExecute()
         process = nil
         return
      end
    if callback ~= nil then
      callback()
      t.Interval = 500 -- slow down
      end
   end
   t.Enabled = true
end

function CETrainer_CETimer1Timer(sender)
   for i = 0, getAddressList().getCount()-1 do
      local mr = getAddressList().getMemoryRecord(i)
      local hk = mr.getHotkeyByID(0)  -- how to get  getHotkeyByID(1) getHotkeyByID(n)
      if hk ~= nil then
         local cheat = CETrainer.findComponentByName("CHEAT" .. mr.Index)
         if cheat ~= nil then
            cheat.setActive(mr.Active)
         end
      end
   end
end


-- Use Auto Attach or manual execution
createCustomTimer(CETrainer_CETimer1Timer)



Or this


Code:

function createRecordCustomAction(mr)
   if mr == nil then return end
   
   local hk = mr.getHotkeyByID(0)  -- how to get  getHotkeyByID(1) getHotkeyByID(n)   
   if hk ~= nil then
      local cheat = CETrainer.findComponentByName("CHEAT" .. mr.Index)
      if cheat ~= nil then
         mr.OnActivate = function(mr,before,currentstate)         
            cheat.setActive(mr.Active)
            return true
         end
         
         mr.OnDeactivate = function(mr,before,currentstate)
            cheat.setActive(mr.Active)      
            return true
         end
      end
   end
end

function CETrainer_CETimer1Timer(sender)
   for i = 0, getAddressList().getCount()-1 do
      local mr = getAddressList().getMemoryRecord(i)
      createRecordCustomAction(mr)
   end
end

-- Use Auto Attach or manual execution
CETrainer_CETimer1Timer()
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