wanou067 0 Posted January 10, 2019 Share Posted January 10, 2019 Hello, (I don't speak english very well, sorry in advance for errors) I need a program to controll an iron with the in-game time. But i d'ont know how to ask to the computer the in-game time, someone can build a simple program to turn on redstone signal at 6AM, and turn it off at 8PM ? I need the program will be easy to understand, and esay ton configure, annotations are good for this Thank you in advance, bye ! Quote Link to post Share on other sites
0 Molinko 43 Posted January 11, 2019 Share Posted January 11, 2019 I made you a 'simple' program that does what you ask. Create a file in the /home dir of your computer called 'timer.lua' with the code below as the file contents and save it. -- # Lua timer for OC forum member local sides = require 'sides' local thread = require 'thread' local component = require 'component' local setOutput = component.redstone.setOutput local time local side = ... -- # set redstone output to back by default if not side or not sides[side] then side = 'back' end local proc = thread.create(function() while true do time = os.date('*t') if time.hour >= 6 and time.hour < 20 then setOutput(sides[side], 15) elseif time.hour < 6 or time.hour >= 20 then setOutput(sides[side], 0) end os.sleep(10) -- # update every 10 seconds end end) proc:detach() -- # background this timer after start Type edit .shrc in the command prompt and add the line timer.lua side and save the file Note: replace side above with a valid side string like 'back' or 'south' etc.. and restart the computer or execute the program with timer.lua side like in the .shrc file. The .shrc file will execute this program on startup for you whenever the computer restart from a shutdown or a crash. Cheers Quote Link to post Share on other sites
Hello, (I don't speak english very well, sorry in advance for errors)
I need a program to controll an iron with the in-game time.
But i d'ont know how to ask to the computer the in-game time,
someone can build a simple program to turn on redstone signal at 6AM, and turn it off at 8PM ?
I need the program will be easy to understand, and esay ton configure, annotations are good for this
Thank you in advance, bye !
Link to post
Share on other sites