Advertisement
AssortedBrunoz

radar

Oct 25th, 2024
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.26 KB | None | 0 0
  1. local max_x, max_y = term.getSize()
  2.  
  3. write("INSERT RADIUS: ")
  4. local radius = tonumber(read())
  5. write("INSERT X: ")
  6. local c_x = tonumber(read())
  7. write("INSERT Z: ")
  8. local c_z = tonumber(read())
  9.  
  10. monitor = peripheral.wrap("top")
  11.  
  12. term.redirect(monitor)
  13.  
  14. function string.split(str, sep)
  15.     if sep == nil then
  16.         sep = "%s"
  17.     end
  18.     local t = {}
  19.     for sr in string.gmatch(str, "([^"..sep.."]+)") do
  20.         table.insert(t, sr)
  21.     end
  22.     return t
  23. end
  24. function int(n)
  25.     return tonumber(n)
  26. end
  27.  
  28. local interpolate = (c_z*2)/max_y
  29. term.clear()
  30. term.setCursorPos(1,1)
  31. while true do
  32.     local git = http.get("https://raw.githubusercontent.com/banana-boye/cannon-thingy/refs/heads/test/main.json")
  33.     local info = textutils.unserialiseJSON(git.readAll())
  34.  
  35.     for player, c_string in pairs(info) do
  36.         local spl = string.split(string.sub(c_string,2,#c_string-1), " | ")
  37.         local x,y,z = tonumber(spl[1]),tonumber(spl[2]),tonumber(spl[3])
  38.         if (x >= c_x-radius and x <= c_x+radius) and (z >= c_z-radius and z <= c_z+radius) then
  39.             term.clear()
  40.             term.setCursorPos(1,1)
  41.             write(player.." found at "..c_string)
  42.         end
  43.     end
  44.  
  45.     paintutils.drawPixel(max_x/2,max_y/2)
  46.  
  47.     os.sleep(5)
  48. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement