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

Help With Detecting Redstone

Started by musicgack, 07 June 2012 - 06:07 AM
musicgack #1
Posted 07 June 2012 - 08:07 AM
On Ic2 Nuclear Control How Can You Do This:

Lets Say A Redstone Current Comes To The Computer So, How Can You Make That Control A Monitor

Redstone Inputs:

Back
Right
Bottom

How Can You Make It Show Up This:

Back = print("2000")

Right = print("4000")

Bottom = print("6000")

On Montior With Size Of Text Big?

=============================
Nuclear Reactor Heat:

(Number Here)

=============================

Can You Try To Make A Code For Me?

-musicgac
Lolgast #2
Posted 07 June 2012 - 09:55 AM
local heat = nil
os.pullEvent("redstone")
if rs.getInput("back") and heat = nil then
 heat = 2000
elseif rs.getInput("right") and heat = 2000 then
 heat = 4000
elseif rs.getInput("bottom") then
 heat = 6000
end
monitor = peripheral.wrap(<side>) --replace <side> with the side of the monitor
term.redirect(monitor) --set output to monitor
print("==================")
print("Nuclear reactor heat:")
print(heat)
print("==================")
term.restore() --set the input back to the console
Don't have a computer with cc right now, but I think it should work.Oh, and btw, it's a bit annoying if you start every word with capital letters.
musicgack #3
Posted 26 June 2012 - 07:53 AM
Sorry, well do you need to have ccsensors?
musicgack #4
Posted 26 June 2012 - 07:59 AM
Don't have a computer with cc right now, but I think it should work.Oh, and btw, it's a bit annoying if you start every word with capital letters.
Ok ill try not to it is a habbit
musicgack #5
Posted 26 June 2012 - 08:40 AM
It Says "bios:206: [string "test"]:3: 'then' expected

(I Named The Program Test)
Lyqyd #6
Posted 26 June 2012 - 06:49 PM
Lines three and five should have heat == instead of heat =.
musicgack #7
Posted 01 July 2012 - 04:44 PM
It does not work because the "heat" does not change it will stay at 2000, and can you make it in a loop?
Lyqyd #8
Posted 01 July 2012 - 06:15 PM
Yes, you can. Just use a while loop.
musicgack #9
Posted 02 July 2012 - 02:38 AM
How about the "heat" not changing? it stays at 2000
Lyqyd #10
Posted 02 July 2012 - 06:05 AM
These lines should be in this order, not the other way around.


local heat = nil
while true do

Though, with that code, it won't change back down.


local heat = 0
term.redirect(peripheral.wrap("right"))
--change "right" to whichever side the monitor is actually on
while true do
    os.pullEvent("redstone")
    if rs.getInput("back") and not rs.getInput("right") then
        heat = 2000
    elseif rs.getInput("right") and not rs.getInput("bottom") then
        heat = 4000
    elseif rs.getInput("bottom")
        heat = 6000
    end
    term.clear()
    term.setCursorPos(1, 1)
    print("Reactor heat: "..heat)
end
musicgack #11
Posted 02 July 2012 - 05:15 PM
thx so much! =D
ardera #12
Posted 02 July 2012 - 06:03 PM
there is still an error:

elseif rs.getInput("bottom")

has to be


elseif rs.getInput("bottom") then
musicgack #13
Posted 04 July 2012 - 11:20 PM
Thanks Andora I Just Automanicly Put It In =D