View difference between Paste ID: sTZrrdUu and gTafV5gW
SHOW: | | - or go back to the newest paste.
1-
local colors = require("colors")
1+
local colors = require("colors")
2-
local component = require("component")
2+
local component = require("component")
3-
local sides = require("sides")
3+
local sides = require("sides")
4-
print("your train is on its way !")
4+
local shell = require("shell")
5-
rs = component.redstone
5+
rs = component.redstone
6-
state = rs.getBundledInput(sides.bottom,colors.orange) 
6+
7-
7+
function sendColor(col)
8-
if state == 0 then 
8+
    rs.setBundledOutput(sides.top,col,255)
9-
rs.setBundledOutput(sides.top,colors.orange,255)
9+
    os.sleep(3)
10-
train = component.proxy(component.get("d73f"))
10+
    rs.setBundledOutput(sides.top,col,0)
11-
train.setDestination("City/gjfujskylab")
11+
end
12-
12+
13-
else
13+
function readColor(col)
14-
train2 = component.proxy(component.get("c433")
14+
    t = rs.getBundledInput(sides.bottom,col)
15-
os.sleep(2)
15+
    return t
16-
rs.setBundledOutput(sides.top,colors.orange,0)
16+
end
17-
17+
18
function setDest(addr, dest)
19-
19+
    print("Setting train: " .. addr .. " to: " .. dests[dest])
20-
local shell = require("shell")
20+
    addrr = relays[addr]
21-
shell.execute("clear")
21+
    train_f = component.proxy(component.get(addrr))
22-
os.sleep(2)
22+
    train_f.setDestination(dests[dest])
23-
shell.execute("wer38station")
23+
end
24
25
relays = {}
26
relays[1] = "d73f"
27
relays[2] = "c433"
28
relays[3] = "ea0f"
29
relays[4] = "5973"
30
relays[5] = "3894"
31
32
dests = {}
33
dests["skylab"] = "City/gjgfujskylab"
34
dests["grand"] = "UnderGround/grandstation"
35
dests["kittenbag"] = "UnderGround/kittenbag"
36
dests["we38base"] = "City/wer38base"
37
dests["long"] = "LongDistence/LongDistence"
38
dests["spawn"] = "UnderGround/Spawn"
39
40
print("Your train is on its way!")
41
42
if readColor(colors.orange) == 0 then
43
    setDest(1, "skylab")
44
    sendColor(colors.orange)
45
46
elseif readColor(colors.magenta) == 0 then
47
    setDest(2, "skylab")
48
    sendColor(colors.magenta)
49
50
elseif readColor(colors.lightblue) == 0 then
51
    setDest(3, "skylab")
52
    sendColor(colors.lightblue)
53
else
54
    print("Error, no trains to send.")
55
end