Jump to content




Doorstatus OPEN/CLOSE doesnt work


  • You cannot reply to this topic
7 replies to this topic

#1 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 22 July 2014 - 10: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 by Xixili, 22 July 2014 - 10:45 PM.


#2 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 22 July 2014 - 10: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.

#3 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 22 July 2014 - 11:03 PM

View PostCranium, on 22 July 2014 - 10:59 PM, said:

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 by Xixili, 22 July 2014 - 11:03 PM.


#4 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 22 July 2014 - 11:06 PM

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?

#5 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 22 July 2014 - 11:10 PM

View PostCranium, on 22 July 2014 - 11:06 PM, said:

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 by Xixili, 22 July 2014 - 11:26 PM.


#6 Cranium

    Ninja Scripter

  • Moderators
  • 4,031 posts
  • LocationLincoln, Nebraska

Posted 22 July 2014 - 11:25 PM

That's probably because you use term.clear() at the start of your loop. You might want to rethink how your GUI is assembled.

#7 Xixili

  • Members
  • 65 posts
  • LocationChina

Posted 22 July 2014 - 11:32 PM

View PostCranium, on 22 July 2014 - 11:25 PM, said:

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.

#8 hbomb79

  • Members
  • 352 posts
  • LocationOrewa, New Zealand

Posted 23 July 2014 - 06: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 by Hbomb_79, 23 July 2014 - 07:03 AM.






3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users