MegiRicky

migSysyemBombSight.lua

Sep 19th, 2024
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.15 KB | None | 0 0
  1. local radar = peripheral.find("sp_radar")
  2. local ar = peripheral.find("arController")
  3. local raycaster = peripheral.find("raycaster")
  4.  
  5. local function askUser(prompt, defaultValue)
  6. print(prompt .. " (default: " .. defaultValue .. ")")
  7. local input = io.read()
  8. if input == "" then
  9. return defaultValue
  10. else
  11. return input
  12. end
  13. end
  14.  
  15. local screenWidth, screenHeight, fov, GUIscale
  16. local sourceX, sourceY, sourceZ = 0,0,0
  17. local source = {}
  18. local userID
  19. local friendlyIDs
  20. local friendlyIDFile = "friendly_ids.txt"
  21. local widthMagic = 1.125
  22. local projectionDistance = 30
  23. local currentPitch, currentYaw = 0,0
  24. local lockedTarget = nil
  25. local elements = {}
  26. local pInfo = {}
  27. --Bombsight
  28. local euler_mode = true
  29. local max_distance = 2000
  30. local immediate_execution = true
  31. local check_for_blocks_in_world = true
  32. local gravity = 10
  33. local time_step = 0.1 -- seconds, time step for simulation
  34. local max_simulation_time = 100 -- seconds, max time for the simulation
  35.  
  36. local Kp = 0.3 -- Proportional gain
  37. local Ki = 0.1 -- Integral gain
  38. local Kd = 0.05 -- Derivative gain
  39.  
  40. local controls = {cannonControlMode = "mouseAim"}
  41.  
  42.  
  43. -- Configuration file paths
  44. local function readConfig(filename)
  45. if not fs.exists(filename) then
  46. print("Configuration file '" .. filename .. "' does not exist. Creating it.")
  47. file = fs.open(filename, "w")
  48.  
  49. resolution = askUser("Input your resolution eg.(1920,1080)", "3440,1440")
  50. file.writeLine("resolution=" .. resolution)
  51.  
  52. fov = askUser("Input your FOV eg.(70)", "70")
  53. file.writeLine("fov=" .. fov)
  54.  
  55. guiScale = askUser("Input your GUI scale", "4")
  56. file.writeLine("guiScale=" .. guiScale)
  57.  
  58. mode = askUser("Input your mode 1:System in world space 2:System on vs ship", "1")
  59. file.writeLine("mode=" .. mode)
  60.  
  61. userID = askUser("Input your ID", "MegiRicky")
  62. file.writeLine("userID=" .. userID)
  63.  
  64. if mode == "1" then
  65. local source = askUser("Input the location of the computer (X,Y,Z)", "0,0,0")
  66. file.writeLine("source=" .. source)
  67. else
  68. file.writeLine("source=ship")
  69. end
  70.  
  71. -- Integrating channel number into the config
  72. cannonHitPosChannel = askUser("Input the cannon data channel number", "700")
  73. file.writeLine("cannonHitPosChannel=" .. cannonHitPosChannel)
  74.  
  75. controlChannel = askUser("Input the control channel", "500")
  76. file.writeLine("controlChannel=" .. controlChannel)
  77.  
  78. file.close()
  79. end
  80. sleep(1)
  81. local file = fs.open(filename, "r")
  82. local config = {}
  83. local line = file.readLine()
  84. while line do
  85. local key, value = line:match("^(%w+)=(.*)$")
  86. config[key] = value
  87. line = file.readLine()
  88. end
  89. file.close()
  90. return config
  91. end
  92.  
  93. -- Function to edit configuration
  94. local function editConfig(filename)
  95. print("Do you want to edit the config? (yes/no),press enter to skip")
  96. local editChoice = io.read()
  97. if editChoice == "" then
  98. editChoice = "no"
  99. end
  100. if editChoice:lower() == "yes" then
  101. if fs.exists(filename) then
  102. fs.delete(filename)
  103. end
  104. return readConfig(filename)
  105. else
  106. return nil
  107. end
  108. end
  109.  
  110. -- Function to select or create config
  111. local function loadOrCreateConfig()
  112. print("Which player's config do you want to load?")
  113. local selectedID = io.read()
  114.  
  115. local configFile = selectedID .. "config.txt"
  116.  
  117. if fs.exists(configFile) then
  118. print("Config file for " .. selectedID .. " exists. Loading it.")
  119. local config = readConfig(configFile)
  120.  
  121. -- Ask if user wants to edit config
  122. editConfig(configFile)
  123.  
  124. return config
  125. else
  126. print("No config file found for " .. selectedID .. ". Creating a new one.")
  127. return readConfig(configFile)
  128. end
  129. end
  130.  
  131. -- Function to read friendly IDs from a file
  132. local function readFriendlyIDs(filename)
  133. if not fs.exists(filename) then
  134. print("Friendly IDs file '" .. filename .. "' does not exist. Creating it.")
  135. local file = fs.open(filename, "w")
  136. print("Input friendly IDs separated by commas:")
  137. local ids = io.read()
  138. file.write(ids)
  139. file.close()
  140. end
  141.  
  142. local file = fs.open(filename, "r")
  143. local friendlyIDs = {}
  144. if file then
  145. local line = file.readLine()
  146. while line do
  147. for id in string.gmatch(line, "%d+") do
  148. table.insert(friendlyIDs, tonumber(id))
  149. end
  150. line = file.readLine()
  151. end
  152. file.close()
  153. end
  154. return friendlyIDs
  155. end
  156.  
  157. local function sign(x)
  158. return x > 0 and 1 or x < 0 and -1 or 0
  159. end
  160.  
  161. -- Load configuration
  162.  
  163. local config = loadOrCreateConfig()
  164. sleep(1)
  165. print(textutils.serialize(config))
  166. screenWidth, screenHeight = config.resolution:match("(%d+),(%d+)")
  167. screenWidth = tonumber(screenWidth)
  168. screenHeight = tonumber(screenHeight)
  169. fov = tonumber(config.fov)
  170. GUIscale = tonumber(config.guiScale)
  171. local mode = tonumber(config.mode)
  172. userID = config.userID
  173. friendlyIDs = readFriendlyIDs(friendlyIDFile)
  174. local magicNumber = GUIscale/4
  175. local cannonHitPosChannel = tonumber(config.cannonHitPosChannel)
  176. local controlChannel = tonumber(config.controlChannel)
  177.  
  178. if modem then
  179. modem.open(cannonHitPosChannel)
  180. modem.open(controlChannel)
  181. end
  182.  
  183. if mode == 1 then
  184. sourceX, sourceY, sourceZ = string.match(config.source, "(%-?%d+),(%-?%d+),(%-?%d+)")
  185. sourceX = tonumber(sourceX)
  186. sourceY = tonumber(sourceY)
  187. sourceZ = tonumber(sourceZ)
  188. else
  189. local pos = ship.getWorldspacePosition()
  190. sourceX, sourceY, sourceZ = pos.x, pos.y, pos.z
  191. end
  192.  
  193. print("Source X: " .. sourceX)
  194. print("Source Y: " .. sourceY)
  195. print("Source Z: " .. sourceZ)
  196. print("Resolution: " .. screenWidth .. ", " .. screenHeight)
  197. if screenWidth == 3440 and screenHeight == 1440 then widthMagic = 1.125 else widthMagic = 0.92 end
  198. ar.setRelativeMode(true, screenWidth * 4, screenHeight * 4)
  199.  
  200. local function isFriendly(id)
  201. for _, friendlyID in ipairs(friendlyIDs) do
  202. if id == friendlyID then
  203. return true
  204. end
  205. end
  206. return false
  207. end
  208.  
  209. -- Function to project 3D coordinates to 2D screen coordinates
  210. local function projectToScreen(x, y, z, userPos, lookVector)
  211. local dx = x - userPos[1]
  212. local dy = -(y - userPos[2])
  213. local dz = z - userPos[3]
  214.  
  215. local lx, ly, lz = lookVector[1], lookVector[2], lookVector[3]
  216. local playerYaw = math.deg(math.atan2(lz, lx))
  217. local playerPitch = math.deg(math.asin(-ly))
  218. playerYaw = playerYaw + 90
  219. if playerYaw < 0 then
  220. playerYaw = playerYaw + 360
  221. end
  222.  
  223. -- Calculate yaw difference
  224. local targetYaw = math.deg(math.atan2(dz, dx)) + 90
  225. if targetYaw < 0 then
  226. targetYaw = targetYaw + 360
  227. end
  228.  
  229. local yawDiff = targetYaw - playerYaw
  230. if yawDiff > 180 then
  231. yawDiff = yawDiff - 360
  232. elseif yawDiff < -180 then
  233. yawDiff = yawDiff + 360
  234. end
  235.  
  236. if math.abs(yawDiff) > 90 then
  237. return nil, nil
  238. end
  239.  
  240. -- Calculate pitch difference
  241. local distXY = math.sqrt(dx * dx + dz * dz)
  242. local targetPitch = math.deg(math.atan2(dy, distXY))
  243. local pitchDiff = targetPitch - playerPitch
  244.  
  245. local screenDepth = screenWidth / 2 * math.tan(math.rad(fov / 1.125 / 2))
  246. local verticalScreenDepth = screenHeight * math.tan(math.rad(fov / 2))
  247.  
  248. local projectedX, projectedY
  249.  
  250. if yawDiff > 0 then
  251. projectedX = screenWidth / 2 + screenDepth * math.tan(math.rad(math.abs(yawDiff)))
  252. else
  253. projectedX = screenWidth / 2 - screenDepth * math.tan(math.rad(math.abs(yawDiff)))
  254. end
  255.  
  256. if pitchDiff > 0 then
  257. projectedY = screenHeight / 2 + screenHeight * math.tan(math.rad(fov / 0.95 / 2)) * math.tan(math.rad(math.abs(pitchDiff)))
  258. else
  259. projectedY = screenHeight / 2 - screenHeight * math.tan(math.rad(fov / 1.05 / 2)) * math.tan(math.rad(math.abs(pitchDiff)))
  260. end
  261.  
  262. projectedX = math.floor(projectedX / magicNumber)
  263. projectedY = math.floor(projectedY / magicNumber) + 20
  264.  
  265. return projectedX, projectedY
  266. end
  267.  
  268. -- Function to display pitch and yaw of a cannon
  269. local function angleToScreen(pitch, yaw, userPos, lookVector)
  270. local lx, ly, lz = lookVector[1], lookVector[2], lookVector[3]
  271. local playerYaw = math.deg(math.atan2(lz, lx))
  272. local playerPitch = math.deg(math.asin(-ly))
  273. playerYaw = playerYaw + 90
  274. if playerYaw < 0 then
  275. playerYaw = playerYaw + 360
  276. end
  277.  
  278. -- Calculate yaw difference
  279. local yawDiff = yaw - playerYaw
  280. if yawDiff > 180 then
  281. yawDiff = yawDiff - 360
  282. elseif yawDiff < -180 then
  283. yawDiff = yawDiff + 360
  284. end
  285.  
  286. if math.abs(yawDiff) > 90 then
  287. return nil, nil
  288. end
  289.  
  290. -- Calculate pitch difference
  291. local pitchDiff = -pitch + playerPitch
  292.  
  293. local screenDepth = screenWidth / 2 * math.tan(math.rad(fov / 1.125 / 2))
  294. local verticalScreenDepth = screenHeight * math.tan(math.rad(fov / 2))
  295.  
  296. local projectedX, projectedY
  297.  
  298. if yawDiff > 0 then
  299. projectedX = screenWidth / 2 + screenDepth * math.tan(math.rad(math.abs(yawDiff)))
  300. else
  301. projectedX = screenWidth / 2 - screenDepth * math.tan(math.rad(math.abs(yawDiff)))
  302. end
  303.  
  304. if pitchDiff > 0 then
  305. projectedY = screenHeight / 2 + screenHeight * math.tan(math.rad(fov / 0.95 / 2)) * math.tan(math.rad(math.abs(pitchDiff)))
  306. else
  307. projectedY = screenHeight / 2 - screenHeight * math.tan(math.rad(fov / 1.05 / 2)) * math.tan(math.rad(math.abs(pitchDiff)))
  308. end
  309.  
  310. projectedX = math.floor(projectedX / magicNumber)
  311. projectedY = math.floor(projectedY / magicNumber) + 20
  312.  
  313. return projectedX, projectedY
  314. end
  315.  
  316. local function isWithinRenderDistance(projectedX, projectedY, centerX, centerY, maxdx, maxdy, maxd)
  317. local dx = projectedX - centerX / magicNumber
  318. local dy = projectedY - centerY / magicNumber
  319.  
  320. if dx < maxdx then
  321. if dy < maxdy then
  322. local distance = math.sqrt(dx * dx + dy * dy)
  323. if distance <= maxd then
  324. return true
  325. else
  326. return false
  327. end
  328. else
  329. return false
  330. end
  331. else
  332. return false
  333. end
  334. end
  335.  
  336. -- Function to check for overlap and adjust positions
  337. local function filterElements(elements)
  338. table.sort(elements, function(a, b) return a.mass > b.mass end) -- Sort by mass
  339. local filteredElements = {}
  340.  
  341. for i, element in ipairs(elements) do
  342. local overlap = false
  343. for _, filteredElement in ipairs(filteredElements) do
  344. local dx = math.abs(element.screenX - filteredElement.screenX)
  345. local dy = math.abs(element.screenY - filteredElement.screenY)
  346. if dx < 800 / GUIscale and dy < 800 / GUIscale then
  347. overlap = true
  348. element.renderInfo = false
  349. break
  350. end
  351. end
  352.  
  353. table.insert(filteredElements, element)
  354.  
  355. end
  356.  
  357. return filteredElements
  358. end
  359.  
  360. -- Function to render elements in parallel
  361. local function renderElements(elements, cannonHitPos, pInfo, lockedTarget)
  362. local tasks = {}
  363. for _, element in ipairs(elements) do
  364. table.insert(tasks, function()
  365. local color = element.color
  366. if lockedTarget and element.id == lockedTarget.id then
  367. color = 0xFF0000 -- Red color for locked target
  368. end
  369. ar.horizontalLineWithId("frame_top_" .. element.id, element.screenX - element.frameSize, element.screenX + element.frameSize, element.screenY - element.frameSize, color)
  370. ar.horizontalLineWithId("frame_bottom_" .. element.id, element.screenX - element.frameSize, element.screenX + element.frameSize, element.screenY + element.frameSize, color)
  371. ar.verticalLineWithId("frame_left_" .. element.id, element.screenX - element.frameSize, element.screenY - element.frameSize, element.screenY + element.frameSize, color)
  372. ar.verticalLineWithId("frame_right_" .. element.id, element.screenX + element.frameSize, element.screenY - element.frameSize, element.screenY + element.frameSize, color)
  373. if element.renderInfo then
  374. ar.drawString("dist: " .. element.distance, element.screenX - 15, element.screenY - 200 / GUIscale, color)
  375. ar.drawString("mass: " .. math.floor(element.mass / 1000) .. "k", element.screenX - 15, element.screenY - 340 / GUIscale, color)
  376. ar.drawString("speed: " .. element.speed, element.screenX - 15, element.screenY - 480 / GUIscale, color)
  377. ar.drawString("id: " .. element.id, element.screenX - 15, element.screenY - 620 / GUIscale, color)
  378. end
  379. end)
  380. end
  381. parallel.waitForAll(table.unpack(tasks))
  382. end
  383.  
  384. local function lockHighestThreatTarget(elements, centerX, centerY, radius)
  385. local highestThreat = nil
  386. local highestThreatLevel = -1
  387.  
  388. for _, element in ipairs(elements) do
  389. if element.id then
  390. local dx = element.screenX - centerX / magicNumber
  391. local dy = element.screenY - centerY / magicNumber
  392. local distance = math.sqrt(dx * dx + dy * dy)
  393.  
  394. if distance <= radius / GUIscale then
  395. local threatLevel = element.mass -- Use mass as a proxy for threat level
  396. if isFriendly(element.id) then threatLevel = -1 end
  397. if threatLevel > highestThreatLevel then
  398. highestThreat = element
  399. highestThreatLevel = threatLevel
  400. end
  401. end
  402. end
  403. end
  404.  
  405. return highestThreat
  406. end
  407.  
  408. local function modemMessage()
  409. while true do
  410. if modem then
  411. local event, side, channel, replyChannel, message, distance = os.pullEvent("modem_message")
  412. if channel == cannonHitPosChannel then
  413. cannonHitPos = message
  414. elseif channel == controlChannel then
  415. controls = message
  416. end
  417. else
  418. sleep()
  419. end
  420. end
  421. end
  422.  
  423. local function getAngularVelocity(currentYaw, currentTime)
  424. if lastYaw and lastYawTime then
  425. local deltaTime = currentTime - lastYawTime
  426. local deltaYaw = (currentYaw - lastYaw + math.pi) % (2 * math.pi) - math.pi
  427. return deltaYaw / deltaTime -- Radians per second
  428. end
  429. return 0
  430. end
  431.  
  432. -- Update the main function to remove target locking and aiming
  433. local function main()
  434. while true do
  435. local playerList = radar.scanForPlayers(1000)
  436. if cannonHitPos then
  437.  
  438. end
  439.  
  440. for _, player in ipairs(playerList) do
  441. local playerName = player.nickname
  442. local playerPosition = player.pos
  443. local lookAngle = player.look_angle
  444.  
  445. if player.nickname == userID then
  446. pInfo = {
  447. nickname = player.nickname,
  448. pos = player.pos,
  449. lookVector = lookAngle
  450. }
  451. end
  452. end
  453.  
  454. if pInfo.nickname then
  455. local objectList = radar.scanForShips(10000)
  456. ar.clear()
  457.  
  458. elements = {}
  459. for _, object in ipairs(objectList) do
  460. local objX, objY, objZ = object.pos.x, object.pos.y, object.pos.z
  461. local screenX, screenY = projectToScreen(objX, objY, objZ, pInfo.pos, pInfo.lookVector)
  462. local distance = math.floor(math.sqrt((object.pos.x - pInfo.pos[1]) ^ 2 + (object.pos.y - pInfo.pos[2]) ^ 2 + (object.pos.z - pInfo.pos[3]) ^ 2))
  463. local speed = math.floor(math.sqrt(object.velocity.x ^ 2 + object.velocity.y ^ 2 + object.velocity.z ^ 2))
  464. local color
  465. if isFriendly(object.id) then
  466. color = 0x009cff -- Friendly, blue color
  467. elseif object.mass < 10000 then
  468. color = 0x999999 -- type unknown/low threat
  469. elseif object.mass < 100000 then
  470. if speed > 40 then
  471. -- high speed low mass, potential missile
  472.  
  473. local missileVector = {object.velocity.x, object.velocity.y, object.velocity.z}
  474. local toPlayerVector = {pInfo.pos[1] - objX, pInfo.pos[2] - objY, pInfo.pos[3] - objZ}
  475. local dotProduct = missileVector[1] * toPlayerVector[1] + missileVector[2] * toPlayerVector[2] + missileVector[3] * toPlayerVector[3]
  476. if dotProduct > 0 then
  477. color = 0xff5600 -- missile coming, high threat
  478. else
  479. color = 0xFFFF00 -- potential threat
  480. end
  481. else
  482. color = 0x00FF00 -- low mass low speed, low threat
  483. end
  484. elseif object.mass < 1000000 then
  485. color = 0xfff700 -- Medium sized vehicle, fighter jet, tanks, helicopter
  486. else
  487. color = 0xffc300 -- Large sized vehicle, ships, strategic bomber
  488. end
  489.  
  490. if distance > 20 then
  491. if screenX and screenY and isWithinRenderDistance(screenX, screenY, screenWidth / 2, screenHeight / 2, 4000 / GUIscale, 4800 / GUIscale, 3200 / GUIscale) then
  492. table.insert(elements, {
  493. id = object.id,
  494. screenX = screenX,
  495. screenY = screenY,
  496. frameSize = 20,
  497. color = color,
  498. distance = distance,
  499. mass = object.mass,
  500. speed = speed,
  501. velocity = object.velocity,
  502. renderInfo = true
  503. })
  504. end
  505. end
  506. end
  507.  
  508. local filteredElements = filterElements(elements)
  509.  
  510. for _, element in ipairs(elements) do
  511. local found = false
  512. for _, filteredElement in ipairs(filteredElements) do
  513. if element.id == filteredElement.id then
  514. found = true
  515. break
  516. end
  517. end
  518. if not found then
  519. element.renderInfo = false
  520. end
  521. end
  522.  
  523. renderElements(filteredElements, cannonHitPos, pInfo, lockedTarget)
  524. end
  525.  
  526. if pInfo then
  527.  
  528. end
  529.  
  530. if ship.getVelocity() then
  531. local velocity = ship.getVelocity()
  532. local speed = math.floor(math.sqrt(velocity.x^2 + velocity.y^2 + velocity.z^2)) * 1.94384449
  533.  
  534. ar.drawStringWithId("AimCrossHair","speed: "..speed.." knots", 100, 500, 0xFFFFFF)
  535. end
  536.  
  537.  
  538. sleep(0.05) -- Adjust the sleep time as needed to balance performance and responsiveness
  539. end
  540. end
  541.  
  542. local function calculateBombLandingPosition(ship_pos, ship_velocity, release_height)
  543. local time = 0
  544. local bomb_pos = {ship_pos.x, ship_pos.y, ship_pos.z} -- Starting at ship's position
  545. local bomb_velocity = {ship_velocity.x, ship_velocity.y, ship_velocity.z} -- Initial velocity same as the ship's velocity
  546.  
  547. while time < max_simulation_time do
  548. -- Update the bomb's position based on current velocity
  549. bomb_pos[1] = bomb_pos[1] + bomb_velocity[1] * time_step -- X position
  550. bomb_pos[2] = bomb_pos[2] + bomb_velocity[2] * time_step -- Y position (height)
  551. bomb_pos[3] = bomb_pos[3] + bomb_velocity[3] * time_step -- Z position
  552.  
  553. -- Update the bomb's vertical velocity due to gravity
  554. bomb_velocity[1] = bomb_velocity[1] * 0.975
  555. bomb_velocity[2] = bomb_velocity[2] - gravity * time_step -- Y velocity decreases due to gravity
  556. bomb_velocity[3] = bomb_velocity[3] * 0.975
  557.  
  558. -- Check if bomb hits the ground (Y position <= 0)
  559. if bomb_pos[2] <= 0 then
  560. break
  561. end
  562.  
  563. time = time + time_step
  564. end
  565.  
  566. return bomb_pos -- The final position where the bomb hits the ground
  567. end
  568.  
  569. local function hitMark()
  570. while true do
  571. if raycaster then
  572. local playerList = radar.scanForPlayers(1000)
  573. for _, player in ipairs(playerList) do
  574. local playerName = player.nickname
  575. local playerPosition = player.pos
  576. local lookAngle = player.look_angle
  577.  
  578. if player.nickname == userID then
  579. pInfo = {
  580. nickname = player.nickname,
  581. pos = player.pos,
  582. lookVector = lookAngle
  583. }
  584. end
  585. end
  586.  
  587. local result = {}
  588. local shipPitch = math.deg(ship.getRoll())
  589. local shipLocation = ship.getWorldspacePosition()
  590. local shipVelocity = ship.getVelocity()
  591. var1 = 0
  592. var2 = math.rad(-shipPitch)
  593. result = raycaster.raycast(max_distance, {var1, var2}, euler_mode, immediate_execution)
  594.  
  595. if result.is_block and result.block_type ~= "block.minecraft.air" then
  596. print("Block hit at:")
  597. print("Hit position: " .. result.hit_pos[1] .. ", " .. result.hit_pos[2] .. ", " .. result.hit_pos[3])
  598. print("Block type: " .. result.block_type)
  599. print("Distance: " .. result.distance)
  600. elseif result.is_entity then
  601. print("Entity hit at:")
  602. print("Hit position: " .. result.hit_pos[1] .. ", " .. result.hit_pos[2] .. ", " .. result.hit_pos[3])
  603. print("Entity ID: " .. result.id)
  604. print("Entity type: " .. result.descriptionId)
  605. print("Distance: " .. result.distance)
  606. elseif result.ship_id then
  607. print("No hit detected within " .. max_distance .. " blocks.")
  608. print("Hit position: "..result.hit_pos[1].." , "..result.hit_pos[2].." , "..result.hit_pos[3])
  609. end
  610.  
  611. if result.hitpos and result.hit_pos[2] < 0 then
  612. result.hit_pos[2] = 0
  613. result.distance = shipLocation.y - 0
  614. end
  615.  
  616. local bombLandingPos = calculateBombLandingPosition(shipLocation, shipVelocity, result.distance)
  617.  
  618. if bombLandingPos then
  619. objX, objY, objZ = bombLandingPos[1], bombLandingPos[2], bombLandingPos[3]
  620. end
  621. if objX and objY and objZ then
  622. local screenX, screenY = projectToScreen(objX, objY, objZ, pInfo.pos, pInfo.lookVector)
  623. if screenX and screenY then
  624. ar.clearElement("CrossHair")
  625. ar.drawStringWithId("CrossHair","X", screenX, screenY, 0xFF0000)
  626. end
  627. end
  628. end
  629. sleep()
  630. end
  631. end
  632.  
  633. -- Main loop
  634. parallel.waitForAny(
  635. modemMessage,
  636. main,
  637. hitMark
  638. )
  639.  
Advertisement
Add Comment
Please, Sign In to add comment