Advertisement
CrazedProgrammer

pacpal

Jul 6th, 2017
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. --[[
  2. MIT License
  3.  
  4. Copyright (c) 2017 CrazedProgrammer
  5.  
  6. Permission is hereby granted, free of charge, to any person obtaining a copy
  7. of this software and associated documentation files (the "Software"), to deal
  8. in the Software without restriction, including without limitation the rights
  9. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  10. copies of the Software, and to permit persons to whom the Software is
  11. furnished to do so, subject to the following conditions:
  12.  
  13. The above copyright notice and this permission notice shall be included in all
  14. copies or substantial portions of the Software.
  15.  
  16. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  19. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  21. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  22. SOFTWARE.
  23. ]]
  24.  
  25. local imgstr = [[ 1111  ccc   ddd   bbb   aaa   999
  26. 111   c8c8c d8d8d b8b8b a8a8a 98989
  27. 11    cfcfc dfdfd bfbfb afafa 9f9f9
  28. 111   ccccc ddddd bbbbb aaaaa 99999
  29.  1111 c c c d d d b b b a a a 9 9 9
  30.                                    
  31.  4444  eee   555   333   222   666
  32. 444   e0e0e 50505 30303 20202 60606
  33. 44    e7e7e 57575 37373 27272 67676
  34. 444   eeeee 55555 33333 22222 66666
  35.  4444 e e e 5 5 5 3 3 3 2 2 2 6 6 6]]
  36. local imgwidth = 35
  37. local imgheight = 11
  38.  
  39. -- oh god why
  40. local imgpath = "/tmpimg"..math.random(1, 9999)
  41. local handle = fs.open(imgpath, "w")
  42. handle.write(imgstr)
  43. handle.close()
  44. local img = paintutils.loadImage(imgpath)
  45. fs.delete(imgpath)
  46.  
  47. local twidth, theight = term.getSize()
  48. local ocx, ocy = term.getCursorPos()
  49. local tcx, tcy = math.floor((twidth - imgwidth) / 2) + 1, (ocy > (theight - imgheight)) and (theight - imgheight) or ocy
  50.  
  51. if ocy > tcy then
  52.     term.scroll(ocy - tcy)
  53. end
  54.  
  55. paintutils.drawImage(img, tcx, tcy)
  56.  
  57. term.setCursorPos(1, tcy + imgheight)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement