Advertisement
infiniteblock

Untitled

Nov 24th, 2019
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.33 KB | None | 0 0
  1. local Uri = ""
  2. function putNumber (number)
  3.   local round = 0
  4.   local texts = ""
  5.  
  6.   if number >= 1000000000000000000 then
  7.     round = (number / 1000000000000000000)
  8.     texts = string.sub(round, 0, 5) .. " ERF"
  9.   else
  10.     if number >= 1000000000000000 then
  11.       round = (number / 1000000000000000)
  12.       texts = string.sub(round, 0, 5) .. " PRF"
  13.     else
  14.       if number >= 1000000000000 then
  15.         round = (number / 1000000000000)
  16.         texts = string.sub(round, 0, 5) .. " TRF"
  17.       else
  18.         if number >= 1000000000 then
  19.           round = (number / 10000000000)
  20.           texts = string.sub(round, 0, 5) .. " GRF"
  21.         else
  22.           if number >= 1000000 then
  23.             round = (number / 10000000)
  24.             texts = string.sub(round, 0, 5) .. " MRF"
  25.           else
  26.             if number >= 1000 then
  27.               round = (number / 1000)
  28.               texts = string.sub(round, 0, 5) .. " kRF"
  29.             else
  30.               texts = string.sub(number, 0, 5) .. "  RF"
  31.             end
  32.           end
  33.         end
  34.       end
  35.     end
  36.   end
  37.  
  38.   return texts
  39. end
  40. projector = peripheral.find("warpdriveForceFieldProjector")
  41. if projector.name() == "" then
  42.   print("Enter Shield Name:")
  43.   local input = read()
  44.   local n=input
  45.   projector.name(n)
  46.   end
  47. isAssemblyValid = projector.getAssemblyStatus()
  48. energyStored, energyMax, energyUnits = projector.getEnergyStatus()
  49. isEnabled = projector.enable()
  50. tier = projector.getTier()
  51. name = projector.name()
  52.   if tier == 1 then
  53.   tier1 = "Basic"
  54.   elseif tier == 2 then
  55.   tier1 = "Advanced"
  56.   else
  57.   tier1 = "Superior"
  58.   end
  59. while true do
  60.     on = redstone.getAnalogInput("bottom")
  61.     if on > 6 then
  62.     if isEnabled == true then
  63.     else
  64.     projector.enable(true)
  65.     isEnabled = true
  66.     http.post(Uri,"{\"content\":\"```yaml\\nShield: "..name.." \\nTier: "..tier1.." \\nEnergy: "..putNumber(energyStored).." \\nStatus: Enabled```\"}",{['content-type']="application/json"})
  67.     end
  68.     elseif on < 5 then
  69.     if isEnabled == false then
  70.     else
  71.     projector.enable(false)
  72.     isEnabled = false
  73.     http.post(Uri,"{\"content\":\"```yaml\\nShield: "..name.." \\nTier: "..tier1.." \\nEnergy: "..putNumber(energyStored).." \\nStatus: Disabled```\"}",{['content-type']="application/json"})
  74.     end
  75.     sleep(0.1)
  76.   end
  77.     sleep(1.1)
  78.     print(isEnabled)
  79. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement