so i used a bunch of code from someone else on the site to import the date and time but i dont know lua, i only know a bit of c++
Basicly what i want to use this for is so that at a certain time(s) i can send out a redstone signal to a command block to restart my server.
anyone able to help?
rl time and date, and using it as a basis for in game events
Started by Redd56, Mar 21 2018 08:49 AM
networking utility help
6 replies to this topic
#1
Posted 21 March 2018 - 08:49 AM
#2
Posted 21 March 2018 - 09:28 AM
If you're on ComputerCraft 1.7 or later, you may be better off using a Command Computer. This would lower the risk of a player accessing and activating the command block directly (some other mods these days let them drill through bedrock), and there's also the whole issue where turning on a redstone signal may send your server into a reboot loop (as the code to turn the signal off may never get a chance to run).
Although, there's no command block command to restart a server in vanilla, and Command Computers don't always get access to additional commands added by other mods.
How complex your code will be hinges on whether the date matters at all, whether you want to set more than one restart point in a day, whether those restart points will be evenly spaced or not, and whether you want to delay restarting when players are online (seriously, most servers don't need daily reboots, and doing them while people are trying to play is more annoying than it is practical).
A really simple way of doing it would be to just say "let's have the server reboot every three hours", which would just be a matter of:
There are server extensions which could handle this better and more simply than automated server commands can, though, including the whole "don't reboot while players are online" thing. I'm afraid I don't have direct experience with these, but they're worth researching.
Although, there's no command block command to restart a server in vanilla, and Command Computers don't always get access to additional commands added by other mods.
How complex your code will be hinges on whether the date matters at all, whether you want to set more than one restart point in a day, whether those restart points will be evenly spaced or not, and whether you want to delay restarting when players are online (seriously, most servers don't need daily reboots, and doing them while people are trying to play is more annoying than it is practical).
A really simple way of doing it would be to just say "let's have the server reboot every three hours", which would just be a matter of:
rs.setOutput("back", false)
sleep(10800) --# 10,800 seconds == three hours
rs.setOutput("back", true)
There are server extensions which could handle this better and more simply than automated server commands can, though, including the whole "don't reboot while players are online" thing. I'm afraid I don't have direct experience with these, but they're worth researching.
#3
Posted 21 March 2018 - 07:45 PM
i was more wanting to have it happen at a certain time of day, as the reboot actualy takes time itself, also how would i have the program always running
#4
Posted 21 March 2018 - 09:21 PM
here let me post a link to the original code
http://www.computerc...h-a-rl-datetime
This is the code i used, (the stuff in the spoiler) i am mostly just wanting to find a way to extract the time out of it every so often and set up a timed signal for it.
http://www.computerc...h-a-rl-datetime
This is the code i used, (the stuff in the spoiler) i am mostly just wanting to find a way to extract the time out of it every so often and set up a timed signal for it.
#5
Posted 22 March 2018 - 09:38 AM
If you are on latest CC you may want to try: https://github.com/d...mment-299637976
#6
Posted 24 March 2018 - 10:19 PM
Lupus590, on 22 March 2018 - 09:38 AM, said:
If you are on latest CC you may want to try: https://github.com/d...mment-299637976
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











