Advertisement
Guest User

ScanPlayer.lua

a guest
Oct 15th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.39 KB | None | 0 0
  1. ---------------------------------------------------------------------------------------------------------------------------------------
  2.  
  3. --[[
  4.     Скан игрока (инвентаря, эффектов, брони). Версия 0.2;
  5.     "ScanPlayer 0.2" by Dronax;
  6.     Кто спиздит тот пидорас;
  7. ]]--
  8.  
  9. ---------------------------------------------------------------------------------------------------------------------------------------
  10.  
  11. local term = require("term")
  12. local component = require("component")
  13. local event = require("event")
  14. local gpu = component.gpu
  15. local exit = 0
  16. local buffer = 1
  17.  
  18. ---------------------------------------------------------------------------------------------------------------------------------------
  19.  
  20. if component.isAvailable("openperipheral_sensor") then
  21.     openperipheral_sensor = component.openperipheral_sensor
  22. else
  23.     print("Install the sensor in your computer | Установите сенсор в ваш компьютер")
  24.     os.exit()
  25. end
  26.  
  27. ---------------------------------------------------------------------------------------------------------------------------------------
  28.  
  29. function helmet_armor() -- Проверка шлема
  30.     helmet = openperipheral_sensor.getPlayerByName(player).all().living.armor.helmet
  31.     if helmet == nil then
  32.         gpu.set(3, 3, "Helmet: nil")
  33.     else
  34.         gpu.set(3, 3, "Helmet: " .. helmet.display_name)
  35.     end
  36. end
  37.  
  38. function chestplate_armor() -- Проверка нагрудника
  39.     chestplate = openperipheral_sensor.getPlayerByName(player).all().living.armor.chestplate
  40.     if chestplate == nil then
  41.         gpu.set(3, 4, "ChestPlate: nil")
  42.     else
  43.         gpu.set(3, 4, "ChestPlate: " .. chestplate.display_name)
  44.     end
  45. end
  46.  
  47. function leggings_armor() -- Проверка поножей
  48.     leggings = openperipheral_sensor.getPlayerByName(player).all().living.armor.leggings
  49.     if leggings == nil then
  50.         gpu.set(3, 5, "Leggings: nil" )
  51.     else
  52.         gpu.set(3, 5, "Leggings: " .. leggings.display_name)
  53.     end
  54. end
  55.  
  56. function boots_armor() -- Проверка ботинок
  57.     boots = openperipheral_sensor.getPlayerByName(player).all().living.armor.boots
  58.     if boots == nil then
  59.         gpu.set(3, 6, "Boots: nil")
  60.     else
  61.         gpu.set(3, 6, "Boots: " .. boots.display_name)
  62.     end
  63. end
  64.  
  65. function effect() -- Проверка эффектов
  66.     potion_effects = openperipheral_sensor.getPlayerByName(player).all().living.potion_effects
  67.     gpu.set(3,7, "Effects:")
  68.     for i = 1, #potion_effects do
  69.         gpu.set(3, 7+i, "Effect " .. i .. ": " .. potion_effects[i].effect.name)
  70.     end
  71. end
  72.  
  73. function scan_inventory() -- Скан игрока
  74.     for i = 1, 36 do
  75.         inventory = openperipheral_sensor.getPlayerByName(player).all().player.inventory
  76.         if inventory[i] == nil then
  77.         else
  78.             buffer = buffer + 1
  79.             gpu.set(52, buffer, "Slot " .. i .. ": " .. inventory[i].all().display_name .. " | Amount: " .. inventory[i].all().qty)
  80.         end
  81.     end
  82.     wait()
  83. end
  84.  
  85. function main_graphic() -- менюшка
  86.     gpu.setResolution(160, 50)
  87.     gpu.setBackground(0x000000)
  88.     gpu.setForeground(0xFFFFFF)
  89.     term.clear()
  90.     gpu.setBackground(0xC5C5C5)
  91.     gpu.fill(1, 1, 160, 1, " ")
  92.     gpu.fill(1, 50, 160, 1, " ")
  93.     gpu.fill(1, 1, 1, 50, " ")
  94.     gpu.fill(160, 1, 1, 50, " ")
  95.     gpu.setForeground(0x0900FF)
  96.     gpu.set(20, 1, "Preferences")
  97.     gpu.set(105, 1, "Inventory")
  98.     gpu.set(160, 1, "X")
  99.     gpu.set(151, 50, "by Dronax")
  100.     gpu.fill(50, 1, 1, 50, " ")
  101.     gpu.setBackground(0x000000)
  102.     gpu.setForeground(0xFFFFFF)
  103. end
  104.  
  105. function hello() -- запуск
  106.     print("Введите ник игрока которого хотите про сканировать")
  107.     player = io.read()
  108.     term.clear()
  109.     main_graphic()
  110.     main_scan()
  111. end
  112.  
  113. function main_scan() -- всеобщий скан
  114.     gpu.set(3, 2, "Name: " .. player)
  115.     helmet_armor()
  116.     chestplate_armor()
  117.     leggings_armor()
  118.     boots_armor()
  119.     effect()
  120.     scan_inventory()
  121. end
  122.  
  123. function wait() -- ожидает закрытия
  124.     while true do
  125.         event.pull("touch")
  126.         if exit == 1 then
  127.             gpu.setBackground(0x000000)
  128.             gpu.setForeground(0xFFFFFF)
  129.             term.clear()
  130.             os.exit()
  131.         end
  132.     end
  133. end
  134.  
  135. function exit(touch, uuid, x, y, mouse, name) -- изменение переменной
  136.     if x == 160 then
  137.         if y == 1 then
  138.             if mouse == 0 then
  139.                 exit = 1
  140.             end
  141.         end
  142.     end
  143. end
  144.  
  145. ---------------------------------------------------------------------------------------------------------------------------------------
  146.  
  147. event.listen("touch", exit)
  148. hello()
  149.  
  150. ---------------------------------------------------------------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement