Advertisement
hevohevo

CC: simple_paint1

Apr 26th, 2016
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.58 KB | None | 0 0
  1. -- simple_paint1
  2. -- 簡易ペイントプログラム
  3.  
  4. -- Config
  5. local leftColor = colors.red
  6. local rightColor = colors.black
  7.  
  8. -- Functions
  9. function init()
  10.   term.setTextColor(colors.white)
  11.   term.setBackgroundColor(colors.black)
  12.   term.clear()
  13. end
  14.  
  15. function drawPoint(x,y,color)
  16.   term.setBackgroundColor(color)
  17.   term.setCursorPos(x,y)
  18.   term.write(" ")
  19. end
  20.  
  21. -- Main
  22. init()  -- 画面初期化
  23.  
  24. while true do
  25.   local event, button, x, y = os.pullEvent("mouse_click")
  26.   if button == 1 then
  27.     drawPoint(x, y, leftColor)
  28.   else
  29.     drawPoint(x,y, rightColor)
  30.   end
  31. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement