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 


How to check Value in lua ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Sting9x
Expert Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 110

PostPosted: Mon May 14, 2018 2:43 am    Post subject: How to check Value in lua ? Reply with quote

My idea is like this :
Is there a way to turn on trainer
I will click button it will check value = 0 trainer will turn on
if value is not correct = 0 trainer will turn off
How do I do this?
Back to top
View user's profile Send private message
Profound_Darkness
Newbie cheater
Reputation: 0

Joined: 21 May 2015
Posts: 16

PostPosted: Mon May 14, 2018 4:10 pm    Post subject: Reply with quote

Hmm... I remember reading something a while ago about a self activating/deactivating cheat...

Managed to find the thread but it's a bit long and bounces around what you are interested in so I'll share what I distilled out of it for myself with a twist towards what you seem to want. This is a bit of a skeleton.

In a cheat table script
Code:

[Enable]
{$Lua}
function checkValue(sender)
  local value
  --Code to get the value that is to be tested.
  if value ~= 0 then
    getAddressList().getMemoryRecordByID(31).Active = false
    --You need to get the ID of the script and replace the 31 with that ID.
  end
end

local value
--code to get 'value'
if value ~= 0 then return 0 end --if the value is not 0 don't enable this cheat

--Any other lua code you might have if this cheat is enabled.

--Since there could be other elements that cause the cheat to bail in Lua I've put the timer code down here.
watchTimer = createTimer(nil)
watchTimer.OnTimer=checkValue
watchTimer.interval=100
watchTimer.Enabled = true

{$asm}
//any asm code you might have if the cheat is enabled.

[Disable]
{$Lua}
watchTimer.Enabled = false --this line probably unnecessary.
watchTimer.destroy()

--Any other Lua disable code...
{$asm}
//any asm code for disabling the cheat.


Regarding getting the ID. One way to do this is to open the cheat table file in a text editor, search for the name of the script (helps if it's unique), and the ID is right there above the description (what you searched for). Another is to have some temporary lua code which will iterate over each item in the list and print it's name and ID out... Leaving that as an exercise.
Back to top
View user's profile Send private message
Sting9x
Expert Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 110

PostPosted: Mon May 14, 2018 6:12 pm    Post subject: Reply with quote

Profound_Darkness wrote:
Hmm... I remember reading something a while ago about a self activating/deactivating cheat...

Managed to find the thread but it's a bit long and bounces around what you are interested in so I'll share what I distilled out of it for myself with a twist towards what you seem to want. This is a bit of a skeleton.

In a cheat table script
Code:

[Enable]
{$Lua}
function checkValue(sender)
  local value
  --Code to get the value that is to be tested.
  if value ~= 0 then
    getAddressList().getMemoryRecordByID(31).Active = false
    --You need to get the ID of the script and replace the 31 with that ID.
  end
end

local value
--code to get 'value'
if value ~= 0 then return 0 end --if the value is not 0 don't enable this cheat

--Any other lua code you might have if this cheat is enabled.

--Since there could be other elements that cause the cheat to bail in Lua I've put the timer code down here.
watchTimer = createTimer(nil)
watchTimer.OnTimer=checkValue
watchTimer.interval=100
watchTimer.Enabled = true

{$asm}
//any asm code you might have if the cheat is enabled.

[Disable]
{$Lua}
watchTimer.Enabled = false --this line probably unnecessary.
watchTimer.destroy()

--Any other Lua disable code...
{$asm}
//any asm code for disabling the cheat.


Regarding getting the ID. One way to do this is to open the cheat table file in a text editor, search for the name of the script (helps if it's unique), and the ID is right there above the description (what you searched for). Another is to have some temporary lua code which will iterate over each item in the list and print it's name and ID out... Leaving that as an exercise.

Thanks you , working Razz Razz Razz
Back to top
View user's profile Send private message
Sting9x
Expert Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 110

PostPosted: Tue May 15, 2018 3:10 am    Post subject: Reply with quote

Profound_Darkness wrote:
Hmm... I remember reading something a while ago about a self activating/deactivating cheat...

Managed to find the thread but it's a bit long and bounces around what you are interested in so I'll share what I distilled out of it for myself with a twist towards what you seem to want. This is a bit of a skeleton.

In a cheat table script
Code:

[Enable]
{$Lua}
function checkValue(sender)
  local value
  --Code to get the value that is to be tested.
  if value ~= 0 then
    getAddressList().getMemoryRecordByID(31).Active = false
    --You need to get the ID of the script and replace the 31 with that ID.
  end
end

local value
--code to get 'value'
if value ~= 0 then return 0 end --if the value is not 0 don't enable this cheat

--Any other lua code you might have if this cheat is enabled.

--Since there could be other elements that cause the cheat to bail in Lua I've put the timer code down here.
watchTimer = createTimer(nil)
watchTimer.OnTimer=checkValue
watchTimer.interval=100
watchTimer.Enabled = true

{$asm}
//any asm code you might have if the cheat is enabled.

[Disable]
{$Lua}
watchTimer.Enabled = false --this line probably unnecessary.
watchTimer.destroy()

--Any other Lua disable code...
{$asm}
//any asm code for disabling the cheat.


Regarding getting the ID. One way to do this is to open the cheat table file in a text editor, search for the name of the script (helps if it's unique), and the ID is right there above the description (what you searched for). Another is to have some temporary lua code which will iterate over each item in the list and print it's name and ID out... Leaving that as an exercise.

It looks like it does not work as expected Sad
Can you be clearer?
Back to top
View user's profile Send private message
Sting9x
Expert Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 110

PostPosted: Wed May 16, 2018 10:09 am    Post subject: Reply with quote

Help me please Sad
Back to top
View user's profile Send private message
Corroder
Grandmaster Cheater
Reputation: 17

Joined: 10 Apr 2015
Posts: 656

PostPosted: Wed May 16, 2018 6:03 pm    Post subject: Reply with quote

Code:
function CheckValue(t)
  local al=getAddressList()
  local memrec=al.getMemoryRecordByDescription("ok")
  if memrec~=nil then
    memrec.Active = true
    if tonumber(memrec.Value) ~= 0 then
      showMessage("ERROR")
      closeCE()
      return caFree
    end
  end
end

function ActivateTimer()
  t=createTimer(nil)
  t.OnTimer=CheckValue
  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())

_________________
Singapore Sling + Johnnie Walker + Some Peanuts....


Last edited by Corroder on Thu May 17, 2018 5:51 am; edited 1 time in total
Back to top
View user's profile Send private message
Sting9x
Expert Cheater
Reputation: 0

Joined: 27 Jul 2016
Posts: 110

PostPosted: Thu May 17, 2018 3:36 am    Post subject: Reply with quote

Corroder wrote:
Code:
function CheckValue(t)
  local al=getAddressList()
  local memrec=al.getMemoryRecordByDescription("ok")
  if memrec~=nil then
    memrec.Active = true
    if tonumber(memrec.Value) ~= 0 then
      showMessage("ERROR")
      closeCE()
      return caFree
    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())

Tks u , working , you are great Very Happy
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