Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bgc = 512 --backgroundcolour
- stc = 1 --standart text farbe
- function af()
- return "[Fuel "..turtle.getFuelLevel().."]"
- end
- --Add Button
- mxi = 2 --button anzahl
- tx = {2, 2} -- {1, 2, 3}
- ty = {2, 12} --x&y coordinates
- text = {af(), "-[Tools]-"} --text of button
- tc = {32768, 32768} --text farbe
- tbgc = {2048, 2048} --text backgroundcolour
- --Add funktions
- function click(str)
- if str == 1 then
- shell.run("refuel")
- text[1] = af()
- return
- elseif str == 2 then
- term.setCursorPos(5,5)
- print("test")
- os.sleep(3)
- return
- end
- end
- --hard code
- function dd()
- term.setBackgroundColor(bgc)
- term.setTextColor(stc)
- term.clear()
- i = 1
- repeat
- term.setCursorPos(tx[i], ty[i])
- term.setBackgroundColor(tbgc[i])
- term.setTextColor(tc[i])
- print(text[i])
- term.setBackgroundColor(bgc)
- term.setTextColor(stc)
- i = i + 1
- until i >= mxi+1
- end
- dd()
- while true do
- e, but, cx, cy = os.pullEvent()
- j = 1
- if e == "mouse_click" then
- repeat
- if cx >= tx[j] and cx <= tx[j]+text[j]:len()-1 and cy == ty[j] then
- click(j)
- end
- j = j + 1
- until j >= mxi+1
- end
- dd()
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement