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

Bundled Signal to Monitor Help

Started by NukeInMyPantz, 24 February 2016 - 09:51 PM
NukeInMyPantz #1
Posted 24 February 2016 - 10:51 PM
Hello
I need help writing a script…
These are the things i'm using. Lamp, Insulated Wire, Bundled Cable, Advanced Computer, Advanced Monitor.

Here is the example code I got from a post.


--test
while true do
m = peripheral.wrap("top")
m.clear()
m.setCursorPos(1,1)
m.write("-----Welcome to the station-----")
m.setCursorPos(1,3)
m.write("Blue Line: ")
m.setCursorPos(1,4)
m.write("Yellow Line: ")
m.setCursorPos(1,5)
m.write("Red Line: ")

m.setCursorPos(15,3)
if redstone.getInput("left") then
  m.write("Arrived")
else
  m.write("Away")
end

m.setCursorPos(15,4)
if redstone.getInput("back") then
  m.write("Arrived ")
else
  m.write("Away")
end

m.setCursorPos(15,5)
if redstone.getInput("right") then
  m.write("Arrived ")
else
  m.write("Away")
os.pullEvent("redstone")
end
sleep(1)
end


Here is my version.


-- Test for lamp signal
m = peripheral.wrap("top")
-- Useful functions here
function printCentered(sText)
  local w, h = term.getSize()
  local x, y = term.getCursorPos()
  x = math.max(math.floor((w / 2) - (#sText / 2)), 0)
  term.setCursorPos(x, y)
  print(sText)
end



function main()
while true do
m = peripheral.wrap("top")
m.clear()
m.setCursorPos(15,1)
m.write("-----Lamp Status-----")
m.setCursorPos(1,3)
m.write("White Lamp: ")
m.setCursorPos(1,4)
m.write("Orange Lamp: ")
m.setCursorPos(1,5)
m.write("Magenta Lamp: ")

m.setCursorPos(12,3)
if redstone.getBundledInput("right", colors.white) then
  m.write("On")
else
  m.write("Off")
end

m.setCursorPos(13,4)
if redstone.getBundledInput("right", colors.orange) then
  m.write("On")
else
  m.write("Off")
end

m.setCursorPos(14,5)
if redstone.getBundledInput("right", colors.magenta) then
  m.write("On")
else
  m.write("Off")
os.pullEvent("redstone")

sleep(5)
	  end
   end
end
main()

I didn't want to post until I really needed to but this has got me stuck at the moment, if anyone could help that would be great!
KingofGamesYami #2
Posted 25 February 2016 - 12:23 AM
What do you expect your program to do, and what does it do instead? If it gave you an error, what was it?
Dragon53535 #3
Posted 25 February 2016 - 01:55 AM
You need to use colors.test to see if a color is in your bundled input


local currentInput = redstone.getBundledInput("right") --#Just so I only have to call this once
if colors.test(currentInput,colors.white) then  --# Colors.test works much like getInput
  --#Do your stuff
else
  --#Other stuff
end
NukeInMyPantz #4
Posted 25 February 2016 - 02:21 AM
What do you expect your program to do, and what does it do instead? If it gave you an error, what was it?

When I look at the Monitor it glitches, as in it will appear and disappear really fast.
The error is "peripheral:74: Too long without yielding".