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 


Lua Script [I want to turn ON/OFF]

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

Joined: 09 May 2020
Posts: 13

PostPosted: Sun May 10, 2020 8:16 pm    Post subject: Lua Script [I want to turn ON/OFF] Reply with quote

I have a lua script. I want it to be active when I press the Delete key. And if you press the Delete key again, if it is active, get deactivated. Is this possible?

So when I press Delete, "pointer_on" will work. When I press Delete button for the second time, "pointer_off" will work if it is active. Do you understand what I mean? So I want to make On / Off with a single button.


Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="18">
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>

x = getMainForm()
x.WindowState = 'wsMinimized'

function myattach(timer)
  if getProcessIDFromProcessName("test.exe") ~= nil then
    object_destroy(timer)
    openProcess("test.exe")
  end
end

t=createTimer(nil);
timer_setInterval(t,10)
timer_onTimer(t,myattach)

function WriteSignatures(targetSignature, overrideSignature, codePage)
  local byteLine = overrideSignature:gsub("%w+", "0x%0,"):sub(1,-2)
  local results = AOBScan(targetSignature, codePage)
  if (results == nil) then  return end
  for i = 0, results.Count-1 do
    local address = getAddress(results.getString(i))
    local lineCode = 'writeBytes('..address..','.. byteLine..')'
    loadstring(lineCode)()
  end
  results.destroy()
end

function pointer_on()
  local targetSignature   = '54 73 6C 52 65 63 6F 69 6C 43 6F 6D 70 6F 6E 65 6E 74'
  local overrideSignature = '91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91'
  local codePage = '-X*C*W'
  WriteSignatures(targetSignature, overrideSignature, codePage)
end

function pointer_off()
  local targetSignature   = '91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91'
  local overrideSignature = '54 73 6C 52 65 63 6F 69 6C 43 6F 6D 70 6F 6E 65 6E 74'
  local codePage = '-X*C*W'
  WriteSignatures(targetSignature, overrideSignature, codePage)
end

createHotkey(pointer_on, VK_DELETE)
createHotkey(pointer_off, VK_DELETE)
</LuaScript>
</CheatTable>
Back to top
View user's profile Send private message
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1516

PostPosted: Mon May 11, 2020 12:47 am    Post subject: Reply with quote

Code:
local state = 0

function pointer_on()
state = 1
  local targetSignature   = '54 73 6C 52 65 63 6F 69 6C 43 6F 6D 70 6F 6E 65 6E 74'
  local overrideSignature = '91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91'
  local codePage = '-X*C*W'
  WriteSignatures(targetSignature, overrideSignature, codePage)
end

function pointer_off()
state = 0
  local targetSignature   = '91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91 91'
  local overrideSignature = '54 73 6C 52 65 63 6F 69 6C 43 6F 6D 70 6F 6E 65 6E 74'
  local codePage = '-X*C*W'
  WriteSignatures(targetSignature, overrideSignature, codePage)
end

function pointer_on_off()
if state==0 then
pointer_on()
else
pointer_off()
end
end

createHotkey(pointer_on_off, VK_DELETE)

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
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