CodeCrafter

BTN

Mar 10th, 2014
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.93 KB | None | 0 0
  1. button = {}
  2. --mon = peripheral.wrap("left")
  3. mon = term
  4. function fillTable(name, xmin, xmax, ymin, ymax, text, color)
  5. button[name] = {}
  6. button[name]["text"] = text
  7. button[name]["xmin"] = xmin
  8. button[name]["xmax"] = xmax
  9. button[name]["ymin"] = ymin
  10. button[name]["ymax"] = ymax
  11. button[name]["color"] = color
  12. end
  13.  
  14. function createBox(name)
  15. tableData = button[name]
  16. currentY = tableData["ymin"]
  17. while currentY ~= tableData["ymax"] do
  18.   mon.setCursorPos(tableData["xmin"], currentY)
  19.   for i = 1,tableData["xmax"] do
  20.    write(" ")
  21.                 end
  22.                 currentY = currentY +1
  23.         end
  24. end
  25. function createButton(name)
  26. tableData = button[name]
  27. mon.setBackgroundColor(tableData["color"])
  28. xLoc = tableData["xmin"] + (math.ceil((tableData["xmax"] - string.len(tableData["text"]))/2))
  29. yLoc = math.ceil((tableData["ymax"]+tableData["ymin"])/2)-1
  30. createBox(name)
  31. mon.setCursorPos(xLoc,yLoc)
  32. mon.write(tableData["text"])
  33. end
Add Comment
Please, Sign In to add comment