Posted 18 October 2012 - 06:11 PM
Hello my name is Dcleondc and im here to show you some functions/code that can help you make your next GUI.
if you are using these functions in your code make sure you put this code at the top
Print Center-This function does just what it says, it will print the text that you pass it in the center of the screen
Usage-
Print Right- This function prints the text that you pass it in the center of the right section of the screen.
Usage-
Print Left- This function prints the text that you pass it in the center of the left section of the screen.
Usage-
Print menu- this function will print a border around screen.
Usage-
setPos - faster the typing out term.setCursorPos(x,y)
usage- setPos(x,y)
code
if you are using these functions in your code make sure you put this code at the top
x, y = term.getSize()
Print Center-This function does just what it says, it will print the text that you pass it in the center of the screen
Usage-
printC("Put any text here", and put what line you want it on here)
CodeSpoiler
function printC( text, ypos )
term.setCursorPos(x/2 - #text/2, ypos)
term.write(text)
end
Print Right- This function prints the text that you pass it in the center of the right section of the screen.
Usage-
printR("Put any text here", and put what line you want it on here)
CodeSpoiler
function printR( text, ypos )
xpos1 = x/2
xpos2 = xpos1/2
xpos3 = xpos2+xpos1
xpos = xpos3-#text/2
term.setCursorPos(xpos,ypos)
term.write(text)
end
Print Left- This function prints the text that you pass it in the center of the left section of the screen.
Usage-
printL("Put any text here", and put what line you want it on here)
CodeSpoiler
function printL( text, ypos )
xpos1 = x/2
xpos2 = xpos1/2
xpos = xpos2 - #text/2
term.setCursorPos(xpos,ypos)
term.write(text)
end
Print menu- this function will print a border around screen.
Usage-
menu(x,y)
CodeSpoiler
function menu(x1,y1)
clear()
for i=1, x1-1 do
setPos(i,1)
write("#")
end
for i=1, x1-1 do
setPos(i,y1)
write("#")
end
for i=1, y1-1 do
setPos(1,i)
write("#")
end
for i=1, y1-1 do
setPos(x-1,i)
write("#")
end
end
setPos - faster the typing out term.setCursorPos(x,y)
usage- setPos(x,y)
code
Spoiler
function setPos(x,y)
setCursorPos(x,y)
end