Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Attention!!
- relativeY = 1
- relativeX = 1
- stc = term.setTextColor
- sbc = term.setBackgroundColor
- scp = function(x,y)
- term.setCursorPos(x,y)
- sX,sY = term.getCursorPos()
- relativeX = sX
- relativeY = y
- end
- cl = term.clearLine()
- clear = term.clear
- clearall = function() sbc(colors.black) stc(colors.white) clear() scp(1,1) end
- box = paintutils.drawFilledBox
- border = paintutils.drawBox
- line = paintutils.drawLine
- width, height = term.getSize()
- --]] GUI Simplicity Stuff
- function fadeout(time)
- cols = {"lightGray","gray","black"}
- time = time / #cols
- for i = 1, #cols do
- sbc(colors[cols[i]])
- clear()
- sleep(time)
- end
- end
- function fadein(time)
- cols = {"gray","lightGray","white"}
- time = time / #cols
- for i = 1, #cols do
- sbc(colors[cols[i]])
- clear()
- sleep(time)
- end
- end
- function cprint(text, y)
- scp( (width / 2) - #text / 2, y)
- print(text)
- end
- function rprint(text,y)
- scp(relativeX, y)
- print(text)
- end
- function rlprint(text)
- scp(relativeX, relativeY)
- print(text)
- end
- function rcprint(text)
- -- why not working?
- scp( (width/2) - #text/2, relativeY+1)
- print(text)
- end
- --]] Click menu
- function createMenu(x,y,activecolor,atcolor,adur,bcolor,tcolor,options)
- local menu = {
- opt = options,
- mx = x,
- my = y,
- acolor = activecolor,
- atcol = atcolor,
- aduration = adur,
- bcol = bcolor,
- tcol = tcolor,
- selid = 1,
- setBackColor = function(self,color)
- self.bcol = color
- end,
- setTextColor = function(self,color)
- self.tcol = color
- end,
- setActiveBackColor = function(self,color)
- self.acolor = color
- end,
- setActiveTextColor = function(self,color)
- selt.atcol = color
- end,
- SwapColors = function(self)
- local ac = self.acolor
- local at = self.atcol
- self.acolor = self.bcol
- self.atcol = self.tcol
- self.bcol = ac
- self.tcol = at
- end,
- draw = function(self)
- for i=1, #self.opt do
- scp(self.mx, self.my + (i-1) )
- stc(self.tcol)
- sbc(self.bcol)
- print(self.opt[i])
- end
- end,
- flash = function(self,id)
- scp( self.mx, self.my+(id-1) )
- stc(self.atcol)
- sbc(self.acolor)
- print(self.opt[id])
- sleep(self.aduration)
- sbc(self.bcol)
- stc(self.tcol)
- rlprint(self.opt[id])
- end,
- update = function(self,ev)
- if(ev[1] == "mouse_click")then
- mcx = ev[3]
- mcy = ev[4]
- --print(mcx .." | " .. self.mx)
- --print(mcy .. " | " .. self.my)
- for i=1, #self.opt do
- if(mcx >= self.mx and mcx <= self.mx + #self.opt[i]
- and mcy == self.my + (i-1) )then
- self:flash(i)
- return self.opt[i]
- end
- end
- end
- end,
- }
- return menu
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement