Advertisement
DarkSiders061

test kinjer

Jul 19th, 2024 (edited)
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.09 KB | None | 0 0
  1. --Look throughout the code for comments like this. They explain what to do to change things.
  2.  
  3. --What side the monitor will be on (change this if needed)
  4. modem = peripheral.find("modem") or error("No modem attached", 0)
  5. m = peripheral.find("monitor") or error("No monitor attached", 0)
  6.  
  7.  
  8. --button on/off color
  9. bactive = colors.cyan
  10. binactive=colors.gray
  11. --text on/off color
  12. tactive=colors.white
  13. tinactive=colors.black
  14. --Background color
  15. bgcolor = colors.black
  16.  
  17.  
  18. buttons = {}
  19.  
  20.  
  21.  
  22. function newButton(id,xmin,xmax,ymin,ymax,text,func)
  23. buttons[id] = {}
  24. buttons[id]["xmin"] = xmin
  25. buttons[id]["xmax"] = xmax
  26. buttons[id]["ymin"] = ymin
  27. buttons[id]["ymax"] = ymax
  28. buttons[id]["active"] = false
  29. buttons[id]["text"] = text
  30. buttons[id]["func"] = func
  31.  
  32. end
  33. ---------------------------------------------------------------------------------
  34. function printButton(id)
  35. ymin = buttons[id]["ymin"]
  36. ymax = buttons[id]["ymax"]
  37. xmin = buttons[id]["xmin"]
  38. xmax = buttons[id]["xmax"]
  39. text = buttons[id]["text"]
  40. ia = buttons[id]["active"]
  41.  
  42.  
  43.  
  44. width = xmax - xmin
  45. height = ymax - ymin
  46.  
  47. if ia then
  48. m.setBackgroundColor(bactive)
  49. m.setTextColor(tactive)
  50. sleep(1)
  51. ia = false
  52. else
  53. m.setBackgroundColor(binactive)
  54. m.setTextColor(tinactive)
  55.  
  56. end
  57.  
  58. for j = ymin,ymax do
  59. m.setCursorPos(xmin,j)
  60. for i = xmin,xmax do
  61.  
  62. m.write(" ")
  63.  
  64. end
  65.  
  66. end
  67.  
  68.  
  69. m.setCursorPos(xmin + width / 2 - #text / 2 + 1,ymin + height / 2)
  70.  
  71. m.write(text)
  72. m.setBackgroundColor(bgcolor)
  73.  
  74. end
  75. ----------------------------------------------------------------------------------
  76. function refreshButtons()
  77. for i = 1,#buttons do
  78. printButton(i)
  79. end
  80. end
  81. function checkxy( x,y )
  82. for i = 1, #buttons do
  83. if y >= buttons[i]["ymin"] and y <= buttons[i]["ymax"] then
  84. if x >= buttons[i]["xmin"] and x <= buttons[i]["xmax"] then
  85.  
  86.  
  87. buttons[i]["active"] = not buttons[i]["active"]
  88. clicked = i
  89. if buttons[i]["func"] ~= nil then
  90.  
  91. buttons[i]["func"]()
  92.  
  93.  
  94. end
  95. end
  96. end
  97. end
  98. end
  99.  
  100.  
  101. bool1 = false
  102. bool2 = false
  103. bool3 = false
  104. rs.setBundledOutput("back",0)
  105.  
  106.  
  107.  
  108.  
  109. --White is pigman, Orange is witch, purple is wither skele (Bundled cable)
  110.  
  111.  
  112. function villager()
  113.  
  114. if bool1 then
  115. bool1 = not bool1
  116. modem.transmit(7, 7, "RDC")
  117. end
  118. end
  119.  
  120. function znkkiller()
  121. current = rs.getBundledOutput("back")
  122. bool2 = not bool2
  123. if bool2 then
  124. rednet.broadcast("znkkilleron")
  125. else
  126. rednet.broadcast("znkkilleroff")
  127. end
  128. end
  129.  
  130. function microsoftkiller()
  131. current = rs.getBundledOutput("back")
  132. bool3 = not bool3
  133. if bool3 then
  134. rednet.broadcast("microsoftkilleron")
  135. else
  136. rednet.broadcast("microsoftkilleroff")
  137. end
  138. end
  139.  
  140. function ancientknight()
  141. current = rs.getBundledOutput("back")
  142. bool3 = not bool3
  143. if bool3 then
  144. rednet.broadcast("ancienton")
  145. else
  146. rednet.broadcast("ancientoff")
  147. end
  148. end
  149.  
  150.  
  151. --You can add more buttons and also change the size of them. The format is startingx,startingy,endingx,endingy,text,function
  152.  
  153. --The buttons
  154. newButton(1, 2,24,2,6,"Villager",villager)
  155. newButton(2, 26,48,2,6,"ZNK Killer",znkkiller)
  156. newButton(3, 26,48,7,11,"Microsoft Killer",microsoftkiller)
  157. newButton(4, 2,24,7,11,"Ancient Knight",ancientknight)
  158. ------------------------------------------------
  159.  
  160.  
  161.  
  162. m.clear()
  163. refreshButtons()
  164.  
  165.  
  166. --main loop
  167. while true do
  168. e,side,x,y = os.pullEvent("monitor_touch")
  169. checkxy(x,y)
  170.  
  171. refreshButtons()
  172. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement