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 


Restart timer

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Fri Jul 25, 2014 1:25 pm    Post subject: Restart timer Reply with quote

Hey,
If I have a timer that updates GUI after 4 seconds.
And I update GUI manually after 2 seconds (means 2 more seconds until timer updates it), can I 'restart' the timer? if so, then how?

_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 457

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

PostPosted: Fri Jul 25, 2014 1:45 pm    Post subject: Reply with quote

Set Enabled to false and then back to true again
_________________
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
DaSpamer
Grandmaster Cheater Supreme
Reputation: 52

Joined: 13 Sep 2011
Posts: 1578

PostPosted: Fri Jul 25, 2014 2:02 pm    Post subject: Reply with quote

Ok, thanks perfect.
_________________
HEY Hitler
Do you get lazy when making trainers?
Well no more!
My CETrainer will generate it for you in seconds, so you won't get lazy! Very Happy

http://forum.cheatengine.org/viewtopic.php?t=564919
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 218

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Sat Jul 26, 2014 6:38 am    Post subject: Reply with quote

I'm also using "restart timer" thing very often.

For example I used this in my, very first version, table for DS II ("Items List" script):
Code:
function CEEdit1Change(sender)
  if itemsTable==nil then return end

  filteredTable = {}

  local filter = UDF1.CEEdit1.Text

  for i,v in ipairs(itemsTable) do
    if v.name:upper():match(filter:upper()) then
     filteredTable[#filteredTable+1] = v
    end
  end

  UDF1.ShownItemsLabel.Caption = 'count: '..#filteredTable
  fillList(UDF1.CEListBox1,filteredTable)

end

CEEdit1 is used to filter out other items, those which doesn't match.

Because I didn't want another "OK" button, I called fillList function inside CEEdit1Change. This fillList function clears ListBox and then fills it again. It has one unpleasant effect: for every typed letter ListBox is refreshed. Sometimes those calls are stacked (user already typed in whole word very fast and list still will blink one or two times).

I resolved this problem by using timer:
Code:
if filterDelayTimer ~= nil then filterDelayTimer.destroy(); filterDelayTimer=nil end
filterDelayTimer = createTimer(nil,false)
filterDelayTimer.Interval = 500
filterDelayTimer.OnTimer =
  function (t) t.Enabled=false; fillList(UDF1.CEListBox1,filteredTable) end

function CEEdit1Change(sender)
  if itemsTable==nil then return end

  filteredTable = {}

  local filter = UDF1.CEEdit1.Text

  for i,v in ipairs(itemsTable) do
    if v.name:upper():match(filter:upper()) then
     filteredTable[#filteredTable+1] = v
    end
  end

  UDF1.ShownItemsLabel.Caption = 'count: '..#filteredTable
  filterDelayTimer.Enabled=false
  filterDelayTimer.Enabled=true

end


The above is exactly "set Enabled to false and then back to true again". ListBox is refreshed with 500ms delay. I left only visual thing which is immediately refreshed: ShownItemsLabel

_________________
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