The online racing simulator
Countdown timer (code for v5.7xx + code for v5.8xx)
Hi

Countdown using coloured buttons
READY
3
2
1
GO
I've done 2 versions.

Tested v5.844, but not v5.714 - To be honest, I struggled to remember how to code that.

If v5.714 not quite right, most of the detail is there, so should be easy to correct.

I've loaded video onto youtube - http://www.youtube.com/watch?v=Ex2mos68QqM.

Files saved in text format - copy and paste in relevant section
5.714 - look for other RegisterMsgAction coding, and add after one that finishes 'EndSub'.
5.844 - look for other CASE coding, and add after one that finishes 'BREAK;'

=========================
Repeat what I always say - make backup of your working lapper; and I take no responsibility when it all goes horribly wrong!
=========================

If it works as expected, you should type !click (or !CLICK or !Click), and counter will begin
Black button with READY in white letters. Should stay on screen for 3 seconds.
This is to allow time for drivers to get prepared
Then that button self closes, and a red button appears with black number 3
Red button closes......buttons close till you get to Yellow button with GO in green
That stays on screen for 3 seconds - drivers with good reactions will get off quickly (video shows why this is needed - and I was prepared for it!)


BE AWARE - You may have to change colours - the combinations may be impossible to see for people that are colour blind
Attached files
LFSLapper V5 7xx Count Function.txt - 4.8 KB - 234 views
LFSLapper V5 8xx Count Function.txt - 4.8 KB - 306 views
nice work hmm i sopose a 30 second one would be hard lol
Good work

but wth are u grapics doing?
Quote from Fire_optikz001 :nice work hmm i sopose a 30 second one would be hard lol



But seriously.

Not only hard but I think there's a limitation.

I've used 50 buttons basically for 5 events.

I think you're allowed maximum of 200 buttons (?) on any InSim application, so best you could do is start from

READY
18
17
....
1
GO

Possible if you reduced overall size of countdown, you could cut number of smaller buttons needed to make the bigger button.

BUT. Who would want to hang around for that length of time anyway? Snooze.

Now if there was a way to make it random - say between 10 to 3 seconds - that would be cool

Way beyond my meager programming talents.
Quote from Heiko1 :but wth are u grapics doing?



Number of things.

1 - Showing off countdown timer button
2 - Showing off driftmeter with add on messages at top of screen
3 - Showing off a couple of Marshalls. Rewatching the video, looks like the slipstream has pulled off some of the marshalls clothes when car went by so closely. Realistic or what?!
4 - I've got major pc graphics problems - reloading various versions of Nvidea's drivers has made no difference. I think my card is dying. If you think it looks bad in the video, you should try driving with it. On some parts of the track I have to drive over tarmac that suddenly shows as sky, or worse, driving to a part of track that suddenly shows the track vertically and going straight from one side of the display to another (makes me feel like Kimi when that happens - only he had more skill).
A different looking countdown timer
At someone's request;

Different looking timer (this will be my last!) for newer version of lapper....

Part 1 of code should be added in the same section as other CASE: coding - make sure fitted after a BREAK; line.

Part 2 of code should be added at very end of section where CASE: - BREAK; is, and after End Switch / End Event lines.


V5.844 - Part 1 of code


CASE "!count":
CASE "!Count":
CASE "!COUNT":
IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "counter_text1",60,85,20,20,1,3,0,"^7( ^1READY ^7)", onfinishopenstart);
ENDIF
BREAK;

V5.844 - Part 2 of code

Sub onfinishopenstart($KeyFlags,$id)
closePrivButton("counter_text1");
openGlobalButton( "lone_counter",60,85,20,20,1,5,0,"^3> %cpt% <", endcounter );
EndSub
Sub endcounter($KeyFlags,$id)
closePrivButton("counter_text1&lone_counter");
openGlobalButton( "circle_GO",50,75,40,40,1,6,0,"^2! GO !");
EndSub

To make it work, you need to be Admin, and you need to type !count.

If may be you need to play around with text colours, placement and size to get it to work to your personal requirements.

Plenty of posts elsewhere on lapper forum on how to do this.

Colours of this one ok for me, but I've skewed it slightly left as I'm testing something in middle of screen.
Attached images
another lapper counter.PNG
THIS WORKS 2

CASE "!count":
CASE "!Count":
CASE "!COUNT":

IF( UserInGroup( "admin",$userName ) == 1 )
THEN
DelayedCommand( 1, SC1 );
ENDIF
BREAK;

Sub SC1()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^3R E A D Y");
DelayedCommand( 2, SC2 );
EndSub
Sub SC2()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^13");
DelayedCommand( 2, SC3 );
EndSub
Sub SC3()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^12");
DelayedCommand( 2, SC4 );
EndSub
Sub SC4()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^11");
DelayedCommand( 2, SC5 );
EndSub
Sub SC5()
openGlobalButton( "Count",92,78,20,40,5,3,0,"^2Go");
EndSub

Quote from sinanju :At someone's request;

Different looking timer (this will be my last!) for newer version of lapper....

Part 1 of code should be added in the same section as other CASE: coding - make sure fitted after a BREAK; line.

Part 2 of code should be added at very end of section where CASE: - BREAK; is, and after End Switch / End Event lines.


V5.844 - Part 1 of code


CASE "!count":
CASE "!Count":
CASE "!COUNT":
IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "counter_text1",60,85,20,20,1,3,0,"^7( ^1READY ^7)", onfinishopenstart);
ENDIF
BREAK;

V5.844 - Part 2 of code

Sub onfinishopenstart($KeyFlags,$id)
closePrivButton("counter_text1");
openGlobalButton( "lone_counter",60,85,20,20,1,5,0,"^3> %cpt% <", endcounter );
EndSub
Sub endcounter($KeyFlags,$id)
closePrivButton("counter_text1&lone_counter");
openGlobalButton( "circle_GO",50,75,40,40,1,6,0,"^2! GO !");
EndSub

To make it work, you need to be Admin, and you need to type !count.

If may be you need to play around with text colours, placement and size to get it to work to your personal requirements.

Plenty of posts elsewhere on lapper forum on how to do this.

Colours of this one ok for me, but I've skewed it slightly left as I'm testing something in middle of screen.

thats sweet
#9 - Silox
Quote from sinanju :
I think you're allowed maximum of 200 buttons (?) on any InSim application

That would be 255 (256?) because (in LFS_External) the ButtonID's get sent through a Byte, which can't be larger then 255 (256?).

But anyway, great!

I wonder what happens if you move while the countdown is counting?
nothing

Quote from Silox :That would be 255 (256?) because (in LFS_External) the ButtonID's get sent through a Byte, which can't be larger then 255 (256?).

But anyway, great!

I wonder what happens if you move while the countdown is counting?

Quote from Fire_optikz001 :THIS WORKS 2

CASE "!count":
CASE "!Count":
CASE "!COUNT":

IF( UserInGroup( "admin",$userName ) == 1 )
THEN
DelayedCommand( 1, SC1 );
ENDIF
BREAK;

Sub SC1()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^3R E A D Y");
DelayedCommand( 2, SC2 );
EndSub
Sub SC2()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^13");
DelayedCommand( 2, SC3 );
EndSub
Sub SC3()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^12");
DelayedCommand( 2, SC4 );
EndSub
Sub SC4()
openGlobalButton( "Count",92,78,20,40,5,-1,0,"^11");
DelayedCommand( 2, SC5 );
EndSub
Sub SC5()
openGlobalButton( "Count",92,78,20,40,5,3,0,"^2Go");
EndSub


My code's a lot more condensed, but basically because it's mainly a number count.

Your code is much better if you want something like

ON YOUR MARKS
READY
STEADY
WAIT FOR IT
WAIT FOR IT!
.....
GO!

I haven't got my head round the delay command yet.

On yours you have 2
DelayedCommand( 1, SC1 );
DelayedCommand( 2, SC2 );

I understand the variable SC1/SC2/SC3... for the sub commands, but what do the 1 and 2 signify?

Also. Didn't realise you could re-use the same unique button ("Count") name again and again. I assume that must only be in DelayedCommand?
no what it does is reopens the button with the new info such as a schedule action it will reload text again and again except with the updated text.
1 and 2 = how many seconds to delay

its sorta like this :

RegisterScheduleAction( "10 * * * * * * : 30 * * * * * * : 50 * * * * * *", SA_site );
RegisterScheduleAction( "00 * * * * * * : 20 * * * * * * : 40 * * * * * *", SA_time );

Sub SA_time() # Lapper Event
openGlobalButton( "time",69,194,51,6,5,-1,32,"^7Time and Date: ^1" . GetLapperVar("LongTime") ." ^7" . GetLapperVar("LongDate") );
openGlobalButton( "SORT",120,194,20,6,10,-1,32,"^1All times are ^7GMT" );
EndSub

Sub SA_site() # Lapper Event
openGlobalButton( "time",69,194,51,6,5,-1,32,"^7Time and Date: ^1" . GetLapperVar("LongTime") ." ^7" . GetLapperVar("LongDate") );
openGlobalButton( "SORT",120,194,20,6,10,-1,32,"^7SuperCr3w.co.uk" );
EndSub

Quote from sinanju :My code's a lot more condensed, but basically because it's mainly a number count.

Your code is much better if you want something like

ON YOUR MARKS
READY
STEADY
WAIT FOR IT
WAIT FOR IT!
.....
GO!

I haven't got my head round the delay command yet.

On yours you have 2
DelayedCommand( 1, SC1 );
DelayedCommand( 2, SC2 );

I understand the variable SC1/SC2/SC3... for the sub commands, but what do the 1 and 2 signify?

Also. Didn't realise you could re-use the same unique button ("Count") name again and again. I assume that must only be in DelayedCommand?

i also remade this into a bunch of cool features

CASE "!count":
IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "lone_counter",50,63,100,40,100,$argv,0,"^3> %cpt% <", endcounter );
ENDIF
BREAK;
CASE "!countdown":
IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "lone_counter",50,63,100,40,100,$argv,0,"^3> %cpt% <", countdown );
ENDIF
BREAK;
CASE "!term":
IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "lone_counter",50,63,100,40,100,$argv,0,"^3> %cpt% <", term );
IF( . $argv . == 1)
THEN

cmdLFS("/msg ^1INSIM SHUTAGE IN " . $argv . " SECOND " );
cmdLFS("/msg ^2INSIM SHUTAGE IN " . $argv . " SECOND " );
cmdLFS("/msg ^3INSIM SHUTAGE IN " . $argv . " SECOND " );
cmdLFS("/msg ^4INSIM SHUTAGE IN " . $argv . " SECOND " );
cmdLFS("/msg ^5INSIM SHUTAGE IN " . $argv . " SECOND " );
cmdLFS("/msg ^6INSIM SHUTAGE IN " . $argv . " SECOND " );
cmdLFS("/msg ^7INSIM SHUTAGE IN " . $argv . " SECOND " );

ELSE

cmdLFS("/msg ^1INSIM SHUTAGE IN " . $argv . " SECONDS " );
cmdLFS("/msg ^2INSIM SHUTAGE IN " . $argv . " SECONDS " );
cmdLFS("/msg ^3INSIM SHUTAGE IN " . $argv . " SECONDS " );
cmdLFS("/msg ^4INSIM SHUTAGE IN " . $argv . " SECONDS " );
cmdLFS("/msg ^5INSIM SHUTAGE IN " . $argv . " SECONDS " );
cmdLFS("/msg ^6INSIM SHUTAGE IN " . $argv . " SECONDS " );
cmdLFS("/msg ^7INSIM SHUTAGE IN " . $argv . " SECONDS " );

ENDIF
ENDIF
BREAK;
CASE "!reinit":

IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "lone_counter",50,63,100,40,100,$argv,0,"^3> %cpt% <", reinit );
IF( . $argv . == 1)
THEN

cmdLFS("/msg ^1SERVER REBOOT IN " . $argv . " SECOND " );
cmdLFS("/msg ^2SERVER REBOOT IN " . $argv . " SECOND " );
cmdLFS("/msg ^3SERVER REBOOT IN " . $argv . " SECOND " );
cmdLFS("/msg ^4SERVER REBOOT IN " . $argv . " SECOND " );
cmdLFS("/msg ^5SERVER REBOOT IN " . $argv . " SECOND " );
cmdLFS("/msg ^6SERVER REBOOT IN " . $argv . " SECOND " );
cmdLFS("/msg ^7SERVER REBOOT IN " . $argv . " SECOND " );

ELSE

cmdLFS("/msg ^1SERVER REBOOT IN " . $argv . " SECONDS " );
cmdLFS("/msg ^2SERVER REBOOT IN " . $argv . " SECONDS " );
cmdLFS("/msg ^3SERVER REBOOT IN " . $argv . " SECONDS " );
cmdLFS("/msg ^4SERVER REBOOT IN " . $argv . " SECONDS " );
cmdLFS("/msg ^5SERVER REBOOT IN " . $argv . " SECONDS " );
cmdLFS("/msg ^6SERVER REBOOT IN " . $argv . " SECONDS " );
cmdLFS("/msg ^7SERVER REBOOT IN " . $argv . " SECONDS " );
ENDIF
ENDIF
BREAK;

Sub endcounter($KeyFlags,$id)
closePrivButton("lone_counter");
openGlobalButton( "circle_GO",,50,63,100,40,100,3,0,"^2! GO !");
EndSub

Sub countdown($KeyFlags,$id)
closePrivButton("lone_counter");
EndSub

Sub term($KeyFlags,$id)
termLapper();
EndSub


Sub reinit($KeyFlags,$id)
cmdLFS("/reinit" );
EndSub

Quote from sinanju :At someone's request;

Different looking timer (this will be my last!) for newer version of lapper....

Part 1 of code should be added in the same section as other CASE: coding - make sure fitted after a BREAK; line.

Part 2 of code should be added at very end of section where CASE: - BREAK; is, and after End Switch / End Event lines.


V5.844 - Part 1 of code


CASE "!count":
CASE "!Count":
CASE "!COUNT":
IF( UserInGroup( "admin",$userName ) == 1 )
THEN
openGlobalButton( "counter_text1",60,85,20,20,1,3,0,"^7( ^1READY ^7)", onfinishopenstart);
ENDIF
BREAK;

V5.844 - Part 2 of code

Sub onfinishopenstart($KeyFlags,$id)
closePrivButton("counter_text1");
openGlobalButton( "lone_counter",60,85,20,20,1,5,0,"^3> %cpt% <", endcounter );
EndSub
Sub endcounter($KeyFlags,$id)
closePrivButton("counter_text1&lone_counter");
openGlobalButton( "circle_GO",50,75,40,40,1,6,0,"^2! GO !");
EndSub

To make it work, you need to be Admin, and you need to type !count.

If may be you need to play around with text colours, placement and size to get it to work to your personal requirements.

Plenty of posts elsewhere on lapper forum on how to do this.

Colours of this one ok for me, but I've skewed it slightly left as I'm testing something in middle of screen.

Quote from Silox :That would be 255 (256?) because (in LFS_External) the ButtonID's get sent through a Byte, which can't be larger then 255 (256?).

But anyway, great!

I wonder what happens if you move while the countdown is counting?

240 according to the InSim.txt file. Values of 0-239 (inclusive) are permitted for the button ID:

Quote from InSim.txt :// BUTTONS
// =======

// You can make up to 240 buttons appear on the host or guests (ID = 0 to 239).

...

struct IS_BTN // BuTtoN - button header - followed by 0 to 240 characters
{
byte Size; // 12 + TEXT_SIZE (a multiple of 4)
byte Type; // ISP_BTN
byte ReqI; // non-zero (returned in IS_BTC and IS_BTT packets)
byte UCID; // connection to display the button (0 = local / 255 = all)

byte ClickID; // button ID (0 to 239)
byte Inst; // some extra flags - see below
byte BStyle; // button style flags - see below
byte TypeIn; // max chars to type in - see below

byte L; // left : 0 - 200
byte T; // top : 0 - 200
byte W; // width : 0 - 200
byte H; // height : 0 - 200

// char Text[TEXT_SIZE]; // 0 to 240 characters of text
};

i have had way more then 239 lol
Quote from Fire_optikz001 :i have had way more then 239 lol

I've noticed if I've got my drift meter on, Yisc[NL]'s pitboard, and a few other things at same time, I don't get all of Tim[NL]'s !gui loading - it's usually missing track choices and cars.

Once I close something else down (eg pitboard), then buttons appear ok.
Quote from sinanju :I've noticed if I've got my drift meter on, Yisc[NL]'s pitboard, and a few other things at same time, I don't get all of Tim[NL]'s !gui loading - it's usually missing track choices and cars.

Once I close something else down (eg pitboard), then buttons appear ok.

ye im working on a thing where u do lets say gui it whips the screen and when u close it reopens
sounds like fun to code

sinanju wanna help me test come to [SC] Cruise server
#19 - Hoxz
how to make it work on v 6.0 ?
I think the code in Post #1 for Version 5.8 should still work in Version 6.

FGED GREDG RDFGDR GSFDG