Laine_prikol

blockpaint

Mar 24th, 2017
210
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. local component = require("component")
  2. local event = require("event")
  3. local term = require("term")
  4. local gpu = component.gpu
  5. blockid = "stone"
  6. blockscroll = 1
  7. local xMonitorSize, yMonitorSize = gpu.getResolution(xMonitorSize, yMonitorSize)
  8. exitblockstotal = xMonitorSize * yMonitorSize
  9. removedblocks = 0
  10. term.clear()
  11. detect = false
  12.  
  13. if not component.isAvailable("command_block") then
  14.     local d = component.debug
  15.     detect = true
  16.     function cmd(comm) -- Это если у нас дебаг карта
  17.         d.runCommand(comm)
  18.     end
  19. end
  20.  
  21. if component.isAvailable("command_block") and detect == false then
  22.     local cmdblock = component.command_block
  23.     function cmd(comm) -- Если есть командный блок
  24.         cmdblock.setCommand(comm)
  25.         cmdblock.executeCommand()
  26.     end
  27. end
  28.  
  29. function redraw()
  30.     gpu.setBackground(0x696969)
  31.     gpu.fill(1,1,80,1, " ")
  32.     gpu.setForeground(0xFFFFFF)
  33.     blocknames(2, "redstone_block")
  34.     blocknames(3, "lapis_block")
  35.     blocknames(4, "iron_block")
  36.     blocknames(5, "gold_block")
  37.     blocknames(6, "diamond_block")
  38.     blocknames(7, "air")
  39.     blocknames(8, "glowstone")
  40.     blocknames(8, "glass")
  41.     gpu.set(1,1, "[X] BlocksPaint [+] Block [-] Selected block: "..blockid)
  42.     gpu.setBackground(0x000000)
  43. end
  44.  
  45. function scrollblock(scrollid, block, color)
  46.     if blockscroll == scrollid then
  47.         blockid = block
  48.         gpu.setForeground(color)
  49.         end
  50. end
  51. function blocknames(scrollid, block)
  52.     if blockscroll == scrollid then
  53.         blockid = block
  54.         end
  55. end
  56. function Exitfromprogram() 
  57.     gpu.setBackground(0x696969)
  58.     gpu.fill(1,1,80,1, " ")
  59.         for x=1,xMonitorSize do
  60.                 for y=1,yMonitorSize - 1 do
  61.                        cmd("/setblock ~"..x.." ~"..y.." ~0 minecraft:air")
  62.                        removedblocks = removedblocks + 1
  63.                        gpu.set(1,1, "Exiting please wait... Removing blocks: "..removedblocks.."/"..exitblockstotal)
  64.                 end
  65.         end
  66. end
  67. function checkblock()
  68.     scrollblock(2, "redstone_block", 0xFF0000)
  69.     scrollblock(3, "lapis_block", 0x0000FF)
  70.     scrollblock(4, "iron_block", 0xC0C0C0)
  71.     scrollblock(5, "gold_block", 0xFFFF00)
  72.     scrollblock(6, "diamond_block", 0x00FFFF)
  73.     scrollblock(7, "air", 0x000000)
  74.     scrollblock(8, "glowstone", 0x808000)
  75.     scrollblock(8, "glass", 0xFFFFFF)
  76. end
  77. while true do
  78.  local id, _, x, y = event.pullMultiple("touch", "drag")
  79.   if id == "touch" or id == "drag" then
  80.       if y>1 then
  81.       gpu.set(x, y, "■")
  82.       cmd("/setblock ~"..(x-1).." ~"..(yMonitorSize+3-y).." ~0 minecraft:"..blockid)
  83.       redraw()
  84.       checkblock()
  85.       end
  86.   if x == 2 and y == 1 then
  87.     Exitfromprogram()
  88.     term.clear()
  89.     gpu.setBackground(0x000000)
  90.     gpu.setForeground(0xFFFFFF)
  91.     os.exit()  
  92.   end
  93.   if x == 18 and y == 1 then
  94.    blockscroll = blockscroll + 1
  95.    redraw()
  96.    checkblock()
  97.     if blockscroll == 8 then
  98.         blockscroll = 8
  99.         end
  100.   end
  101.   if x == 28 and y == 1 then
  102.    blockscroll = blockscroll - 1
  103.    redraw()
  104.    checkblock()
  105.     if blockscroll == 1 then
  106.         blockscroll = 1
  107.         end
  108.   end
  109. end
  110. end
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×