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

Fail with read()

Started by Manello, 18 July 2013 - 12:25 PM
Manello #1
Posted 18 July 2013 - 02:25 PM
I have a Problem with my new Program, it dont react to anything, i think the read() is the Problem but i dont know it really. If i open the Program, it opens an Input where i can type in what i want, but nothing happends, and the "type Input" should be not there. Sorry for my terrible english.

---------------------------------------------------------------------Variablen
m = peripheral.wrap("top")
an = 0
gleisa1 = 0
gleisa2 = 0
gleisb1 = 0
gleisb2 = 0
-----------------------------------------------------------------------Gleis Auswahl GUI
m.setBackgroundColor(colors.blue)
function draw()
m.clear()
  m.setCursorPos(1,1)
  m.setTextScale(3)
  m.write("Gleis Auswahl")
m.setTextColour(colors.lime)
  m.setCursorPos(3,3)
   m.write("Ankunft 1")
  m.setCursorPos(3,4)
   m.write("Ankunft 2")
  m.setCursorPos(3,5)
   m.write("Abfahrt 1")
  m.setCursorPos(3,6)
   m.write("Abfahrt 2")
end
draw()
------------------------------------------------------------------------Gleis Auswahl Vorbereitung
rednet.open("back")
rednet.open("bottom")
rednet.isOpen("back")
while true do
  redstone.getBundledInput("front")
an = read()
--------------------------------------------------------------------GLEIS 1 ANFART
  if event == "monitor_touch" then
  if an == 1 then
    m.setCursorPos(3,3)
    m.setTextColour(colors.red)
    m.write("Ankunft 1")
  rednet.send(672,"1")
gleisa1 = gleisa1 + 1
  an = 0
  end
  if an == 2 and gleisa1 == 1 then
    m.setCursorPos(3,4)
    m.setTextColour(colors.red)
    m.write("Ankunft 2")
  rednet.send(672,"0")
  gleisa2 = gleisa2 + 1
    an = 0
  end
 
while true do
  event,side,x,y = os.pullEvent()
  if event == "monitor_touch" then
------------------------------------------------------------------------Gleis Auswahl FUNKTION
   
-----------------------------------------------------------------------GLEIS 1 ABFAHRT   
	  if x == 3 and y == 3 and gleisa1 == 1 then
    m.setCursorPos(3,3)
    m.setTextColour(colors.lime)
    m.write("Ankunft 1")
  rednet.send(681,"1")
   gleisa1 = gleisa1 - 1
  end
if x == 3 and y == 4 and gleisa2 == 1 then
    m.setCursorPos(3,4)
    m.setTextColour(colors.lime)
    m.write("Ankunft 2")
  rednet.send(680,"1")
   gleisa2 = gleisa2 - 1
  end
  if x == 3 and y == 5 and gleisb1 == 1 then
    m.setCursorPos(3,4)
    m.setTextColour(colors.lime)
    m.write("Abfahrt 1")
  rednet.send(680,"1")
   gleisa2 = gleisa2 - 1
  end
    if x == 3 and y == 6 and gleisb2 == 1 then
    m.setCursorPos(3,4)
    m.setTextColour(colors.lime)
    m.write("Abfahrt 2")
  rednet.send(680,"1")
   gleisa2 = gleisa2 - 1
  end
	 
    end
  end
end
  end
KaoS #2
Posted 18 July 2013 - 04:43 PM
you are comparing your results to numbers. read() returns a string

an==1
should be

an=="1"
or

tonumber(an)==1