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 


Stop lua script after close
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
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Fri May 27, 2016 1:48 am    Post subject: Stop lua script after close Reply with quote

How to stop lua script after close window?


F#cking script work after close window, show window back, i can't close it!!!!!!!!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri May 27, 2016 3:23 am    Post subject: Reply with quote

axd an onClose event to the window. in there disable the script. like disabling timers, threads, and perhaps closing cheat engine completely
_________________
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
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Fri May 27, 2016 3:48 am    Post subject: Reply with quote

Why?!
Please create new function closeThisScript() for complete close script! If a lot of timers, threads etc - impossible to destroy all !!!!
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: Fri May 27, 2016 4:14 am    Post subject: Re: Stop lua script after close Reply with quote

karaulov wrote:
How to stop lua script after close window?


F#cking script work after close window, show window back, i can't close it!!!!!!!!

We are not magicians. We don't know what script you wrote.

Post your CT file (you can snip some things if you want) which shows your problem.

Then I or someone else will tell what to do and post back a fixed CT.

_________________
Back to top
View user's profile Send private message MSN Messenger
hhhuut
Grandmaster Cheater
Reputation: 6

Joined: 08 Feb 2015
Posts: 607

PostPosted: Fri May 27, 2016 4:32 am    Post subject: Reply with quote

karaulov wrote:
Why?!

Because you do not always want to deactivate the script when just closing it.
Back to top
View user's profile Send private message
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Fri May 27, 2016 5:15 am    Post subject: Reply with quote

Who does not want just do not use this feature. But it is needed!
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri May 27, 2016 5:40 am    Post subject: Reply with quote

closeCE() will close all threads and timers

alternatively, keep track of the timers and threads you create and terminate them.

tip: If your timer is embedded inside a form (owned by a form) then destroying the form will also kill the timer.
if you return caFree in the OnClose event of the form, the form will be destroyed instead of just hidden

_________________
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
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Fri May 27, 2016 6:46 am    Post subject: Reply with quote

How to add action OnCLose without form ?
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: Fri May 27, 2016 7:41 am    Post subject: Reply with quote

Quote:
If a lot of timers, threads etc - impossible to destroy all !!!!

Not a problem. You can write your own createTimer function so it will create and register all timers.

Code:
collectedTimers = {}

function myCreateTimer(...)
  local timer = createTimer(...)
  collectedTimers[#collectedTimers+1] = timer
  return timer
end

function destroyAllTimers()
  for _,v in ipairs(collectedTimers) do
    v.destroy()
  end
  collectedTimers = {}
end

function disableAllTimers()
  for _,v in ipairs(collectedTimers) do
    v.Enabled=false
  end
end

function enableAllTimers()
  for _,v in ipairs(collectedTimers) do
    v.Enabled=true
  end
end



Just use myCreateTimer for every timer you want to create.


When you want to shutdown the timer(s) object just use this in "Lua Engine" window
Code:
destroyAllTimers()





About threads. This's more complicated. And solution will be different depending on how many threads you have, does one of those has "free on terminate" (which is the default setting)...

_________________


Last edited by mgr.inz.Player on Fri May 27, 2016 8:22 am; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Fri May 27, 2016 8:17 am    Post subject: Reply with quote

How to use it without form? (How to create onClose event)
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: Fri May 27, 2016 8:35 am    Post subject: Reply with quote

OnClose events are called only when form is about to close.
http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/delphivclwin32/Forms_TForm_OnClose.html



 

_________________
Back to top
View user's profile Send private message MSN Messenger
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Fri May 27, 2016 11:45 pm    Post subject: Reply with quote

Help, i don't know, how to add event onClose in console script window?!
Back to top
View user's profile Send private message
predprey
Master Cheater
Reputation: 24

Joined: 08 Oct 2015
Posts: 486

PostPosted: Sat May 28, 2016 2:48 am    Post subject: Reply with quote

yourObject.onClose = function (sender)
....your code(destroy(), etc...)
end

onClose is just a property though....your object needs to be able to call it, if its not a form
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 May 28, 2016 4:18 am    Post subject: Reply with quote

create new text file with .lua extension inside autorun folder, with this script:
Code:
collectedTimers = {}
originalCreateTimer = createTimer

function createTimer(...)
  local timer = originalCreateTimer(...)
  collectedTimers[#collectedTimers+1] = timer
  return timer
end

function addDestroyTimersButton()
  local btn=getMainForm().frmAutoInject.Button1
  local newButton = createButton(getMainForm().frmAutoInject.Panel1)
  newButton.Height = 31
  newButton.Width = 129
  newButton.Caption = "Destroy all timers"
  newButton.AnchorSideTop.Control = btn
  newButton.AnchorSideLeft.Control = btn
  newButton.AnchorSideLeft.Side = asrBottom
  newButton.BorderSpacing.Left = 5
  newButton.OnClick = function ()
                       for _,v in ipairs(collectedTimers) do
                        v.destroy()
                       end
                       collectedTimers = {}
                      end
end

addDestroyTimersButton()


It will add "Destroy all timers" button to "Lua Script: Cheat Table" window.

_________________
Back to top
View user's profile Send private message MSN Messenger
karaulov
Advanced Cheater
Reputation: 0

Joined: 12 Aug 2013
Posts: 65
Location: Belarus

PostPosted: Sat May 28, 2016 8:40 am    Post subject: Reply with quote

Yes it works! Very Happy

Only for lua table window, not works with lua console script ??
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