Jump to content




always active 'reboot' button using bundle redstone input


  • You cannot reply to this topic
5 replies to this topic

#1 Andale

  • Members
  • 46 posts
  • LocationNWIndiana

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.

#2 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

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 )


#3 Luanub

    Lua Nub

  • Members
  • 1,135 posts
  • LocationPortland OR

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

View PostTheOriginalBIT, on 16 January 2013 - 05:36 PM, said:

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.

#4 theoriginalbit

    Semi-Professional ComputerCrafter

  • Moderators
  • 7,332 posts
  • LocationAustralia

Posted 16 January 2013 - 05:40 PM

View PostLuanub, on 16 January 2013 - 05:38 PM, said:

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...

#5 Andale

  • Members
  • 46 posts
  • LocationNWIndiana

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.

#6 D3matt

  • Members
  • 830 posts

Posted 16 January 2013 - 06:18 PM

View PostAndale, on 16 January 2013 - 05:54 PM, said:

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.





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users