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

Redstone Triggered Reactor Timer

Started by Nuxem, 05 May 2013 - 03:12 AM
Nuxem #1
Posted 05 May 2013 - 05:12 AM
Hello everyone, after reviewing many of the already stated timer programs that have been created here, I have managed to get a cursory understanding of how the variable timer works however it appears that nobody has integrated this with a redstone based trigger. The desire/need for such a program just came out of using Nuclear Reactors with IC2/Gregtech (FTB Ultimate), especially with reactors above Mark-I where the risk of detonation is possible- despite the fact there are alarms and thermal detection devices I like the idea of a timer broadcasting the reactor's cycle time.
I'm really looking forward to seeing if anyone can come up with a solution to this (well I see it as practical) usage of CC.

Conditions
1) Redstone Triggered to start an Adjustible timer
2) Displays remaining time to a monitor
3) Outputs Redstone signal upon timer reaching Zero
4) Program then resets awaiting next redstone signal
Lyqyd #2
Posted 05 May 2013 - 12:21 PM
Split into new topic.
GreatOak #3
Posted 08 May 2013 - 06:02 PM
I would look into the Nuclear Information Reader since you are in ultimate pack. You would do something like this:

nir = peripheral.wrap("left") --Side of Nuclear Info Reader
mon = peripheral.wrap("top") --Side of Monitor
nirInfo = nir.get(1)
function resetScreen(bgColor,txtColor)
  term.clear()
  term.setCursorPos(1,1)
  term.setBackgroundColor(bgColor)
  term.setTextColor(txtColor)
end
for system,status in pairs(nirInfo) do
  status = tostring(status)
  print("System: "..system.." Status: "..status)
end
The only command a Nuclear Info Reader can do is nir.get(arg) which returns a table that you have to extract with a for loop. Basically you will want to have a while true loop with a constant nir.get() then a couple of functions that will broadcast that table's info if you are using a red net system. I have an example that isn't quite working, but the idea is there. I just messed up on the button part. Here is the code I put together:
Spoiler

monitor =  peripheral.wrap("top")
monitor.clear()
nir = peripheral.wrap("left")
local nuke = paintutils.loadImage("nuke")
os.loadAPI("disk/buttons")
addButton("NuclearReactorToggle",no,reactorToggle,colors.yellow,colors.yellow,colors.black,1,1,25,1)
function reactorToggle()
  rednet.open("bottom")
  if reactorNumb == 1 then
	rednet.send(255,on)
  elseif reactorNumb == 2 then
	rednet.send(254,on)
  elseif reactorNumb == 3 then
	rednet.send(254,on)
  elseif reactorNumb == 4 then
	rednet.send(253,on)
  end
end

--System Functions

function heat()
for system,status in pairs(info) do
  status = tostring(status)
  max = 500
  if system == "heat" then
	monitor.setCursorPos(1,3)
	monitor.setTextColor(colors.yellow)
	print("*")
	monitor.setCursorPos(1,5)
	print("*")
	monitor.setTextColor(colors.white)
	monitor.setCursorPos(2,3)
	print(" Reactor Heat Level = "..status)
	monitor.setCursorPos(2,5)
	print(" Reactor Max Heat = "..max)
	monitor.setTextColor(colors.yellow)
	monitor.setCursorPos(27,5)
	print("+")
	monitor.setTextColor(colors.white)
	monitor.setCursorPos(28,5)
	print(" or ")
	monitor.setCursorPos(33,5)
	monitor.setTextColor(colors.yellow)
	print("-")
  end
end
end
function reactorPower()
for system,status in pairs(info) do
  status = tostring(status)
  if system == "reactorPoweredB" then
	monitor.setBackgroundColor(colors.yellow)	
	monitor.setTextColor(colors.black)
	monitor.setCursorPos(1,1)
	for name,data in pairs(disk/buttons) do
	  local on = data["active"]
	  if on == true then
		reactorStatus = "on"
	  else
		reactorStatus = "off"
	  end
	end
	print("Nuclear Reactor #"..reactorNumb.." = "..reactorStatus)
	monitor.setCursorPos(1,18)
	print("Back")
	monitor.setCursorPos(28,18)
	print("Page Forward")
	monitor.setBackgroundColor(colors.black)
  end
end
end
function output()
for system,status in pairs(info) do
  status = tostring(status)
  if system == "output" then
	monitor.setTextColor(colors.yellow)
	monitor.setCursorPos(1,7)
	print("*")
	monitor.setTextColor(colors.white)
	monitor.setCursorPos(2,7)
	print(" EU Output = "..status)
  end
end
end
function timeLeft()
for system,status in pairs(info) do
  status = tostring(status)
  if system == "timeLeft" then
	monitor.setTextColor(colors.yellow)
	monitor.setCursorPos(1,9)
	print("*")
	monitor.setTextColor(colors.white)
	monitor.setCursorPos(2,9)
	print(" Uranium Cells level = "..status)
  end
end
end
function nuclear(numbNuke)
  noth1, noth2, card, info = nir.get(numbNuke)
  reactorNumb = numbNuke
  term.redirect(monitor)
  monitor.clear()
  monitor.setBackgroundColor(colors.black)
  heat()
  reactorPower()
  output()
  timeLeft()
  term.restore()
end

--Load Screen Function

local function loadScreen()
  monitor.clear()
  term.redirect(monitor)
  monitor.setTextColor(colors.white)
  monitor.setBackgroundColor(colors.black)
  monitor.setCursorPos(9,1)
  textutils.slowWrite("Nuclear Reactor Controls")
  paintutils.drawImage(nuke,-4,2)
  monitor.setCursorPos(1,15)
  textutils.slowWrite("(Right Click Screen to go edit Reactor)")
  while os.pullEvent("monitor_touch") == false do
	sleep(0)
  end
  monitor.clear()
  term.restore()
end

--Load Screen Function

loadScreen()

--Nuclear #1 Display/Controls

nuclear(1)
while true do
  nuclear(1)
  buttonLoop()
  sleep(0)
end
PS I used a button api for this. If you want the code just go to my profile and click content, and there are the pastebins.
This is my example of using a nuclear info reader peripheral. I know it isn't timed out, but I'm sure someone could expand on my idea.