Advertisement
bobopopcornboy

Windows Minecraft

Nov 6th, 2024
14
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. mouseU = true
  2. backgroundColor = colors.lightBlue
  3.  
  4.  
  5. windows = {NewWindow = function(name)
  6. windows.open[#windows.open + 1] = {POS = {x = 0, y = 0},SIZE = {x = 10, y = 9},NAME = name}
  7. end,
  8. open = {}
  9. }
  10.  
  11.  
  12. windows.NewWindow("TEST")
  13.  
  14.  
  15. function pixel(x,y,color,cahr)
  16. term.setCursorPos(x,y)
  17. term.setBackgroundColor(color)
  18. if not cahr then cahr = " " end
  19. write(cahr)
  20. term.setBackgroundColor(backgroundColor)
  21. end
  22.  
  23.  
  24.  
  25.  
  26. function mouse_up()
  27. startPOS = nil
  28. end
  29.  
  30.  
  31.  
  32.  
  33. function mouseDown(mx,my)
  34. if startPOS then
  35. oldPOS = {x=window.POS.x,y=window.POS.y}
  36. window.POS.x = mx - startPOS.x + oldPOS.x
  37. window.POS.y = my - startPOS.y + oldPOS.y
  38. startPOS = {x = mx,y = my}
  39. end
  40. end
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49. function mouseDownStart(mx,my)
  50. if mx >= window.POS.x and mx <= window.POS.x + window.SIZE.x - 1 then
  51. if my-1 == window.POS.y then
  52. startPOS = {x = mx,y = my}
  53. end
  54. end
  55. end
  56.  
  57.  
  58. function mouseClick(mb,mx,my)
  59. if mx == window.POS.x + window.SIZE.x then
  60. if my-1 == window.POS.y then
  61. window.NAME = "Close"..string.char(2)
  62. end
  63. end
  64. end
  65.  
  66.  
  67. while true do
  68. event,p1,p2,p3 = os.pullEvent()
  69. if event == "mouse_up" then
  70. mouseU = true
  71. mouse_up()
  72. elseif event == "mouse_drag" then
  73. if p1 == 1 then
  74. if mouseU then
  75. mouseDownStart(p2,p3)
  76. end
  77. mouseDown(p2,p3)
  78. mouseU = false
  79. end
  80. elseif event == "mouse_click" then
  81. mouseClick(p1,p2,p3)
  82. end
  83. --draw
  84. term.clear()
  85. for wi=1, #windows.open do
  86. window = windows.open[wi]
  87. for x=1, window.SIZE.x do
  88. for y=1,window.SIZE.y do
  89. c = colors.lightGray
  90. t=" "
  91. if y == 1 then
  92. c = colors.gray
  93. if x <= string.len(window.NAME) then
  94. t = string.sub(window.NAME,x,x)
  95. end
  96. if x == window.SIZE.x then
  97. c = colors.red
  98. end
  99. end
  100. pixel(window.POS.x+x,window.POS.y+y,c,t)
  101. end
  102. end
  103. end
  104. sleep(0.1)
  105. end
  106.  
Tags: Cc
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement