| View previous topic :: View next topic |
| Author |
Message |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Tue Feb 24, 2015 12:01 pm Post subject: Is It Possible ?? |
|
|
I run a script where people have a certain time to perform a task.
The task starts monday 1 min past midnight and ends sunday midnight what i would like to do is something like this as a point of reference for them
If it was monday the guys would have 7 days to go
If it was tuesday the guys would have 6 days to go etc etc
so as the week progresses the display would show
7 Day/s Left to go
6 Day/s Left to go
5 Day/s Left to go
4 Day/s Left to go
and tomorrow it would show
3 Day/s Left to go
im a total noob and wondered if it could be done
many thx in advance |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Feb 24, 2015 12:38 pm Post subject: Re: Is It Possible ?? |
|
|
| COBRa wrote: |
...
so as the week progresses the display would show
...
|
When? Once? Right after midnight? .... or what? |
|
| Back to top |
|
 |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Tue Feb 24, 2015 12:43 pm Post subject: |
|
|
the countdown for the week would be constantly displayed so as the week progresses it would count down by day until the week is over
so as of sunday 00.01 the display would show
7 day/s to go
then as of monday 00.01 the display would show
6 day/s to go and so on till the week is over then then rest itsself as to start again
hope tht makes sence |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Feb 24, 2015 2:16 pm Post subject: |
|
|
| COBRa wrote: | the countdown for the week would be constantly displayed so as the week progresses it would count down by day until the week is over
so as of sunday 00.01 the display would show
7 day/s to go
then as of monday 00.01 the display would show
6 day/s to go and so on till the week is over then then rest itsself as to start again
hope tht makes sence |
Not really.
You said, "constantly" - which means just that. Basically - a flood. Making an announcement something like once per every two seconds.
Then you re-iterated what you had already said, pretty much. That part says that you want it to announce once per day.
But anyway - here you go:
| Code: |
# Feb. 24, 2015
# http://forum.egghelp.org/viewtopic.php?p=103540#103540
###########
#set the channel in which to do the announcement
set announce_chan #eggdrop
###########
###########
bind cron - "01 00 * * 0" sunday_announce
bind cron - "01 00 * * 1" monday_announce
bind cron - "01 00 * * 2" tuesday_announce
bind cron - "01 00 * * 3" wednesday_announce
bind cron - "01 00 * * 4" thursday_announce
bind cron - "01 00 * * 5" friday_announce
bind cron - "01 00 * * 6" saturday_announce
proc sunday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :7 day/s to go"
}
proc monday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :6 day/s to go"
}
proc tuesday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :5 day/s to go"
}
proc wednesday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :4 day/s to go"
}
proc thursday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :3 day/s to go"
}
proc friday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :2 day/s to go"
}
proc saturday_announce {min hour day month weekday} {
global announce_chan
putserv "privmsg $announce_chan :1 day to go"
}
|
This should make the announcement at 1 min past midnight.
Once daily.
With very brief testing, it works for me.
Test it.
I hope this helps. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Feb 24, 2015 2:19 pm Post subject: |
|
|
Here is another way to do it.
There are probably lots more, too.
| Code: |
# Feb. 24, 2015
# http://forum.egghelp.org/viewtopic.php?p=103540#103540
####
#set the channel in which to do the announcement
set announce_chan #eggdrop
###########
bind cron - "01 00 * * *" days2go_announce
proc days2go_announce {min hour day month weekday} {
global announce_chan
if {[strftime %u] == "6"} {
putserv "privmsg $announce_chan :1 day to go"
}
if {[strftime %u] == "5"} {
putserv "privmsg $announce_chan :2 days to go"
}
if {[strftime %u] == "4"} {
putserv "privmsg $announce_chan :3 days to go"
}
if {[strftime %u] == "3"} {
putserv "privmsg $announce_chan :4 days to go"
}
if {[strftime %u] == "2"} {
putserv "privmsg $announce_chan :5 days to go"
}
if {[strftime %u] == "1"} {
putserv "privmsg $announce_chan :6 days to go"
}
if {[strftime %u] == "0"} {
putserv "privmsg $announce_chan :7 days to go"
}
}
|
|
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Tue Feb 24, 2015 3:41 pm Post subject: |
|
|
Yeah, instead of multiple if statements you could go with switch. Apart this, good idea willyw.
I was thinking at something similar to be honest when read the first post, but after I have read your post I was thinking why not get creative and pull a rabbit out of the hat.
| Code: |
bind cron - "01 00 * * *" days2go:announce
proc days2go:announce {min hour day month weekday} {
set days [expr 7 - [strftime %u]]
puthelp "privmsg #announce_chan :[expr {$days==1?"1 day":"$days days"}] to go!"
}
|
Not 100% sure and can't test right now, but i think we can use $day variable as well but I'd expect it to have an leading zero, but no problem with that.  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Tue Feb 24, 2015 4:01 pm Post subject: |
|
|
| caesar wrote: |
Yeah, instead of multiple if statements you could go with switch. Apart this, good idea willyw.
|
I was hoping that it might be so easy to follow that the original poster would be wanting to explore learning some basic TCL for him/her self.
| Quote: |
...
Not 100% sure and can't test right now, but i think we can use $day variable as well but I'd expect it to have an leading zero, but no problem with that.  |
Did you mean to say $weekday?
If so, then yes - I had flirted with using it, instead of strftime. I believe it does contain a leading zero, and I don't know what it does on Sunday, and didn't want to try to change dates on a shell, etc. to experiment and find out. Then there may have been need to deal with the leading zero, and I just wanted the thing to be so simple that the flow of what was going on was easy to see.
I hope it works out for the original poster, and that they jump in and try some basic TCL soon.
 |
|
| Back to top |
|
 |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Wed Feb 25, 2015 5:14 am Post subject: |
|
|
many thx guys both versions work for me im in the process of adding to my script with a couple of modifications once i get it running i'll post the final draft or report any difficulties
Many thx once again |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Feb 25, 2015 10:04 am Post subject: |
|
|
The expr will have no problem with any leading zeroes. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Thu Feb 26, 2015 3:26 pm Post subject: |
|
|
| Code: |
bind cron - "01 00 * * *" days2go:announce
proc days2go:announce {min hour day month weekday} {
set days [expr 7 - [strftime %u]]
puthelp "privmsg #announce_chan :[expr {$days==1?"1 day":"$days days"}] to go!"
}
|
Using this code instead of the announce line is it possible to make a variable so I can incorporate it into another announce line? |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Fri Feb 27, 2015 2:17 am Post subject: |
|
|
Sure, just move out the
| Code: |
[expr {$days==1?"1 day":"$days days"}]
|
to a variable
| Code: |
set days2go [expr {$days==1?"1 day":"$days days"}]
|
like this, and if you want to use $days2go in another proc then define it globally
| Code: |
proc days2go:announce {min hour day month weekday} {
global days2go
... rest of the code
|
and the same global days2go in any other proc you want. _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Fri Feb 27, 2015 7:52 am Post subject: |
|
|
| Many thx for the swift reply but I have an issue is bind cron supported in ver 1.6.21 as it kills the bot when I add the cron line if not could it be done with bind time plz |
|
| Back to top |
|
 |
willyw Revered One
Joined: 15 Jan 2009 Posts: 1175
|
Posted: Fri Feb 27, 2015 9:11 am Post subject: |
|
|
| COBRa wrote: |
... is bind cron supported in ver 1.6.21...
|
Yes.
| Quote: |
...as it kills the bot...
|
This is not enough information for us to be able to try to help you.
Describe everything that you see when it happens.
Especially from the partyline. (Check your console flags, and be sure that any that could possibly help you see things, are On.)
| Quote: |
...when I add the cron line ...
|
This is not enough information for us to be able to try to help you.
Show us the line(s) in question.
| Quote: |
... if not could it be done with bind time plz |
Maybe. We can't guess as to which way might be best, until we see what you are trying to do.
You mentioned that you have modified the code from what I wrote. If the cron bind is somehow causing a problem, I'm assuming that is part of what you modified, because it did not cause a problem when I quickly tested it. I tested it on a version 1.6.21 bot. |
|
| Back to top |
|
 |
COBRa Halfop
Joined: 04 Jan 2013 Posts: 49
|
Posted: Sat Feb 28, 2015 8:27 am Post subject: |
|
|
| many thx guys for all your help ive got it working just fine now |
|
| Back to top |
|
 |
|