Jump to content




Bundled Signal to Monitor Help


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

#1 NukeInMyPantz

  • Members
  • 11 posts

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!

#2 KingofGamesYami

  • Members
  • 3,002 posts
  • LocationUnited States of America

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?

#3 Dragon53535

  • Members
  • 973 posts
  • LocationIn the Matrix

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


#4 NukeInMyPantz

  • Members
  • 11 posts

Posted 25 February 2016 - 02:21 AM

View PostKingofGamesYami, on 25 February 2016 - 12:23 AM, said:

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".





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users