Advertisement
nikita2007558

Робот для спавна душ + красный камень

Jul 29th, 2023 (edited)
1,371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.52 KB | None | 0 0
  1. local com = require("component")
  2. local robot = require("robot")
  3. local event = require("event")
  4. local gpu = require("component").gpu
  5.  
  6. local active_slot = 1
  7. local size = robot.inventorySize()
  8. local redstone = com.redstone
  9. local w, h = 50, 16
  10.  
  11. -- Функция для рисования интерфейса
  12. function drawGUI()
  13.     gpu.fill(1, 1, w, h, " ")
  14.    
  15.     gpu.set(1, 1, "┌" .. string.rep("─", w - 2) .. "┐")
  16.     gpu.set(1, h, "└" .. string.rep("─", w - 2) .. "┘")
  17.     for i = 2, h - 1 do
  18.       gpu.set(1, i, "│")
  19.       gpu.set(w, i, "│")
  20.     end
  21.    
  22.     gpu.set(3, 2, "Робот " .. robot.name() .. " запущен!")
  23.     gpu.set(3, 4, "Для спауна нужно подать сигнал красного камня")
  24. end
  25.  
  26. -- Рисуем интерфейс
  27. drawGUI()
  28.  
  29. -- Основной цикл
  30. while true do
  31.     local redstoneSignal = false
  32.     for i = 0, 5 do
  33.         if redstone.getInput(i) > 0 then
  34.             redstoneSignal = true
  35.             break
  36.         end
  37.     end
  38.  
  39.     if redstoneSignal then
  40.           pcall(robot.place, 0, true)
  41.  
  42.         if robot.count(active_slot) == 0 and robot.select(active_slot) ~= size then
  43.             active_slot = active_slot + 1
  44.         end
  45.  
  46.         if robot.select(active_slot) == size and robot.count(active_slot) == 0 then
  47.             active_slot = 1
  48.         end
  49.  
  50.         gpu.set(3, 11, "Редстоун сигнал: true")
  51.     else
  52.         gpu.set(3, 11, "Редстоун сигнал: false")
  53.     end
  54.  
  55.     os.sleep(1)
  56. end
  57.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement