<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="15">
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"script (lua_state hijack)"</Description>
      <Color>80000008</Color>
      <VariableType>Auto Assembler Script</VariableType>
      <AssemblerScript>[ENABLE]
//code from here to '[DISABLE]' will be used to enable the cheat
alloc(newmem,2048) //2kb should be enough
label(returnhere)
label(doOurLoadString)

label(bForceLoadString)
registersymbol(bForceLoadString)
label(command)
registersymbol(command)

newmem:
// mov ecx,[esp+04]
// mov eax,[ecx+08]
// sub eax,[ecx+0C]
sar eax,04

cmp [bForceLoadString],0
jne doOurLoadString
ret

doOurLoadString:
mov [bForceLoadString],0

push command
push ecx
call lua5.1-32.luaL_loadstring
add esp,08
ret

bForceLoadString:
dd 0
command:
db 'playerStats.Health = 100;',0

"lua5.1-32.dll"+124A:
jmp newmem
returnhere:

[DISABLE]
dealloc(newmem)
"lua5.1-32.dll"+124A:
sar eax,04
ret 
int 3 
//Alt: db C1 F8 04 C3 CC

unregistersymbol(bForceLoadString)
unregistersymbol(command)
</AssemblerScript>
    </CheatEntry>
    <CheatEntry>
      <ID>1</ID>
      <Description>"set to 1 to enable"</Description>
      <Color>80000008</Color>
      <VariableType>4 Bytes</VariableType>
      <Address>bForceLoadString</Address>
    </CheatEntry>
    <CheatEntry>
      <ID>2</ID>
      <Description>"current command"</Description>
      <Color>80000008</Color>
      <VariableType>String</VariableType>
      <Length>200</Length>
      <Unicode>0</Unicode>
      <ZeroTerminate>1</ZeroTerminate>
      <Address>command</Address>
    </CheatEntry>
  </CheatEntries>
  <UserdefinedSymbols/>
  <LuaScript>

openProcess('cheatengine-i386.exe')  
  
playerStats = {}
playerStats.Health = 30

if timer~=nil then object_destroy(timer);timer=nil;end

timer = createTimer(nil,true)
timer.Interval = 1000
timer.OnTimer = function (sender)
                  if playerStats.Health &gt;=100 then
                    sender.Enabled = false
                    showMessage('success')
                  end
                end
</LuaScript>
</CheatTable>
