24 posts
Posted 13 July 2012 - 03:58 AM
I basically wanna do what the topic says. I have red insulated wires (RedPower Mod) hooked up to thermal monitors (IC2). When the thermal monitor is activated, the redstone is powered from the insulated cable, to bundled wires, that hook into the back of a computer. How would I get that to perform a function on a monitor next to the computer. In this case, lets say the function stops everything you are doing, and says Warning! Reactor overheating!
504 posts
Location
Seattle, WA
Posted 13 July 2012 - 05:07 AM
Well, if you wanted to check if the redstone was active and then display the message of your choice (I think that's what your asking? :)/>/>), then you could either use a boolean variable (true/false) to toggle the redstone and also tell whether or not it was on.
Another solution would be to use the rs.getInput() function. However, I think that this may not work because your computer is generating the pulse as opposed to acting as medium for the current.
Try this: (boolean approach)
Spoiler
bPulse = false; -- This variable will hold the 'true/false' value of the redstone pulse that is generated.
while true do
print( "Press any key to toggle the redstone" );
local event, key = os.pullEvent("key"); -- This will wait until a key event is triggered. (A key is pressed).
bPulse = not bPulse; -- This will reverse whatever state the variables is in: true -> false, false -> true.
if bPulse then rs.setOutput("back", true); -- This will generate a redstone pulse from the selected side of the computer.
else rs.setOutput("back", false); end -- This will shut off the pulse if bPulse is false.
print( "Redstone: "..bPulse ); -- This will print out the value of the bPulse variable.
print(""); print(""); -- Go down to lines for the next iteration of the loop.
end
Go into your computer and type this command: monitor <side> <whatever you named this program>I hope I helped! B)/>/>
8543 posts
Posted 13 July 2012 - 05:41 AM
I basically wanna do what the topic says. I have red insulated wires (RedPower Mod) hooked up to thermal monitors (IC2). When the thermal monitor is activated, the redstone is powered from the insulated cable, to bundled wires, that hook into the back of a computer. How would I get that to perform a function on a monitor next to the computer. In this case, lets say the function stops everything you are doing, and says Warning! Reactor overheating!
You're probably going to want to use the parallel API to monitor the redstone input (pulling redstone events will be the best way to do this) and print the appropriate message if you're planning on using the computer for other things. If this is a dedicated computer, you'll just need to have a program to pull redstone events and act appropriately. The dedicated computer case is far easier than if you still want to use the computer for other things:
while true do
os.pullEvent("redstone")
if rs.testBundledInput("back", colors.blue) then
print("OMFG OVERHEAT!")
else
print("BACK UNDER CONTROL, YO."
end
end