panraven Grandmaster Cheater Reputation: 55
Joined: 01 Oct 2008 Posts: 942
|
Posted: Sun Oct 12, 2014 5:49 am Post subject: |
|
|
You may need to setup your main form close handler, so that the timer created is killed properly during DEBUG.
Code: | local function getRoot(c) local p,q = c.Parent,c ; while p do p,q=p.Parent,p end return q end
local isTrainer = TrainerOrigin -- it is actually the path of cetrainer executed, nil during debug
local function dp(...) if not isTrainer then print(...) end end
local TimerPool = {}
local function marquee (T)
local NameID = getRoot(T).Name ..'|'..T.Name
if TimerPool[NameID] == nil then
local tm = createTimer(T)
TimerPool[NameID] = tm
tm.toRight = function() tm.Direction = 1 end
tm.toLeft = function() tm.Direction = -1 end
tm.setText = function(t) if T.setCaption then T.setCaption(t) end if T.Text then T.Text = t end end
tm.getText = function(t) if T.setCaption then return T.getCaption(t) end if T.Text then return T.Text end end
tm.start = function() tm.Enabled = true end
tm.stop = function() tm.Enabled = false end
tm.OnTimer = function()
local s = tm.getText() ;
local l = string.len(s)
local dir = tonumber(tm.Direction,10) or tm.Direction or 1
if l > 1 then
if dir < 0 then
tm.setText(string.sub(s,2,l)..string.sub(s,1,1))
else
tm.setText(string.sub(s,l,l)..string.sub(s,1,l-1))
end
T.update()
end
end
tm.release = function()
TimerPool[NameID] = nil
tm.Enabled = false
tm.destroy()
tm = nil
end
end
TimerPool[NameID].Direction = 1
TimerPool[NameID].Interval = 1000
TimerPool[NameID].Enabled = false
return TimerPool[NameID]
end
-- need to kill timers during debug, adapt to your main form close handler
UDF1.OnClose = function(sender)
local f = caHide
if isTrainer then f = caFree end
for k,v in pairs(TimerPool) do if v then v.destroy() ; TimerPool[k] = nil ; dp('timer for '..k..' killed')end end
return f
end
-- for test, create controls at designer
local marqL = marquee(UDF1.CELabel1)
local marqE = marquee(UDF1.CEEdit1)
local marqL2 = marquee(UDF1.CELabel1)
-- test if createTimer properly
if marqL == marqL2 then dp('Same control Same Timer, Good') else dp('Same control Diff Timer, Bad') end
if marqL == marqE then dp('Diff control Same Timer, Bad') else dp('Diff control Diff Timer, Good') end
marqL.setText('**abcde fghijkl mnopq rstu vwxyz')
marqE.setText('**1244 99883 2777 266666 99')
marqL.toRight()
marqL.start()
marqE.toLeft()
marqE.start()
UDF1.show()
|
|
|