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

always active 'reboot' button using bundle redstone input

Started by Andale, 16 January 2013 - 04:34 PM
Andale #1
Posted 16 January 2013 - 05:34 PM
looking to make the line below always active without just encapsulation my entire program inside of it

if rs.getInput ("top") = true then os.reboot

i realize that's not quite right, i am just trying to supply the simple example of what I've been trying to do.
I want to have a block on top of my computer with a button on the front, I want it to reboot my computer at any point in the program.
I was thinking something with parallel but I haven't gotten it to work yet.
theoriginalbit #2
Posted 16 January 2013 - 05:36 PM

function main()
  -- other code here
end

function listener()
   while true do
      if rs.getInput("top") then
        os.reboot()
      end
      sleep(0)
   end
end

parallel.waitForAll( listener, main )
Luanub #3
Posted 16 January 2013 - 05:38 PM
Would have to see your code to help you implement it.

One way if you've got a os.pullEvent() driven menu is pretty much do just as you have in you're post.

local e,p1 = os.pullEvent()
if e == "redstone" then
  if rs.getInput("top") then
    os.reboot()
  end
end


function main()
  -- other code here
end

function listener()
   while true do
	  if rs.getInput("top") then
		os.reboot()
	  end
	  sleep(0)
   end
end

parallel.waitForAll( listener, main )

Depending on the rest of the code the parallel may not be needed, it would be better to handle this within an if statement.
theoriginalbit #4
Posted 16 January 2013 - 05:40 PM
Depending on the rest of the code the parallel may not be needed, it would be better to handle this within an if statement.
Very true… there is the redstone event…
Andale #5
Posted 16 January 2013 - 05:54 PM
well, its far from finished and i wanted this for two other project ideas. This one is just an external reboot because I'm editing a startup on a disk from another computer so i can work from a view of the screen. Me being lazy, but only in this instance, I will actually need it for the others which will rely heavily on pullevents to do button presses. ie; press 'c' to continue. Thank you guys.
D3matt #6
Posted 16 January 2013 - 06:18 PM
well, its far from finished and i wanted this for two other project ideas. This one is just an external reboot because I'm editing a startup on a disk from another computer so i can work from a view of the screen. Me being lazy, but only in this instance, I will actually need it for the others which will rely heavily on pullevents to do button presses. ie; press 'c' to continue. Thank you guys.
If you're already pulling events, just add a line for redstone events.