Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- t = {
- {text="Enable Weapons",x=1,y=1,txtCol=color.white,bgCol=colors.green},
- {text="Disable Weapons",x=1,y=2,txtCol=color.white,bgCol=colors.green},
- }
- mon = peripheral.wrap("right") -- Where is the Adv. Monitor located?
- function writeButtons(_table)
- for i,v in pairs(_table) do
- term.setCursorPos(v.x,v.y)
- term.setTextColor(v.txtCol)
- term.setBackgroundColor(v.bgCol)
- write(v.text)
- end
- end
- function isValidClick(_table,mx,my)
- for i,v in pairs(_table do
- if mx >=v.x and mx<= (v.x + #v.text) and my == v.y then
- return true, v.text
- end
- end
- return false, nil
- end
- writeButtons(t)
- while true do
- _, but, x,y, = os.pullEvent("monitor_touch")
- bClick, option = isValidClick(t,x,y)
- if bClick then
- if option == "Enable Weapons" then
- print("Weapons enabled!")
- elseif option == "Disable Weapons" then
- print ("Weapons disabled!")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement