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

Program help! bundled cable monitor thing

Started by JGreen1996, 03 May 2012 - 04:20 PM
JGreen1996 #1
Posted 03 May 2012 - 06:20 PM
as the title says, i have a program that i am using to monitor the status of an IC2 reactor and it's cooling system and display it on a monitor (control is done either manually or via my friends program once he completes it) i have it almost working but it's not changing the status on the monitor
 mon = peripheral.wrap("right")
cool = redstone.testBundledInput("back", 1)
power = redstone.testBundledInput("back", 2)
mon.setTextScale(2)
term.redirect(mon)
term.clear()
term.setCursorPos(1,1)
function cool()
if cool == true then
    print("Cooling Active")
    --end
if cool == false then
    print("COOLING IS NOT ON!")
    end
end
function power()
if power == true then
    print("Reactor Off")
    --end
if power == false then
    print("Reactor On")
    end
end
cool()
power()
textutils.slowPrint(".....")
os.sleep(5)
shell.run("reactor") -- re-runs the program

any help would be much appreciated, (pastebin link is http://pastebin.com/cTUScmsH)
Cloudy #2
Posted 03 May 2012 - 06:53 PM
as the title says, i have a program that i am using to monitor the status of an IC2 reactor and it's cooling system and display it on a monitor (control is done either manually or via my friends program once he completes it) i have it almost working but it's not changing the status on the monitor
 mon = peripheral.wrap("right")
cool = redstone.testBundledInput("back", 1)
power = redstone.testBundledInput("back", 2)
mon.setTextScale(2)
term.redirect(mon)
term.clear()
term.setCursorPos(1,1)
function cool()
if cool == true then
	print("Cooling Active")
	--end
if cool == false then
	print("COOLING IS NOT ON!")
	end
end
function power()
if power == true then
	print("Reactor Off")
	--end
if power == false then
	print("Reactor On")
	end
end
cool()
power()
textutils.slowPrint(".....")
os.sleep(5)
shell.run("reactor") -- re-runs the program

any help would be much appreciated, (pastebin link is http://pastebin.com/cTUScmsH)

My first comment to you would be - don't rerun the program for heavens sake. Learn how to use loops - like so:



mon = peripheral.wrap("right")
mon.setTextScale(2)
term.redirect(mon)
term.clear()
term.setCursorPos(1,1)

function cool()
    local coolStat = redstone.testBundledInput("back", 1)
    if coolStat then
        print("Cooling Active")
        --end
    else 
        print("COOLING IS NOT ON!")
    end
end

function power()
    local powerStat = redstone.testBundledInput("back", 2)
    if powerStat then
        print("Reactor Off")
    else
        print("Reactor On")
    end
end

while true do
    term.clear()
    term.setCursorPos(1,1)
    cool()
    power()
    textutils.slowPrint(".....")
    os.sleep(5)
end

That code was broken, so I've no idea why you didn't tell us the errors you receive.

First of all, you never end the "if power == true" statement at all - then you check if it is false inside the if statement. Second, the variables "power" and "cool" also have functions declared afterwards which replace them - and the functions only check if it is true or false. Hence neither if condition will evaluate to true.

The fixed code above should work.
JGreen1996 #3
Posted 03 May 2012 - 07:25 PM
I'm a noob but I'm learning :)/>/>
yer i sort of had the code working then broke it (can't remember what i broke though)
but thanks for your help :)/>/> It works now,