(Added a disclaimer about the scope of this tutorial)
(Changed some second person and improved some of the article based on wiki standards)
Line 2: Line 2:
  
 
==List==
 
==List==
First, you need a [[list]]. A list is a feature which allows you to stall multiple values at once. Create a list called '''Dates''' or anything you want to call it.
+
First, the scratcher needs a [[list]]. A list is a feature which allows the program to stall multiple values at once. Create a list called '''Dates''' or anything else that is appropriate.
  
Okay, for each item in the list (except the last), it needs to be the last date of the months before the month of the event. The first item will have the last date of the current month and the last one will have the date of the event. For example, you're making a countdown to the next [[Scratch Day]] and it's currently March.
+
For each item in the list (except the last), it needs to be the last date of the months before the month of the event. The first item will have the last date of the current month and the last one will have the date of the event. For example, a scratcher might be making a countdown to the next [[Scratch Day]] and it's currently March.
  
 
<scratchblocks>
 
<scratchblocks>
Line 15: Line 15:
  
 
==Computing the Countdown==
 
==Computing the Countdown==
Here, you now have the list but the countdown isn't complete! Create a [[variable]] called '''Days left''' (since you're using days) or whatever you want to call it.
+
There is now a list but the countdown isn't complete! Create a [[variable]] called '''Days left''' (since the coder is using days) or something else if the scratcher wants to.
  
 
Back to your list, you need to have this script which completes the countdown. The first month will be the current month and the last month will be the month of the event. Here, you'll use March (3) as the first one and May (5) as the last one.
 
Back to your list, you need to have this script which completes the countdown. The first month will be the current month and the last month will be the month of the event. Here, you'll use March (3) as the first one and May (5) as the last one.

Revision as of 15:19, 7 February 2021

A countdown is a timer that reports how much time is left until an event will occur. Projects can also have countdowns too. Here's how to make one. Within the scope of this tutorial, the timer is counting down to an event at a specific date measured in days. Of course, timers can also be built to be compatible to seconds/minutes with either the built in timer feature or the minute block depending on what your project requires.

List

First, the scratcher needs a list. A list is a feature which allows the program to stall multiple values at once. Create a list called Dates or anything else that is appropriate.

For each item in the list (except the last), it needs to be the last date of the months before the month of the event. The first item will have the last date of the current month and the last one will have the date of the event. For example, a scratcher might be making a countdown to the next Scratch Day and it's currently March.

when gf clicked
delete (all v) of [Dates v]
add [31] to [Dates v]
add [30] to [Dates v]
add [9] to [Dates v]

Computing the Countdown

There is now a list but the countdown isn't complete! Create a variable called Days left (since the coder is using days) or something else if the scratcher wants to.

Back to your list, you need to have this script which completes the countdown. The first month will be the current month and the last month will be the month of the event. Here, you'll use March (3) as the first one and May (5) as the last one.

when gf clicked
if <(current [month v]) = (3)> then
replace item (1 v) of [Dates v] with ((item (1 v) of [Dates v]) - (current [date v]))
else
replace item (1 v) of [Dates v] with (0)
if <(current [month v]) = (4)> then
replace item (2 v) of [Dates v] with ((item (2 v) of [Dates v]) - (current [date v]))
else
replace item (2 v) of [Dates v] with (0)
if <(current [month v]) = (5)> then
replace item (3 v) of [Dates v] with ((item (3 v) of [Dates v]) - (current [date v]))
end
end
end
set [Days left v] to ((item (1 v) of [Dates v]) + ((item (2 v) of [Dates v]) + (item (3 v) of [Dates v])))

Congratulations! You created your own countdown!

Cookies help us deliver our services. By using our services, you agree to our use of cookies.