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 


Timer in Lua script.
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu Feb 25, 2016 1:40 am    Post subject: Timer in Lua script. Reply with quote

Hi there. I would like to know if I use timer in the right way, here are the codes, thanks a lot:

Code:

function myTimer()
  print "1"
end

tmer = createTimer(nil)
timer_onTimer(tmer,myTimer)
timer_setInterval(tmer, 1000)
timer_setEnabled(tmer, true)


and

Code:

count = 0

function myTimer()
  if count < 10 then
    count = count + 1
    print "running"
  else
    timer_setEnabled(tmer, false)
    print "stopped"
  end
end

tmer = createTimer(nil)
timer_onTimer(tmer,myTimer)
timer_setInterval(tmer, 1000)
timer_setEnabled(tmer, true)


I also used the following timer script in Lua. However, I couldn't not stop the timer, the "showMessage" kept popping up....
Code:

counter = 0

local function myTimer1()
  counter = counter + 1
  if counter < 1 then
  else
    timer_setEnabled(tmer,false)
    getAddressList().getMemoryRecordByDescription('General').Active=true
    getAddressList().getMemoryRecordByDescription('Change1').Active=true
    getAddressList().getMemoryRecordByDescription('Change2').Active=true
    showMessage("Stop") <---- This message keeps popping up even after I timer_setEnabled to false....
end

tmer1 = createTimer()
timer_setInterval(tmer1, 1500)
timer_onTimer(tmer1, myTimer1)
timer_setEnabled(tmer1, true)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Thu Feb 25, 2016 3:03 am    Post subject: Reply with quote

you're using an obsolete syntax, but for now it still works

as for the last script, use
Code:
 
tmer1.enabled=false


(or give function myTimer1() a parameter and set that to disabled)

_________________
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
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu Feb 25, 2016 10:15 am    Post subject: Reply with quote

Dark Byte wrote:
you're using an obsolete syntax, but for now it still works

as for the last script, use
Code:
 
tmer1.enabled=false


(or give function myTimer1() a parameter and set that to disabled)

Thanks for the reply. Smile
Back to top
View user's profile Send private message
danrevella
Master Cheater
Reputation: 2

Joined: 11 Jun 2008
Posts: 290

PostPosted: Thu Feb 25, 2016 11:25 am    Post subject: Reply with quote

why not put here a version with the new syntax? Wink
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Thu Feb 25, 2016 11:28 am    Post subject: Reply with quote

danrevella wrote:
why not put here a version with the new syntax? Wink


I wanted to say that too. :d
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Feb 25, 2016 2:19 pm    Post subject: Reply with quote

Code:
tmer = createTimer(nil, false)
tmer.OnTimer = function(timer)
  print "1"
end
tmer.Interval = 1000
tmer.Enabled = true
Back to top
View user's profile Send private message
facecheats
Newbie cheater
Reputation: 0

Joined: 12 Jul 2015
Posts: 20

PostPosted: Thu Feb 25, 2016 6:53 pm    Post subject: Reply with quote

Code:
http = require("socket.http")

function timeZone()
  local now = os.time()
  return os.difftime(now, os.time(os.date('!*t',now)))
end

local ServerTime = http.request("website")
local CurTime = tonumber(ServerTime:sub(21,-6))
local MaxTime = os.time{year=2015, month=07, day=15, hour=23, min=59, sec=59, isdst=false} + timeZone()

if MaxTime>CurTime then showMessage("OBRIGADO PARA LOGIN \N AJORA TRENADOR CONTINUA") else end

if MaxTime<=CurTime then showMessage("NO PAY NO PLAY \N PAY OR FUCK OFF HAHAHAHAA...") CloseCE() else end

--==============================ADDS admaggo.ts=====================================--

function reclame()
shellExecute("website")
end
KeyTimer = createTimer(formInfo,false)
timer_setInterval(KeyTimer, 100000) -- 1 min. per attivare il POPUP Automatico di un sito prescelto...
timer_onTimer(KeyTimer, reclame)
timer_setEnabled(KeyTimer, true)
[/code]
_________________
dved rvrdv vrevr rvrve
Back to top
View user's profile Send private message
Dr.Disrespect
Grandmaster Cheater
Reputation: 3

Joined: 17 Feb 2016
Posts: 526

PostPosted: Fri Feb 26, 2016 12:14 am    Post subject: Reply with quote

Thank you all for the reply. Now I know how to use a timer. Very Happy
Back to top
View user's profile Send private message
Cestra
Newbie cheater
Reputation: 0

