46 posts
Location
NWIndiana
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.
7508 posts
Location
Australia
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 )
1111 posts
Location
Portland 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
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.
7508 posts
Location
Australia
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…
46 posts
Location
NWIndiana
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.
686 posts
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.