XEXModz

Untitled

Nov 12th, 2025
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.10 KB | None | 0 0
  1. trackMonID = "monitor_3"
  2. radMonID = "top"
  3.  
  4. stationX = 0
  5. stationZ = 0
  6. scale = 50
  7.  
  8.  
  9. testContact = {
  10. ["x"] = -100,
  11. ["z"] = 30,
  12. ["id"] = "Unknown",
  13. ["icon"] = "?",
  14. ["lastSeen"] = 0,
  15. ["type"] = "MCWS"
  16. }
  17.  
  18. contact = {testContact}
  19.  
  20. permContacts = {
  21. testContact
  22. }
  23.  
  24. pd = peripheral.find("playerDetector")
  25. mon = peripheral.wrap(radMonID)
  26. mon.setTextScale(0.5)
  27. --trackMon = peripheral.wrap(trackMonID)
  28. mon.setTextScale(0.5)
  29.  
  30. sizeX, sizeY = mon.getSize()
  31. cx = sizeX/2
  32. cy = sizeY/2
  33.  
  34. table.insert(contact,testContact)
  35.  
  36. function systemCheck()
  37. contact[1].x = math.random(-300,500)
  38. contact[1].z = math.random(-500,500)
  39. end
  40.  
  41. function writeRednetContact()
  42. while true do
  43. inMsg = rednet.receive("redar_track")
  44. packet = textutils.unserializeJSON(inMsg)
  45. if packet then
  46. if packet.type == "telData" then
  47. newCon = {
  48. ["x"] = packet.x,
  49. ["z"] = packet.z,
  50. ["id"] = packet.id,
  51. ["icon"] = string.sub(packet.id,1,1),
  52. ["type"] = "REDAR"
  53. }
  54. table.insert(contact,newCon)
  55. end
  56. end
  57. sleep(0.5)
  58. end
  59. end
  60.  
  61. function writeMCWSContacts()
  62. while true do
  63. inMsg = ws.receive()
  64. packet = textutils.unserializeJSON(inMsg)
  65. if packet then
  66. if packet.type == "telData" then
  67. newCon = {
  68. ["x"] = packet.x,
  69. ["z"] = packet.z,
  70. ["id"] = packet.id,
  71. ["icon"] = string.sub(packet.id,1,1),
  72. ["type"] = "MCWS"
  73. }
  74. table.insert(contact,newCon)
  75. end
  76. end
  77. sleep(0.5)
  78. end
  79. end
  80.  
  81. trackOffset = 0
  82.  
  83. function drawContacts()
  84.  
  85. for _,radCon in pairs(contact) do
  86. local screenX = (((stationX-radCon.x))/scale)*-1
  87. local screenY = (((stationZ-radCon.z))/scale)*-1
  88. local distanceCalc = math.sqrt(math.pow(radCon.x-stationX,2) - math.pow(radCon.z-stationZ,2))
  89. if radCon.type == "player" then
  90. term.setCursorPos(cx+screenX, cy+screenY)
  91. term.blit(radCon.icon, "0", "e")
  92. end
  93. if radCon.type == "MCWS" then
  94. term.setCursorPos(cx+screenX, cy+screenY)
  95. term.blit(radCon.icon, "0", "1")
  96. end
  97. term.setBackgroundColor(colors.black)
  98. term.setCursorPos(cx+screenX,cy+screenY-1)
  99. term.write("ID: "..radCon.id)
  100. term.setCursorPos(cx+screenX,cy+screenY-2)
  101. term.write("["..tostring("X:"..radCon.x).."|"..tostring("Z:"..radCon.z).."]")
  102. end
  103. end
  104.  
  105. function drawContactArray()
  106. for _, radCon in pairs(contact) do
  107. local distanceCalc = math.sqrt(math.pow(radCon.x-stationX,2) - math.pow(radCon.z-stationZ,2))
  108. trackMon.setCursorPos(1,trackOffset)
  109. trackMon.write("["..radCon.icon.."]".." ID: "..radCon.id)
  110. trackMon.setCursorPos(1,trackOffset+1)
  111. trackMon.write("["..tostring("X:"..radCon.x).."|"..tostring("Z:"..radCon.z).."]")
  112. trackMon.setCursorPos(1,trackOffset+2)
  113. trackMon.write("RNG: "..tostring(math.ceil(distanceCalc)).."m")
  114. trackOffset = trackOffset + 4
  115. end
  116. end
  117.  
  118. function drawCircle(x, y, r)
  119. prevX = x
  120. prevY = y
  121. drawContacts()
  122. for i = 0,360, 1 do
  123. drawContacts()
  124. angle = i;
  125. x1 = r * math.cos(angle * math.pi / 180)
  126. y1 = r * math.sin(angle * math.pi / 180)
  127. term.setCursorPos(x + x1, y + y1)
  128. paintutils.drawLine(x,y,x+x1,y+y1,colors.lime)
  129. drawContacts()
  130. prevX = x1
  131. prevY = y1
  132. sleep(0.000001)
  133. paintutils.drawLine(x,y,x+prevX,y+prevY,colors.black)
  134. drawContacts()
  135. if i == 270 then
  136. term.clear()
  137. contact = permContacts
  138. end
  139.  
  140. end
  141. end
  142.  
  143. function listenKeyboard()
  144. while true do
  145. event, key, held = os.pullEvent("key")
  146. if key == keys.equals then
  147. scale = scale + 50
  148. if scale < 0 then
  149. scale = 1
  150. end
  151. sleep(0.1)
  152. mon.setBackgroundColor(colors.black)
  153. mon.clear()
  154. end
  155. if key == keys.minus then
  156. scale = scale - 50
  157. if scale < 0 then
  158. scale = 1
  159. end
  160. sleep(0.1)
  161. mon.setBackgroundColor(colors.black)
  162. mon.clear()
  163. end
  164. if key == keys.up then
  165. scale = scale + 1
  166. if scale < 0 then
  167. scale = 1
  168. end
  169. sleep(0.1)
  170. mon.setBackgroundColor(colors.black)
  171. mon.clear()
  172. end
  173. if key == keys.down then
  174. scale = scale - 1
  175. if scale < 0 then
  176. scale = 1
  177. end
  178. sleep(0.1)
  179. mon.setBackgroundColor(colors.black)
  180. mon.clear()
  181. end
  182.  
  183. end
  184. end
  185.  
  186. function radar()
  187. term.redirect(mon)
  188. controlTerm = term.native()
  189. controlTerm.setBackgroundColor(colors.black)
  190. controlTerm.clear()
  191. while true do
  192. drawCircle(cx,cy,100)
  193. end
  194. end
  195.  
  196. function updateContact()
  197. while true do
  198. sleep(1)
  199. trackOffset = 1
  200. -- trackMon.clear()
  201. -- trackMon.setCursorPos(1,1)
  202. contact = {}
  203. -- writePlayerContacts()
  204. --drawContactArray()
  205. end
  206. end
  207.  
  208. function controlPanel()
  209. controlTerm = term.native()
  210. while true do
  211. controlTerm.setCursorPos(1,1)
  212. controlTerm.clear()
  213. controlTerm.write("Rednet Distance and Ranging | REDAR")
  214. controlTerm.setCursorPos(1,3)
  215. controlTerm.write("+ / - | +50 / -50 Scale")
  216. controlTerm.setCursorPos(1,4)
  217. controlTerm.write("Up / Down | +1 / -1 Scale")
  218. controlTerm.setCursorPos(1,6)
  219. controlTerm.write("Current Scale: "..tostring(scale).." Meters per pixel")
  220. sleep(0.25)
  221. end
  222. end
  223.  
  224.  
  225. systemCheck()
  226. parallel.waitForAll(listenKeyboard,radar,controlPanel,writeMCWSContacts)
Advertisement
Add Comment
Please, Sign In to add comment