This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Raxe88's profile picture

Simple Time reset program

Started by Raxe88, 08 December 2012 - 08:02 AM
Raxe88 #1
Posted 08 December 2012 - 09:02 AM
Hello! This is my first topic so I hope everyone likes it :)/>

This is a very simple program that gets the time with os.time(), checks if it is 6:00 PM (ingame time) and it resets it with a Command block (/time set 0) It also prints out if it changes or still not and the current time.

The code:


while true do
term.clear()
term.setCursorPos(1,1)
time = textutils.formatTime(os.time(), false)
if time == "6:00 PM" then
  print("Now")
  rs.setOutput("left", true)
  sleep(1)
  rs.setOutput("left", false)
else
  print("Not yet")
end
print(time)
sleep(1)
end

The Pastebin: http://pastebin.com/Lmy1x8VJ

To get it directly from pastebin do ingame:


pastebin get Lmy1x8VJ timecontrol

How to use it:
1. Use the pastebin command in the computer o simply copy it to a new program
2. Place a Command Block where you want next to the compute
3. In the Command Block put the command: /time set 0
4. Enter the code and change the position of the output side of redstone and the time (optional)
5. Enjoy the sun

Thank you! :D/>
tman1123 #2
Posted 02 July 2013 - 03:36 AM
If you want to make this program work without a command block you can go into your your config and set command block to true.
Then you can use these commands.

Hope this helps you for future ideas!

I did it to show you.




 

while true do
term.clear()
term.setCursorPos(1,1)
time = textutils.formatTime(os.time(), false)
if time == "6:00 PM" then
  print("Now")
  commandBlock.setCommand("time set 0")
  sleep(1)
else
  print("Not yet")
end
print(time)
sleep(1)
end

chrdov #3
Posted 03 July 2013 - 11:39 AM
you have to attach a command block to your terminal and do this before using the command block as a PERIPHERAL:

commandBlock = peripheral.wrap(<commandBlock's Relative Side>)
AND THEN You Can Use Functions Like this, in your Program Modification, tman (I Hope you read this Post, tman. It Will Help You!):

commandBlock.setCommand("time set 0")
commandBlock.runCommand() -- Runs The Command in The Wrapped Block.