Reading the tutorial/examples on here they create a form and assign the form as the parent of the Timer.
What if you are not using forms? Do you have to create a dummy form just to use a timer?
Reading the tutorial/examples on here they create a form and assign the form as the parent of the Timer.
What if you are not using forms? Do you have to create a dummy form just to use a timer?
Never ever approach a computer saying or even thinking "I will just do this quickly".
Use nil.
Join the IRC! irc.rizon.net:6667/srl | SQLite (0.99rc3+) | SRL Doc | Simba Doc | Extra Simba Libraries (openSSL & sqlite3)
Originally Posted by #srl
"A programmer is just a tool which converts caffeine into code"
Are you just trying to set up a timer in a script? This code does just that:
Then to check how long it has been since you started the timer, just use:Simba Code:MarkTime(variablename);
Simba Code:TimeFromMark(variablename);
I tried that but it didn't work, leading me to wonder if it was my code or whether I couldn't use nil. Guess it was my code. Back to the drawing board!
No I want a block of code to execute at specific time intervals independent of the main code execution. Which is got me interested in the TTimer.
Never ever approach a computer saying or even thinking "I will just do this quickly".
Yes, although I realize Simba does not support true multi-threading.
What got me interested in this: Digging around in the SRL includes I realized PlayerCurTime is never updated. Ever.
I could simply update it from time to time at various points in my code...Which got me to thinking: Why not use a TTimer and update it periodically automatically behind the scenes? Just starting to write a test script to see if it will actually do what I want.
Never ever approach a computer saying or even thinking "I will just do this quickly".
PlayerCurTime never needs "updated" there is no such thing as a "timer" that "counts up"
The real thing that happens is you get the system time.
then when you wana know how much time has passed you get the system time again and subtract the previous time.
There were a couple other things I wanted to update at the same time. Seemed logical to group them all together.
Regardless having a devil of time coming up with a working test.
The example script in this tutorial does not work as documented. The output from the TTimer procs never display on screen.
http://villavu.com/forum/showthread.php?t=51578
Last edited by Bixby Sayz; 03-26-2011 at 03:09 AM.
Never ever approach a computer saying or even thinking "I will just do this quickly".
The second example that he posted is the one you want to look at.
Run it in scar(NOT SIMBA). make sure you have report and the debug box visible.
Should workPHP Code:var
PlayerCurTime: Integer;
Timer: TTimer;
procedure OnTimer(Sender: TObject);
begin
PlayerCurTime := PlayerCurTime + 500;
end;
begin
Timer := TTimer.Create(nil);
Timer.Interval := 500;
Timer.OnTimer := @OnTimer;
repeat
Sleep(2000);
Writeln(IntToStr(PlayerCurTime));
Until(PlayerCurTime > 4000);
end.
You get the gist of it though
![]()
You may contact me with any concerns you have.
Are you a victim of harassment? Please notify me or any other staff member.
| SRL Community Rules | SRL Live Help & Chat | Setting up Simba | F.A.Q's |
Added Timer.Enabled := True to your code to make it work but still got the following results:
Result in SCAR
SCAR Code:Successfully compiled (140 ms)
0
0
0
0
0
Stopped execution (11500 ms)
Result in Simba
Simba Code:Compiled succesfully in 15 ms.
0
0
0
0
0
0
0
Successfully executed.
I think I will give up on this for the time being. It appears to be rather broken.
Never ever approach a computer saying or even thinking "I will just do this quickly".
There are currently 1 users browsing this thread. (0 members and 1 guests)