Joined: 03 Jun 2016
Posts: 14

PostPosted: Thu Jun 09, 2016 6:17 pm    Post subject: Reply with quote

it's using full memory. Sad how to fix?


CEtimer_Pyscial.gif
 Description:
 Filesize:  1.59 MB
 Viewed:  27891 Time(s)

CEtimer_Pyscial.gif


Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Jun 09, 2016 6:46 pm    Post subject: Reply with quote

Why are you calling openProcess repeatedly? Stop it!
Code:
tmer.OnTimer = function(timer)
  local success = openProcess("calc.exe")
  if success then
    print("found!")
    timer.Enabled = false
  else
    -- blah
  end
end
Back to top
View user's profile Send private message
Cestra
Newbie cheater
Reputation: 0

Joined: 03 Jun 2016
Posts: 14

PostPosted: Thu Jun 09, 2016 6:58 pm    Post subject: Reply with quote

Zanzer wrote:
Why are you calling openProcess repeatedly? Stop it!
Code:
tmer.OnTimer = function(timer)
  local success = openProcess("calc.exe")
  if success then
    print("found!")
    timer.Enabled = false
  else
    -- blah
  end
end


Thx zanzer but I tried it. How I know, when user open the game? Smile

Exp;

Code:
GameTimer=createTimer(nil)
GameTimer.Interval=1000
GameTimer.OnTimer=function(GameTimer)
    local success = openProcess("game.exe")
  if success then
    UDF1.CELabel1.Caption="Game found"
    UDF1.CELabel1.Font.Color=0x006600
    GameTimer.Enabled=false
  else
    UDF1.CELabel1.Caption="Game not found"
    UDF1.CELabel1.Font.Color=0x0000A4
  end
end
GameTimer.Enabled=true
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Thu Jun 09, 2016 9:42 pm    Post subject: Reply with quote

When "success" is true, the user has opened the game.
Back to top
View user's profile Send private message
Zec
Newbie cheater
Reputation: 0

Joined: 02 Jul 2016
Posts: 17

PostPosted: Tue Aug 22, 2017 1:21 pm    Post subject: Reply with quote

Please do not hurt me for digging in this old post.

I am trying this:

As long as a script is active, put 1 into the memory address behind a registered symbol. I get the address with another AA script. The symbol points to the right address, i can change it manually.

This is what I tried but it does not change the value:

Code:

[ENABLE]
{$lua}
tHolz = createTimer(nil, false)
tHolz.OnTimer = function(fHolz)
  print "tHolz ping"
  -- writeInteger('[_stamms]+58','1')
  getAddressList().getMemoryRecordByDescription('_stamms + 58').Value='1'
end
tHolz.Interval = 1000
tHolz.Enabled = true

{$asm}
// -----------------------------------------------------------------------------

[DISABLE]
{$lua}
tHolz.Destroy()
writeInteger('[_stamms]+58','0')
--getAddressList().getMemoryRecordByDescription('_stamms + 58').Value='0'

{$asm}


writeInteger and chaning the table entry do not work.

Where is my mistake?
Back to top
View user's profile Send private message
FreeER
Grandmaster Cheater Supreme
Reputation: 53

Joined: 09 Aug 2013
Posts: 1091

PostPosted: Tue Aug 22, 2017 2:15 pm    Post subject: Reply with quote

Code:
'_stamms + 58'
seems more like an address than a description/name...
If you're not getting an error message that can point you to the issue then try printing some more information out eg.

Code:
tHolz.OnTimer = function(fHolz)
  print "tHolz ping"
  print('writeInteger address in decimal', getAddress('[_stamms]+58'))
  print('mem rec object address in decimal',  getAddressList().getMemoryRecordByDescription('_stamms + 58'))
  -- writeInteger('[_stamms]+58','1')
  getAddressList().getMemoryRecordByDescription('_stamms + 58').Value='1'
end
Back to top
View user's profile Send private message
Zec
Newbie cheater
Reputation: 0

Joined: 02 Jul 2016
Posts: 17

PostPosted: Wed Aug 23, 2017 4:18 pm    Post subject: Reply with quote

The function is not being fired. I do not get the ping and the additional info.

'_stamms + 58' is the name of the table entry. I added it to see the value at the address.

Can something affect the lua engine?

I have a timer in the table script that waits until a AOB pattern becomes available (after the level is loaded). Then an AA script is fired and that timer is being destroyed. That AA script copies the base address of another value and works well.
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
Goto page 1, 2  Next
Page 1 of 2

 
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