Posted 09 September 2012 - 08:39 PM
table.remove(track[1][1])
I can find the value of track[1][1], but I can't seem to remove it from the list. I don't know the exact error because computercraft is being weird on the server. Any ideas?
Never mind I fixed that one too, I guess the scarecrow had a brain all along lol
endloop = false
rednet.open("bottom")
tno=1
A1 ={}
A2 = {}
B1 = {}
B2 = {}
C = {}
D = {}
trains ={}
function newtrain(station)
if station == 4 then x = A1
elseif station == 7 then x = B1
elseif station == 9 then x = D
else print "invalid station"
end
print(x)
table.insert(x, trains[tno])
tno = tno+1
if #x == 1 then
print "new train is next to junction"
neworder(x)
end
end
function neworder(track)
rainbow = (rs.getBundledOutput("right"))
if track == A1 then wire = colors.red
elseif track == B1 then wire = colors.orange
elseif track == D then wire = colors.yellow
else print "invalid track"
end
print(rainbow)
wiretest = colors.test(rainbow, wire)
if wiretest == false then
print "wire is off"
if track[1][1] == "x" then
rs.setBundledOutput("right", colors.combine(rainbow, wire))
end
elseif wiretest == true then
print "wire is on"
if track[1][1] == "y" then
rs.setBundledOutput("right", colors.subtract(rainbow, wire))
end
end
table.remove(track[1][1])
end
function changeline(col, new, old)
if rs.testBundledInput("right", col) == true then
table.insert(new)
table.remove(old[1])
neworder(old)
end
end
function statechange()
changeline(colors.green, A2, D)
changeline(colors.lightBlue, A2, A1)
changeline(colors.blue, B2, B1)
changeline(colors.purple, B2, D)
changeline(colors.black, C, B1)
changeline(colors.white, C, A1)
end
repeat
event, id, msg = os.pullEvent()
if event == "rednet_message" then
trains[tno] = {msg}
print(trains[1])
newtrain(id)
elseif event == "redstone" then
statechange()
end
until endloop == true