#displaying time until an event

1 messages · Page 1 of 1 (latest)

fringe tapir
#

I had some code for a timer but as many people told me, it is not very good. I wanted to replace it by a timer for events that happen every hour as a timer in scoreboard with minutes and seconds until something happens, a timer going down. Heres what I had, how could I go about replacing it with something more functional?

every 1 second:
add 1 to {timer_sec}
if {timer_sec} >= 59:
set {timer_sec} to 0
add 1 to {timer_min}
if {timer_min} >= 59:
set {timer_min} to 0
#the code u put here will proc every 1 hour

on join:
while player is online:
set line 3 of player's scoreboard to "⭐ <##FB08E1>M<##E920E4>a<##D739E6>p <##C451E9>R<##B26AEB>e<##A082EE>s<##8E9BF0>e<##7BB3F3>t <##69CCF5>I<##57E4F8>n:&c %59-{timer_min}%m %59-{timer_sec}%s"

dapper zinc
#

Just do difference between

#

And yes, that code is bad

fringe tapir
#

how could I do that? like how do I get the current time to compare it to the 1 hour

finite ice
#

set {x} to 1 hour from now

#

difference between x and now

fringe tapir
#

something like this?

every hour:
set {timer} to 1 hour from now
set {minutes} to {timer}-now

finite ice
#

difference between {timer} and now

#

But not like that

#

you have to set their scoreboard to difference between {timer} and now

fringe tapir
#

like this?

every hour:
set {timer} to 1 hour from now
set line 3 of player's scoreboard to "⭐ <##FB08E1>M<##E920E4>a<##D739E6>p <##C451E9>R<##B26AEB>e<##A082EE>s<##8E9BF0>e<##7BB3F3>t <##69CCF5>I<##57E4F8>n:&c %{timer}-now%m

finite ice
#

???

#

who's player

dapper zinc
#

finite ice
#

Also that's only ever going to update each hour

fringe tapir
fringe tapir
finite ice
#

what is scoreboard

#

now

#

Use a while loop

dapper zinc
#

The scoreboard isn’t set to anyone

fringe tapir
#

so I do need the "player's"?

dapper zinc
#

Yes

fringe tapir
#

why would I need a while loop?

dapper zinc
#

Cuz it’s best

fringe tapir
#

i dont get how I could do it with a while loop :/

signal igloo
#

on join . . . while player is online

fringe tapir
#

so like this?

#

every hour:
set {timer} to 1 hour from now
on join:
every second:
while player is online:
set line 3 of player's scoreboard to "⭐ <##FB08E1>M<##E920E4>a<##D739E6>p <##C451E9>R<##B26AEB>e<##A082EE>s<##8E9BF0>e<##7BB3F3>t <##69CCF5>I<##57E4F8>n:&c %{timer}-now%m %59-{timer_sec}%s"
wait 1 second

finite ice
#

what...

#

remove the every second part

fringe tapir
#

ok

#

and how could I display it as minutes/seconds?

finite ice
#

By reading the docs

#

I’d search “minutes of”