Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- trainWaitTime = 10
- --Prints Texts on monitors and sets trains free
- function monitorPainting()
- print("Monitorpainting wird gestartet....")
- rednet.open("back")
- local monitors = nil
- if os.getComputerLabel() == "Bahnhof1" then
- monitors = {peripheral.wrap( "monitor_0" ),peripheral.wrap( "monitor_1" ),peripheral.wrap( "monitor_2" ),peripheral.wrap( "monitor_6" )}
- elseif os.getComputerLabel() == "Bahnhof2" then
- monitors = {peripheral.wrap( "monitor_3" ),peripheral.wrap( "monitor_4" ),peripheral.wrap( "monitor_7" ),peripheral.wrap( "monitor_8" )}
- end
- local zugPlan = {}
- myApi.executeTableFunction(monitors, "setTextScale",0.7)
- while true do
- local senderId, message, protocol = rednet.receive()
- local targets = textutils.unserialize(message)
- myApi.executeTableFunction(monitors, "clear")
- myApi.executeTableFunction(monitors, "setTextColor", colors.white)
- myApi.executeTableFunction(monitors, "setCursorPos", 1, 1)
- myApi.executeTableFunction(monitors, "write", "Zug Gleis Ziel ETA Abfahrt")
- local zeile = 2
- local nextZug = ""
- for k, v in pairs( targets ) do
- local gleis = myApi.getGleisFromPosX(v["Position"])
- if string.find(k, "Locomotive") and (gleis ~= "?") then
- if zugPlan[k] == nil then
- zugPlan[k] = os.clock()
- end
- if os.clock()-zugPlan[k] > trainWaitTime then
- if nextZug == "" or (os.clock()-zugPlan[nextZug]) < (os.clock()-zugPlan[k]) then
- nextZug = k
- end
- end
- local ankunft = 0
- if zugPlan[k] ~= nil then
- ankunft = (trainWaitTime - (os.clock()-zugPlan[k]))
- if ankunft < 0 then
- ankunft = 0
- end
- end
- myApi.executeTableFunction(monitors, "setCursorPos", 1, zeile)
- myApi.executeTableFunction(monitors, "write", myApi.fillMyString(v["RouteDestination"],5) .. " " .. gleis .. " Ölplattform 0min ".. math.floor(ankunft) .."sek" )
- if (trainWaitTime - (os.clock()-zugPlan[k])) < -1 then
- myApi.executeTableFunction(monitors, "setTextColor", colors.red)
- myApi.executeTableFunction(monitors, "write", " +" .. math.floor(math.abs(trainWaitTime - (os.clock()-zugPlan[k])) ) )
- myApi.executeTableFunction(monitors, "setTextColor", colors.white)
- end
- zeile = zeile + 1
- end
- end
- if nextZug ~= "" and colors.test(redstone.getBundledInput("bottom"), colors.lightGray) and (not colors.test(redstone.getBundledInput("bottom"), colors.red) ) then
- if myApi.getGleisFromPosX( targets[nextZug]["Position"] ) == 1 then
- redstone.setBundledOutput("bottom", colors.white)
- elseif myApi.getGleisFromPosX( targets[nextZug]["Position"] ) == 2 then
- redstone.setBundledOutput("bottom", colors.yellow)
- elseif myApi.getGleisFromPosX( targets[nextZug]["Position"] ) == 3 then
- redstone.setBundledOutput("bottom", colors.lime)
- elseif myApi.getGleisFromPosX( targets[nextZug]["Position"]) == 4 then
- redstone.setBundledOutput("bottom", colors.pink)
- elseif myApi.getGleisFromPosX( targets[nextZug]["Position"] ) == 5 then
- redstone.setBundledOutput("bottom", colors.cyan)
- end
- zugPlan[nextZug] = nil
- nextZug = ""
- sleep(3)
- redstone.setBundledOutput("bottom", 0)
- else
- sleep(0.5)
- redstone.setBundledOutput("bottom", 0)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment