Advertisement
CaptainSpaceCat

editor

May 18th, 2015
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.91 KB | None | 0 0
  1. function initialize()
  2.   term.setBackgroundColor(colors.orange)
  3.   term.clear()
  4.   iosutils.centerAlign("Program Hub", 1, colors.red, colors.yellow)
  5.   iosutils.leftAlign("Edit: ", 3, colors.white, colors.orange)
  6.   iosutils.leftAlign("Run: ", 5)
  7.   select = {}
  8.   select[3] = 1
  9.   select[4] = 1
  10. end
  11.  
  12. function clickCheck(x, y, x2, y2)
  13.   if select[3] >= x and select[3] <= x2 and select[4] >= y and select[4] <= y2 then
  14.     return true
  15.   else
  16.     return false
  17.   end
  18. end
  19.  
  20. while true do
  21.   initialize()
  22.   select = {os.pullEvent("mouse_click")}
  23.   if clickCheck(1, 3, 12, 3) then
  24.     term.setCursorPos(7, 3)
  25.     local uEdit = read()
  26.     shell.run("edit " .. tostring(uEdit))
  27.   end
  28.   if clickCheck(1, 5, 12, 5) then
  29.     term.setCursorPos(6, 5)
  30.     local uRun = read()
  31.     term.setBackgroundColor(colors.black)
  32.     term.clear()
  33.     term.setCursorPos(1, 1)
  34.     shell.run(tostring(uRun))
  35.     sleep(3)
  36.   end
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement