| View previous topic :: View next topic |
| Author |
Message |
abhijeet1001 Advanced Cheater
Reputation: 0
Joined: 10 Apr 2013 Posts: 87
|
Posted: Fri Nov 08, 2013 1:24 pm Post subject: Lua Banner |
|
|
hello can anyone fix my script I trying to make label banner which males test scroll automatically on a place I made a script which make the text to move but I cannot reset the text also the problem is I have set a time interval of 6 seconds after which the text should stop but when I keep executing it to check its functionality the time interval changes to 4 or 3 seconds automatically even though my script has 6 seconds can someone help me fix it please ?
| Code: | newpos = 400
k = control_getPosition(d)
function floatdesc()
if k == 0 then
control_setPosition(d,15,275)
else if k > 0 then
newpos = newpos - 5
control_setPosition(d,15,newpos)
end
end
end
t=createTimer(nil)
timer_onTimer(t, floatdesc)
timer_setInterval(t, 200)
timer_setEnabled(t, true);
function kill()
if t~=nil then
object_destroy(t)
t = nil
end
end
v=createTimer(nil)
timer_onTimer(v, kill)
timer_setInterval(v, 6000)
timer_setEnabled(v, true);
|
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 471
Joined: 09 May 2003 Posts: 25818 Location: The netherlands
|
Posted: Fri Nov 08, 2013 4:15 pm Post subject: |
|
|
your code doesn't contain any cleanup. So when you execute it again, the other old timers do not get destroyed.
So, kill gets executed 6 seconds after it has been started the first time, even if you did start the second one a few seconds later.
Also, print out the value of k. It might give a clue what's happening
_________________
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 |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Fri Nov 08, 2013 7:21 pm Post subject: |
|
|
| Code: | newpos = 400
k = control_getPosition(d)
function floatdesc(sender)
time = time or 0
time = time + 1
if k == 0 then
control_setPosition(d,15,275)
else
if k > 0 then
newpos = newpos - 5
control_setPosition(d,15,newpos)
end
end
if time >= 30 then -- 6000 / 200 = 30 --> the function will be excuted 30 times within 6 seconds.
object_destroy(sender) --> sender = object who called this function (t - the timer).
end
end
t=createTimer(nil)
timer_onTimer(t, floatdesc)
timer_setInterval(t, 200)
timer_setEnabled(t, true); |
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
abhijeet1001 Advanced Cheater
Reputation: 0
Joined: 10 Apr 2013 Posts: 87
|
Posted: Sat Nov 09, 2013 1:04 pm Post subject: |
|
|
thanks for the help daspammer didn't tried the script yet currently out will be trying it tomoro just saw it today and tried to figure what all change u did can u please explain what was wrong in my script and how you corrected it ? I want to know coze getting that script done directly won't help me in future rather than knowing how u did that
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Sat Nov 09, 2013 1:09 pm Post subject: |
|
|
I just got rid of the second timer.
It's quite simple just read.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
abhijeet1001 Advanced Cheater
Reputation: 0
Joined: 10 Apr 2013 Posts: 87
|
Posted: Sun Nov 10, 2013 9:23 am Post subject: |
|
|
| DaSpamer wrote: | I just got rid of the second timer.
It's quite simple just read. |
daspammer the script is not wrking as it shuld be i wanted to make a banner which constantly keeps on reappearing after getting out of the screen like it goes floating up and comes again from down but using ur script just makes it float up once not again so i made some changes in my script
| Code: |
function allin1()
newpos = 400
k = control_getPosition(d)
function floatdesc()
if k == 0 then
control_setPosition(d,15,275)
else if k > 0 then
newpos = newpos - 5
control_setPosition(d,15,newpos)
end
end
end
t=createTimer(nil)
timer_onTimer(t, floatdesc)
timer_setInterval(t, 300)
timer_setEnabled(t, true);
function kill()
if t~=nil then
object_destroy(t)
t = nil
end
end
v=createTimer(nil)
timer_onTimer(v, kill)
timer_setInterval(v, 6000)
timer_setEnabled(v, true);
if v~=nil then
object_destroy(v)
t = nil
end
end
v=createTimer(nil)
timer_onTimer(v, allin1)
timer_setInterval(v, 7000)
timer_setEnabled(v, true);
|
now my problem is i want to clear up old times so when the above function is executed old timer doesnt interfare in between as dark byte said but i got no idea how to do that please help
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Sun Nov 10, 2013 9:41 am Post subject: |
|
|
Hmm,
My script?
I never shared my script >.>
But who cares.
| Code: | DescLocation = 5 --> Top position of the label
local WIDTH,HEIGHT = control_getSize(Panel) --> Panel 394x125
MaxDescSize = HEIGHT --> 125
function MoveDesc() --> Timer function
local We,He = control_getSize(Label) --> Label with text --> Width
local WE,HE = control_getPosition(Label) --> Label with text --> top
if (HE+He) < 5 then --> Last line of the label is below 5
DescLocation = MaxDescSize --> New var position --> 125 (top)
else
DescLocation = DescLocation - 1 --> Var position - 1
end
control_setPosition(Label, 5, DescLocation) --> Updates label position
end
function TextFits(Height) --> Checking function
if MoveDescTimer~=nil then --> Destroying the old timer, because text has been changed the DescChanger() has been called again.
object_destroy(MoveDescTimer) --> Destroying
MoveDescTimer = nil --> Nulling it
end
DescLocation = 5 --> Reseting the DescLocation back to 5
if MaxDescSize-10 < Height then --> Checking if label height is smaller than MaxDescSize-10 (125-10 = 115);
MoveDescTimer = createTimer(nil,false) --> Creating timer
timer_setInterval(MoveDescTimer, 30) --> Interval
timer_onTimer(MoveDescTimer, MoveDesc) --> the function above..
timer_setEnabled(MoveDescTimer, true) --> Enabling
end
end
function DescChanger() --> The function that is called after changing the label text.
if MoveDescTimer~=nil then
object_destroy(MoveDescTimer)
MoveDescTimer = nil
end
-- Some operation I do here... removed..
local Width,Height = control_getSize(Label) --> after updating the text, getting it's height
TextFits(Height) --> calling the checking function with the text height.
end |
And yes, I wrote it when I used C.E 6.2, long time before I knew about C.E 6.3 features.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
abhijeet1001 Advanced Cheater
Reputation: 0
Joined: 10 Apr 2013 Posts: 87
|
Posted: Sun Nov 10, 2013 12:51 pm Post subject: |
|
|
ah I didn't asked this script its what lol I can't get it how to use this ?
I asked can u fix my script which I posted just above Ur reply I just want to make a clean up command which clear the old timer when the function is again runned so that old timers don't interfere in the second run
EDIT OK I got this script working after putting my values thanks for it but still can u fix my script too ?
|
|
| Back to top |
|
 |
daspamer Grandmaster Cheater Supreme
Reputation: 54
Joined: 13 Sep 2011 Posts: 1588
|
Posted: Sun Nov 10, 2013 1:09 pm Post subject: |
|
|
If I fix for you, you won't understand what I've done and you won't be able to improve anything, and this script is pretty easy.
_________________
I'm rusty and getting older, help me re-learn lua. |
|
| Back to top |
|
 |
|