65 posts
Location
China
Posted 22 July 2014 - 11:44 PM
Hello,
Im trying to open and close my doors trough a computer.
Everything works fine only showing the status about the door (OPEN or CLOSE) doesnt work
The code is shown below and to read the OPEN/CLOSE status is at the bottom (red cable)
Maybe someone can tell me what I do wrong.
-- ######################
-- ## CABLE USAGE
-- ######################
-- Computer ID 17
-- RED Cable - Blastdoor D2
-- ######################
-- ##
-- ######################
local standby = 5
local side = "bottom"
local YES = "y"
local back = "back"
local a = "a"
local b = "b"
local c = "c"
local d = "d"
local e = "e"
red = rs.testBundledInput("bottom", colors.red) -- D-2 BlastDoor
local width, height = term.getSize()
-- ######################
-- ####
-- ######################
while true do
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.white)
term.clear()
term.setTextColor(colors.black)
term.setBackgroundColor(colors.orange)
term.clearLine()
term.setCursorPos(1, height)
term.clearLine()
local text = "Nuclear Research Facility"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)
-- ######################
-- #### MENU
-- ######################
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
term.setCursorPos(1, 3)
term.write("|Menu| Radiation Doors")
term.setCursorPos(4, 5)
term.write("A: D-2 Entrance")
term.setCursorPos(4, 14)
term.setTextColor(colors.black)
term.write("Option: ")
local input = read()
-- ######################
-- #### radiation doors D2
-- ######################
if input == a then
shell.run("d2")
end
-- ######################
-- ## SHUTDOWN SYSTEM
-- ######################
if input == e then
shell.run("startup")
end
-- ######################
-- ## Door Status
-- ######################
if red == true then
term.setCursorPos(22,5)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.white)
term.write("CLOSED ")
else
term.setCursorPos(22,5)
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.white)
term.write("OPEN ")
end
os.pullEvent("redstone")
end
Edited on 22 July 2014 - 09:45 PM
3790 posts
Location
Lincoln, Nebraska
Posted 22 July 2014 - 11:59 PM
What version of ComputerCraft are you using? Anything 1.6 forward will not have bundled cable support yet.
Currently, there are no mods that support our bundled cable API. Chickenbones, from Project:RED has stated that he intends to add support for it, but I've yet to see anything in their changelog stating that the support had been added.
65 posts
Location
China
Posted 23 July 2014 - 12:03 AM
What version of ComputerCraft are you using? Anything 1.6 forward will not have bundled cable support yet.
Currently, there are no mods that support our bundled cable API. Chickenbones, from Project:RED has stated that he intends to add support for it, but I've yet to see anything in their changelog stating that the support had been added.
Version 1.58 using the rednet cable or MFR
Edited on 22 July 2014 - 10:03 PM
3790 posts
Location
Lincoln, Nebraska
Posted 23 July 2014 - 12:06 AM
Ah, okay. That version should be compatible with MFR then.
Is there a specific error you're getting, or is it just not displaying the OPEN/CLOSE status properly?
65 posts
Location
China
Posted 23 July 2014 - 12:10 AM
Ah, okay. That version should be compatible with MFR then.
Is there a specific error you're getting, or is it just not displaying the OPEN/CLOSE status properly?
the OPEN/CLOSE doesnt work properly and not displaying
Edited on 22 July 2014 - 10:26 PM
3790 posts
Location
Lincoln, Nebraska
Posted 23 July 2014 - 12:25 AM
That's probably because you use term.clear() at the start of your loop. You might want to rethink how your GUI is assembled.
65 posts
Location
China
Posted 23 July 2014 - 12:32 AM
That's probably because you use term.clear() at the start of your loop. You might want to rethink how your GUI is assembled.
I tried without the GUI but it didnt solve the problem.
353 posts
Location
Orewa, New Zealand
Posted 23 July 2014 - 07:39 AM
Maybe its because its waiting for an input from you before printing the state of the door… Maybe do the following instead:
-- ######################
-- ## CABLE USAGE
-- ######################
-- Computer ID 17
-- RED Cable - Blastdoor D2
-- ######################
-- ##
-- ######################
local standby = 5
local side = "bottom"
local YES = "y"
local back = "back"
local a = "a"
local b = "b"
local c = "c"
local d = "d"
local e = "e"
red = rs.testBundledInput("bottom", colors.red) -- D-2 BlastDoor
local width, height = term.getSize()
-- ######################
-- ####
-- ######################
while true do
term.setCursorPos(1, 1)
term.setBackgroundColor(colors.white)
term.clear()
term.setTextColor(colors.black)
term.setBackgroundColor(colors.orange)
term.clearLine()
term.setCursorPos(1, height)
term.clearLine()
local text = "Nuclear Research Facility"
term.setCursorPos(math.floor((width - #text) / 2), 1)
term.write(text)
-- ######################
-- #### MENU
-- ######################
function checkRed() --Checker Function Is Now Up Here And Is Actually In A Function
if red == true then
term.setCursorPos(22,5)
term.setTextColor(colors.red)
term.setBackgroundColor(colors.white)
term.write("CLOSED ")
else
term.setCursorPos(22,5)
term.setTextColor(colors.lime)
term.setBackgroundColor(colors.white)
term.write("OPEN ")
end
end
term.setTextColor(colors.black)
term.setBackgroundColor(colors.white)
term.setCursorPos(1, 3)
term.write("|Menu| Radiation Doors")
term.setCursorPos(4, 5)
term.write("A: D-2 Entrance")
term.setCursorPos(4, 14)
term.setTextColor(colors.black)
term.write("Option: ")
checkRed() --Call The Checker Function Right Before It Asks For An Input There might be further complications with it not updating when the input is changed.. That would involve a little more work
local input = read()
-- ######################
-- #### radiation doors D2
-- ######################
if input == a then
shell.run("d2")
end
-- ######################
-- ## SHUTDOWN SYSTEM
-- ######################
if input == e then
shell.run("startup")
end
os.pullEvent("redstone")
end
Notice the arragment change of the redstone input checker block…. Note im not excellent at this so it might not work, but this is how i would do it… :)/>
Hope it works
Edited on 23 July 2014 - 06:03 AM