Nike622000

Teleporter

Jun 12th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.24 KB | None | 0 0
  1. os.loadAPI("ocs/apis/sensor")
  2. senI = sensor.wrap("back")
  3.  
  4. function uE()
  5. term.setCursorPos(1,16)
  6. term.setTextColor(colors.red)
  7. print("ungueltige Eingabe!")
  8. sleep(5)
  9. os.reboot()
  10. end
  11.  
  12. term.clear()
  13. term.setTextColor(colors.white)
  14. term.setCursorPos(15,1)
  15. term.write("Teleporter-Calculator")
  16. term.setCursorPos(15,2)
  17. term.write("Version: ")
  18. term.setTextColor(colors.cyan)
  19. term.write("2.0")
  20. term.setCursorPos(15,4)
  21. term.setTextColor(colors.white)
  22. print("Hier kannst du den Stromverbrauch")
  23. term.setCursorPos(15,5)
  24. print("fuer einen Teleporter sehen.")
  25. term.setCursorPos(15,6)
  26. print("Trage einfach die X,Y,Z Koordinaten")
  27. term.setCursorPos(15,7)
  28. print("der 2 Teleporter ein.")
  29. term.setCursorPos(15,8)
  30. print("Danach wird dein Gewicht ueberprueft")
  31. term.setCursorPos(15,9)
  32. print("und die Kosten fuer eine")
  33. term.setCursorPos(15,10)
  34. print("Teleportation berechnet.")
  35. term.setCursorPos(15,12)
  36. term.write("made by ")
  37. term.setTextColor(colors.cyan)
  38. term.write("Nike622000")
  39.  
  40. term.setCursorPos(1,1)
  41. term.setTextColor(colors.cyan)
  42. print("Teleporter 1")
  43. term.setTextColor(colors.white)
  44. term.setCursorPos(1,2)
  45. print("X-Coord: ")
  46. local XCoord1 = read()
  47. term.setCursorPos(1,4)
  48. print("Y-Coord: ")
  49. local YCoord1 = read()
  50. term.setCursorPos(1,6)
  51. print("Z-Coord: ")
  52. local ZCoord1 = read()
  53.  
  54. term.setCursorPos(1,9)
  55. term.setTextColor(colors.cyan)
  56. print("Teleporter 2")
  57. term.setTextColor(colors.white)
  58. term.setCursorPos(1,10)
  59. print("X-Coord: ")
  60. local XCoord2 = read()
  61. term.setCursorPos(1,12)
  62. print("Y-Coord: ")
  63. local YCoord2 = read()
  64. term.setCursorPos(1,14)
  65. print("Z-Coord: ")
  66. local ZCoord2 = read()
  67.  
  68. if type( XCoord1 ) == "number" then
  69. else
  70. XCoord1 = tonumber(XCoord1)
  71. end
  72. if type( YCoord1 ) == "number" then
  73. else
  74. YCoord1 = tonumber(YCoord1)
  75. end
  76. if type( ZCoord1 ) == "number" then
  77. else
  78. ZCoord1 = tonumber(ZCoord1)
  79. end
  80. if type( XCoord2 ) == "number" then
  81. else
  82. XCoord2 = tonumber(XCoord2)
  83. end
  84. if type( YCoord2 ) == "number" then
  85. else
  86. YCoord2 = tonumber(YCoord2)
  87. end
  88. if type( ZCoord2 ) == "number" then
  89. else
  90. ZCoord2 = tonumber(ZCoord2)
  91. end
  92.  
  93. if XCoord1 == nil or YCoord1 == nil or ZCoord1 == nil or XCoord2 == nil or YCoord2 == nil or ZCoord2 == nil then
  94. uE()
  95. end
  96. if XCoord1 == XCoord2 and YCoord1 == YCoord2 and ZCoord1 == ZCoord2 then
  97. term.setCursorPos(1,16)
  98. term.setTextColor(colors.red)
  99. print("Teleporter an der selben Stelle!")
  100. sleep(5)
  101. os.reboot()
  102. end
  103.  
  104. term.setCursorPos(1,16)
  105. term.setTextColor(colors.red)
  106. print("Inventar wird gescannt!")
  107. term.setCursorPos(1,17)
  108. print("vor den Computer stellen!")
  109. while true do
  110. b=2
  111. d=2
  112. eu=0
  113. menge = 0
  114.  
  115.  
  116. zieleinv = senI.getTargets()
  117.     for k,v in pairs(zieleinv) do
  118.             if v.Name == "Player"
  119.             and v.Position.X<0.5 and v.Position.X>-0.5
  120.             and v.Position.Y==-0.5
  121.             and v.Position.Z<-1.5 and v.Position.Z>-2.5
  122.             then
  123.                 details = senI.getTargetDetails(k)
  124.                     for i = 1,40 do
  125.                     item = details.Inventory[i].Name
  126.                     anzahl = details.Inventory[i].Size
  127.                     maxanzahl = details.Inventory[i].MaxStack
  128.                         if item == "empty" then
  129.                         else
  130.                         menge = menge + 100*anzahl/maxanzahl
  131.                         sleep(0.1)
  132.                         end
  133.                     XCoord = XCoord1-XCoord2
  134.                     YCoord = YCoord1-YCoord2
  135.                     ZCoord = ZCoord1-ZCoord2
  136.                     Entfernung = math.sqrt(XCoord^2+YCoord^2+ZCoord^2)
  137.                     Gesamt = menge+1000
  138.                     eu = math.floor(5 * math.floor(Gesamt) * (math.floor(Entfernung) + 10)^0.7)
  139.                     end
  140.                     term.clear()
  141.                     term.setCursorPos(1,1)
  142.                     term.setTextColor(colors.lime)
  143.                     term.write("Gewicht: "..Gesamt.." / 5000")
  144.                     term.setCursorPos(1,2)
  145.                     term.setTextColor(colors.cyan)
  146.                     term.write("Teleportkosten: "..eu.."EU")
  147.                     term.setCursorPos(1,3)
  148.                     term.setTextColor(colors.yellow)
  149.                     term.write("Teleporter 1: X: "..XCoord1.." Y: "..YCoord1.." Z: "..ZCoord1)
  150.                     term.setCursorPos(1,4)
  151.                     term.write("Teleporter 2: X: "..XCoord2.." Y: "..YCoord2.." Z: "..ZCoord2)
  152.                     term.setCursorPos(1,6)
  153.                     term.setTextColor(colors.red)
  154.                     term.write("STRG + R halten um neuzustarten!")
  155.                     sleep(3)
  156.             end
  157.     end
  158. end
Add Comment
Please, Sign In to add comment