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 


Enable/Disable a lua script via the cheat table

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

Joined: 19 Jun 2013
Posts: 12

PostPosted: Tue Jun 03, 2014 1:35 pm    Post subject: Enable/Disable a lua script via the cheat table Reply with quote

so a while ago I asked for a code for health regen
Code:
function CheckHealth(t)
  local al=getAddressList()
  local memrec=al.getMemoryRecordByDescription("Health")
  if memrec~=nil then
    if tonumber(memrec.Value)<100 then
      memrec.Value=memrec.Value+1
    end
  end
end

t=createTimer(nil)
t.OnTimer=CheckHealth
t.Interval=1000 --every 1 second
t.Enabled=true

unfortunately I can only run this once, so it forces me to use it the rest of the game, I've never seen an option to "add to cheat table" so I'm not particularly sure how to do it
in addition, once I click execute script, the only way to stop the script is to close out cheat engine and the game to terminate everything from memory, which is incredibly frustrating


Last edited by Renard10177 on Tue Jun 03, 2014 2:04 pm; edited 1 time in total
Back to top
View user's profile Send private message
daspamer
Grandmaster Cheater Supreme
Reputation: 54

Joined: 13 Sep 2011
Posts: 1588

PostPosted: Tue Jun 03, 2014 1:45 pm    Post subject: Reply with quote

execute
Code:
t.destroy();

to stop it.

_________________
I'm rusty and getting older, help me re-learn lua.
Back to top
View user's profile Send private message Visit poster's website
Renard10177
Newbie cheater
Reputation: 0

Joined: 19 Jun 2013
Posts: 12

PostPosted: Tue Jun 03, 2014 1:47 pm    Post subject: Reply with quote

DaSpamer wrote:
execute
Code:
t.destroy();

to stop it.

that's usefull to know but it still doesn't give me the option to add it to the cheat table to enable/disable the script
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Jun 03, 2014 2:34 pm    Post subject: Reply with quote

put this in the lua part of the cheat table (table->show cheat table lua script) and execute it (when the table is loaded and it asks, always allow)
Code:

function CheckHealth(t)
  local al=getAddressList()
  local memrec=al.getMemoryRecordByDescription("Health")
  if memrec~=nil then
    if tonumber(memrec.Value)<100 then
      memrec.Value=memrec.Value+1
    end
  end
end

function ActivateTimer()
  t=createTimer(nil)
  t.OnTimer=CheckHealth
  t.Interval=1000 --every 1 second
  t.Enabled=true
end


and add an aa script with this code:
Code:

[enable]
luacall(ActivateTimer())
[disable]
luacall(t.destroy())

_________________
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
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