Advertisement
Guest User

system

a guest
Oct 18th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. bgc = 512 --backgroundcolour
  2. stc = 1 --standart text farbe
  3. function af()
  4.   return "[Fuel "..turtle.getFuelLevel().."]"
  5. end
  6.  
  7. --Add Button
  8. mxi = 2             --button anzahl
  9.  
  10. tx = {2, 2}           -- {1, 2, 3}
  11. ty = {2, 12}           --x&y coordinates
  12. text = {af(), "-[Tools]-"}    --text of button
  13. tc = {32768, 32768}         --text farbe
  14. tbgc = {2048, 2048}    --text backgroundcolour
  15.  
  16. --Add funktions
  17.  
  18. function click(str)
  19.  
  20. if str == 1 then
  21.   shell.run("refuel")
  22.   text[1] = af()
  23.   return
  24. elseif str == 2 then
  25.   term.setCursorPos(5,5)
  26.   print("test")
  27.   os.sleep(3)
  28.   return
  29. end
  30. end
  31.  
  32. --hard code
  33. function dd()
  34. term.setBackgroundColor(bgc)
  35. term.setTextColor(stc)
  36. term.clear()
  37. i = 1
  38. repeat
  39.  
  40. term.setCursorPos(tx[i], ty[i])
  41. term.setBackgroundColor(tbgc[i])
  42. term.setTextColor(tc[i])
  43. print(text[i])
  44.  
  45. term.setBackgroundColor(bgc)
  46. term.setTextColor(stc)
  47. i = i + 1
  48. until i >= mxi+1
  49. end
  50.  
  51. dd()
  52.  
  53. while true do
  54.   e, but, cx, cy = os.pullEvent()
  55.   j = 1
  56.   if e == "mouse_click" then
  57.     repeat
  58.       if cx >= tx[j] and cx <= tx[j]+text[j]:len()-1 and cy == ty[j] then
  59.         click(j)
  60.       end
  61.       j = j + 1
  62.     until j >= mxi+1
  63.   end
  64.   dd()
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement