Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Testing Objects--
- function maxFinder(myTable, kind)
- local maxTable = { }
- if kind == "string" then
- for i=1,#myTable do
- maxTable[i] = #myTable[i]
- end
- table.sort(maxTable)
- return maxTable[#maxTable]
- elseif kind == "number" then
- table.sort(myTable)
- return myTable[#myTable]
- end
- end
- local SubMenu = {
- Draw = function(self)
- local xlength = maxFinder(self.stringTable, "string")
- local ylength = #self.stringTable
- term.setBackgroundColor(self.colorTable[1])
- for i=self.xOrigin, self.xOrigin+xlength+1 do
- for b=self.yOrigin, self.yOrigin+ylength+1 do
- term.setCursorPos(i,b)
- write(" ")
- end
- end
- term.setBackgroundColor(self.colorTable[2])
- for i=self.xOrigin+1,self.xOrigin+xlength do
- for b=self.yOrigin+1, self.yOrigin+ylength do
- term.setCursorPos(i,b)
- write(" ")
- end
- end
- for i=1,#self.stringTable do
- term.setCursorPos(self.xOrigin+1,self.yOrigin+i)
- write(self.stringTable[i])
- end
- end,
- Input = function(self,xClick,yClick)
- local xlength = maxFinder(self.stringTable, "string")
- local ylength = #self.stringTable
- local xOrigin = self.xOrigin+1
- local yOrigin = self.yOrigin+1
- local selection = 1
- for i=1,#self.stringTable do
- if xOrigin <= xClick and xClick <= xOrigin+xlength then
- if yClick == yOrigin+i-1 then
- return selection
- end
- end
- selection = selection + 1
- end
- return false
- end
- }
- local SubMenu_mt = {
- __index = SubMenu
- }
- function SubMenu.new(xOrigin, yOrigin, stringTable, colorTable)
- local SubMenuObject = {
- xOrigin = xOrigin or 0,
- yOrigin = yOrigin or 0,
- stringTable = stringTable or { },
- colorTable = colorTable or { }
- }
- setmetatable(SubMenuObject, SubMenu_mt)
- return SubMenuObject
- end
- term.clear()
- local list = {"NPaintPro","FireWolf","Taco"}
- local list2 = {"Herp","Derping","Rainbow"}
- local standard = {colors.gray,colors.lightBlue}
- AppSubMenu = SubMenu.new(3,3,list,standard)
- HerpMenu = SubMenu.new(15,3,list2,standard)
- AppSubMenu:Draw()
- HerpMenu:Draw()
- term.setCursorPos(1,1)
- term.setBackgroundColor(colors.black)
- term.setTextColor(1)
Advertisement
Add Comment
Please, Sign In to add comment