Posted 20 September 2013 - 03:10 AM
Hello all,
thought I would post this little program I put together. Basically, I use computers instead of timers to pulse machines. This program allows me to set up a computer as a pulser, which will survive server restarts, etc.
Feedback would be great as this is the first program I have posted!
http://pastebin.com/T0STJ1UM
thought I would post this little program I put together. Basically, I use computers instead of timers to pulse machines. This program allows me to set up a computer as a pulser, which will survive server restarts, etc.
Feedback would be great as this is the first program I have posted!
Spoiler
local tArgs = {...}
local program = shell.getRunningProgram()
os.setComputerLabel("pulser")
if fs.exists("pulseLog") then
h = fs.open("pulseLog", "r")
log = textutils.unserialize(h.readAll())
h.close()
sSide = log[1]
duration = log[2]
sInterval = tonumber(duration)/2
else
if not tArgs[1] then
print("Set parameters: <side> <pulse interval>")
return
end
sSide = tArgs[1]
duration = tArgs[2]
sInterval = tonumber(duration)/2
h = fs.open("pulseLog", "w")
h.write(textutils.serialize(tArgs))
h.close()
h = fs.open("startup", "w")
h.write("shell.run(\""..program.."\")")
h.close()
end
while true do
term.clear()
term.setCursorPos(1,1)
print("Pulsing "..sSide.." every "..duration.." seconds.")
rs.setOutput(sSide, true)
sleep(sInterval)
rs.setOutput(sSide, false)
sleep(sInterval)
end
http://pastebin.com/T0STJ1UM