Advertisement
Guest User

dienst

a guest
Jan 23rd, 2014
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.76 KB | None | 0 0
  1. local metro = "007"
  2. local colortop = 0x444444
  3. local colorvenster = 0x666666
  4. local colortext = 0x000000
  5. local dienstbestand = "/info.txt"
  6. local dienstbs = "lijn="
  7. local beginbs = "begin="
  8. local eindbs = "eind="
  9. --
  10. print("[LOG] Opstarten")
  11. for _, v in pairs(rs.getSides()) do
  12.     if peripheral.getType(v) == "modem" then rednet.open(v) present = true break end
  13. end
  14. if fs.exists("/ocs/apis/sensor") then
  15.     os.loadAPI("ocs/apis/sensor")
  16. end
  17. for k,v in pairs(rs.getSides()) do
  18.     if (peripheral.getType(v) == "terminal_glasses_bridge") or (peripheral.getType(v) == "glassesbridge") then
  19.         plastic = peripheral.wrap(v)
  20.         break
  21.     elseif (peripheral.getType(v) == "sensor") and (not worldSensor) then
  22.         worldSensor = sensor.wrap(v)
  23.         if not (worldSensor.getSensorName() == "worldCard") then
  24.             worldSensor = false
  25.         end
  26.     end
  27. end
  28. local file = io.open(shell.resolve(".")..dienstbestand)
  29. if not file then
  30.     print("[ERROR] Bestand '"..dienstbestand.."' is er niet!")
  31. end
  32. local sidl = file:read()
  33. sidl = string.gsub(dienst, dienstbs, "")
  34. sidl = string.gsub(begin, beginbs, "")
  35. sidl = string.gsub(eind, eindbs, "")
  36. print("[LOG] Informatie geladen van '"..dienstbestand.."'")
  37. print("      Lijn: "..dienst)
  38. print("      Begin: "..begin)
  39. print("      Eind: "..eind)
  40. local lijn = plastic.addText(19, 37, "Lijn: "..dienst.."", colortext)
  41. print("[LOG] Opstarten sucsesvol")
  42. while true do
  43.     local senderId, message, distance = rednet.receive()
  44.     if message == "bord" then
  45.         rednet.send(senderId, begin)
  46.         rednet.send(senderId, eind)
  47.     end
  48.     if message == "dienst" then
  49.         rednet.send(denderId, "accept-dienst")
  50.         local senderId2, lijnOnt, distance = rednet.receive()
  51.         local senderId2, beginOnt, distance = rednet.receive()
  52.         local senderId2, eindOnt, distance = rednet.receive()
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement