Advertisement
Vladlen_Info

OpenComputers_command_block_ver_1_1

Mar 19th, 2018
336
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. --example "setblock"
  2.  
  3. local component = require("component")
  4. local event = require("event")
  5. local term = require("term")
  6. local gpu = component.gpu
  7. blockid = "stone"
  8.  
  9.  
  10. if not component.isAvailable("command_block") then
  11.     local d = component.debug
  12.     detect = true
  13.     function cmd(comm) -- Это если у нас дебаг карта
  14.         d.runCommand(comm)
  15.     end
  16. end
  17.  
  18. if component.isAvailable("command_block") and detect == false then
  19.     local cmdblock = component.command_block
  20.     function cmd(comm) -- Если есть командный блок
  21.         cmdblock.setCommand(comm)
  22.         cmdblock.executeCommand()
  23.     end
  24. end
  25.  
  26. while true do
  27.  local id, _, x, y = event.pullMultiple("touch", "drag")
  28.   if id == "touch" or id == "drag" then
  29.       if y>1 then
  30.       gpu.set(x, y, "■")
  31.       cmd("/setblock ~"..(x-1).." ~"..(yMonitorSize+3-y).." ~0 minecraft:"..blockid)
  32.       redraw()
  33.       checkblock()
  34.  
  35.  
  36. function Exitfromprogram()
  37.     gpu.setBackground(0x696969)
  38.     gpu.fill(1,1,80,1, " ")
  39.         for x=1,xMonitorSize do
  40.                 for y=1,yMonitorSize - 1 do
  41.                        cmd("/setblock ~"..x.." ~"..y.." ~0 minecraft:air")
  42.                        removedblocks = removedblocks + 1
  43.                        gpu.set(1,1, "Exiting please wait... Removing blocks: "..removedblocks.."/"..exitblockstotal)
  44.                 end
  45.         end
  46. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement