Jump to content

Hello i need help with Countdown Timer script


Tzimix
 Share

You are about to reply to a thread that has been inactive for 1047 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello community

I allow myself a small message because I'm looking for a timer script in your inventory if ever.

I need to be able to put the script in a prim to wear like a hud and be able to click on it to open a menu that offers me different timer style countdown.

The ideal would be with a loops option (that I can activate or deactivate in my menu) which means that for example if I put the timer at 30 minutes arrived at the end of 30 minutes it starts again on a timer automatically.

I hope I have not lost you in my explanations, here is a small image to show the style of the timer.

i347.png

 

 many thanks in advance

 

Tzimix

 

Link to comment
Share on other sites

You can monitor time with llGetTime, which tell you the number of seconds that have elapsed since the script was reset or since you told it to llResetTime.  So, you can keep track of time by triggering a timer event with llSetTimerEvent(1.0)  and then

timer()
{
    integer time = llGetTime();
    // Display the time in your display, possibly breaking it into minutes and seconds first ...  then check ...
    if ( time >= 1800)  // So, 30 seconds have passed since you started the timer ...
    {
        llResetTime();  // This will reset the timer if 30 minutes (1800 seconds) have passed
    }
}

You can start or stop the timer by putting that llSetTimerEvent command in a toggle switch in your touch_start event:

touch_start(integer num)
{
    llResetTime();
    llSetTimerEvent( 1.0 * (iON = !iON) );   // Where you have previously defined iON as a global integer variable
}

 

Link to comment
Share on other sites

20 minutes ago, Rolig Loon said:

You can monitor time with llGetTime

Depending on the "importance" of the timer, I wouldn't rely on llGetTime() for macro-scale time lengths (a purposefully vague term for times greater than a handful of minutes).

llGetUnixTime() or llGetTimestamp() (sub-second precision) would be better options here; both of those would continue to run if packed away in your inventory though, which may or may not be desired behavior.

Link to comment
Share on other sites

36 minutes ago, Quistess Alpha said:

Depending on the "importance" of the timer, I wouldn't rely on llGetTime() for macro-scale time lengths (a purposefully vague term for times greater than a handful of minutes).

llGetUnixTime() or llGetTimestamp() (sub-second precision) would be better options here; both of those would continue to run if packed away in your inventory though, which may or may not be desired behavior.

I agree. I'd use llGetUnixTime myself if I were interested in precision or if it were more than the 30 minute stopwatch that the OP described.  For casual use, though, llGetTime is adequate, and it does automatically reset if you take the device back to your inventory. ;) 

  • Like 1
Link to comment
Share on other sites

Hello and thank you for your answers.


How is it possible to make a timer with the display like on the picture seen above? Display the timer coldown of 10,20,30 minutes, but not in hovertext?


If any of you have this style of timer in full perm, it would be great.


Many thanks ^^

 

i347.png

Link to comment
Share on other sites

2 hours ago, Tzimix said:

How is it possible to make a timer with the display like on the picture seen above?

What you are looking at is a prim or several prims with individual faces onto which a set of different textures can be shown. If you create a single texture on which you have the digits 0 through to 9 then by applying a portion of that texture to a particular face you can show any of the digit.

If you have the ability to make such a texture, and the ability to work with simple scripts then there are people here who will help you make such a timer. It isn't actually difficult to do if you make a good texture that is nicely proportioned so that the maths for the texture offsets and repeats doesn't require any awkward corrections.

Link to comment
Share on other sites

32 minutes ago, Profaitchikenz Haiku said:

If you have the ability to make such a texture

For anyone on a system with easy access to ImageMagick (a dependency of many free image editors, including gimp) and a shell, (I.E linux, or maybe mac) I put together a set of shell scripts that generate such a texture:

#fixed.sh
#make a single letter/symbol texture
convert -background black -fill white -font fixed -size 128x128 -gravity center label:$1 $1.pnm
#iterate.sh
#generate .pnm images for each ascii symbol and a bunch of numbers. 
#.pnm is needed because it does not contain label metadata which would mess up the tiling step.
for i in {10..127}; do . ./fixed.sh $i ; done
convert -size 32x32 canvas:black " .pnm"
for i in {!..\)}; do . ./fixed.sh $i ; done
convert -background black -fill white -font fixed -size 32x32 -gravity center label:"*" "\*.pnm" #because \ in other script.
for i in {+...}; do . ./fixed.sh $i ; done
convert -background black -fill white -font fixed -size 32x32 -gravity center label:"/" "forward_slash.pnm"
for i in {0..\>}; do . ./fixed.sh $i ; done
convert -background black -fill white -font fixed -size 32x32 -gravity center label:"?" "\?.pnm" # because \ in other script.
for i in {@..\[}; do . ./fixed.sh $i ; done
convert -background black -fill white -font fixed -size 32x32 -gravity center label:"\\\\" "\\.pnm"
for i in {\]..~}; do . ./fixed.sh $i ; done
#tile.sh
# make all the files into a single image
montage {0..127}.pnm {\ ..\)}.pnm "\*.pnm" {+...}.pnm ./forward_slash.pnm {0..9}.pnm {:..\>}.pnm ./\\\?.pnm ./{@..~}.pnm  -tile 16x16 -geometry 32x32+0+0 out.png

It's annoyingly verbose because special characters are special. Make sure to run in a directory that you don't mind polluting with a lot of small files.

could be improved by 0-padding the first set of 0-9, and you'll want to fill in the unused whitespace at the bottom of the texture with black in an image editor.

  • Like 1
Link to comment
Share on other sites

I was going to post my train timer which does exactly what the OP has asked for, but then I realised I made up a special mesh for it that might be outside the OP's toolset. I'll probably put the script and texture up anyway as an example of a simple minute and seconds timer, but I do like your method of generating the texture.

I made mine by putting prims together in SecondLife with a single digit on each, positioning them by script, and then grabbing screencaps looking down vertically with the sun set to midday to ensure even illumination. 

 

"Polluting directories with lots of small files" is where Linux scores over NTFS, because there's no minimum cluster size allocated to such small files.

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

Snippet and texture showing a timer display to handle 0 to 5 mins 55 seconds in 5 seconds granularity

Snippets for a three-face counter, the 4th face is the timer background and includes the colon separating minute face from seconds faces

The eagle-eyed will notice that the offset figures do not follow the expected sequence, I jiggled the values empirically until they looked right, using precise figures resulted in them looking a bit out of line

// handle digits display

string digits = "timer digits"; // name of texture

vector reps = <0.25, 0.5, 0.0>; // texture repeats to access sub-portion of image

list texParams = [  -0.35031, 0.22002,      // blank = 0
                    -0.16012, 0.22002,      // 0        2
                     0.10010, 0.22002,      // 1        4
                     0.34031, 0.22002,      // 2        6
                     -0.37015, -0.26005,    // 3        8
                     -0.16012, -0.26005,    // 4        10
                     0.10010, -0.26005,     // 5        12
                     0.34009, -0.26005      // -        14
                     ];
                     
                     
integer minsFace = 6;
integer secsHighFace = 1;
integer secsLowFace = 2;


setDigit(integer digit, integer face)
{
    // double the digit,. add 2, so that 0 = 2, 1 = 4, 2 = 6, 3 = 8, 4 = 10, 5 = 12, leaving blank -1 => 0 and - 6 > 14
    integer ind = digit * 2 + 2;
    vector offset = <llList2Float(texParams, ind), llList2Float(texParams, ind+1), 0.0>;
    
    llSetLinkPrimitiveParamsFast(LINK_THIS, [PRIM_TEXTURE, face, digits, reps, offset, 0.0]);
    
}

blankDisplay()
{
    setDigit(-1, minsFace);
    setDigit(-1, secsHighFace);
    setDigit(-1, secsLowFace);  
}

 

The texture: ( the dashes are used for effect when changing times by momentarily setting the digit to be changed to a dash then too the new digit to give a railwaylike effect)

 

timer digits.png

Edited by Profaitchikenz Haiku
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1047 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...