Posted 18 September 2013 - 04:57 PM
Just forget it…..
I just found out that i could edit a local write function… now my only problem is the scrolling…
Im making an AdvSetup for all my programs. (currently only for AdvLock).
But im still struggling about making an console output field in the middle of the screen…
EDIT:
tried rewriting the "write" function… but it doesnt go to a next line when reaching the max width…
(max width is 34… min width is 16
miny is 6 (this doesnt do it either..,. (just prints from line 1 instead of line 6)
maxY is 14 (haven't tested if this doesnt work…)
)
photo:
http://imgur.com/aF8fm9l
Pictures:
http://imgur.com/l9kX4g2
http://imgur.com/624H0qJ
Questions:
How do i make so the consoleOutput will automatic split a long string onto more lines, when reaching the max size of the custom console?
How do i make a "faster" way to make my console print and scroll without the text flooding out of the screen?
EDIT: wow.. did 300 + really visit this post? I have an idea that someone refreshed this topic many times… but if not, then if any of thoose 300+ people could help, then Do so :P/>/>/> Thanks
Please help me :)/>/>/>/>
Thanks in Advance
I just found out that i could edit a local write function… now my only problem is the scrolling…
Spoiler
Hello Everyone :)/>/>/>/>Im making an AdvSetup for all my programs. (currently only for AdvLock).
But im still struggling about making an console output field in the middle of the screen…
EDIT:
tried rewriting the "write" function… but it doesnt go to a next line when reaching the max width…
(max width is 34… min width is 16
miny is 6 (this doesnt do it either..,. (just prints from line 1 instead of line 6)
maxY is 14 (haven't tested if this doesnt work…)
)
photo:
http://imgur.com/aF8fm9l
Spoiler
local gui_file
local termX, termY = term.getSize()
local status = nil
local inMain = true
function write( sText )
local w,h = 34, 14
local minx = 16
local miny = 6
local x,y = term.getCursorPos()
x = 16
local nLinesPrinted = 0
local function newLine()
if y + 1 <= h then
term.setCursorPos(minx, y + 1)
else
term.setCursorPos(minx, h)
term.scroll(1)
end
x, y = term.getCursorPos()
nLinesPrinted = nLinesPrinted + 1
end
-- Print the line with proper word wrapping
while string.len(sText) > 0 do
local whitespace = string.match( sText, "^[ \t]+" )
if whitespace then
-- Print whitespace
term.write( whitespace )
x,y = term.getCursorPos()
sText = string.sub( sText, string.len(whitespace) + 1 )
end
local newline = string.match( sText, "^\n" )
if newline then
-- Print newlines
newLine()
sText = string.sub( sText, 2 )
end
local text = string.match( sText, "^[^ \t\n]+" )
if text then
sText = string.sub( sText, string.len(text) + 1 )
if string.len(text) > w then
-- Print a multiline word
while string.len( text ) > 0 do
if x > w then
newLine()
end
term.write( text )
text = string.sub( text, (w-x) + 2 )
x,y = term.getCursorPos()
end
else
-- Print a word normally
if x + string.len(text) - 1 > w then
newLine()
end
term.write( text )
x,y = term.getCursorPos()
end
end
end
return nLinesPrinted
end
function print( ... )
local nLinesPrinted = 0
for n,v in ipairs( { ... } ) do
nLinesPrinted = nLinesPrinted + write( tostring( v ) )
end
nLinesPrinted = nLinesPrinted + write( "\n" )
return nLinesPrinted
end
print("11111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111")
function cPrint(text, yPos)
if yPos then
term.setCursorPos(1, yPos)
end
term.setCursorPos(math.ceil((termX / 2) - (text:len() / 2)), yPos)
write(text)
end
function consoleOutput(text, color)
local posx = {
["minX"] = 16;
["maxX"] = 34;
}
local posy = {
["minY"] = 6;
["maxY"] = 14;
}
for s, y in pairs(posy) do
for s, x in pairs(posx) do
term.setCursorPos(x,y)
term.setTextColor(color)
term.write(string.sub(string.len(text)/posx["maxX"],x))
end
end
end
function setup(status)
if not status then
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.clear()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.lightBlue)
term.clearLine()
cPrint(" AdvLock - Setup ", 1)
term.setBackgroundColor(colors.green)
cPrint(" ",termY/2-1)
cPrint(" INSTALL ADVLOCK ",termY/2)
cPrint(" ",termY/2+1)
--[[for i = 2, 14 do
term.setCursorPos(1,i)
write(i)
end ]]
term.setCursorPos(1,4)
write("12345678901234567890123456789012345678901234567890")
term.setCursorPos(1,19)
term.setBackgroundColor(colors.lightBlue)
term.clearLine()
cPrint(" AdvLock - Setup ", 19)
elseif status=="Clicked" then
for i = 5, 15 do
term.setBackgroundColor(colors.black)
cPrint(string.rep(" ", 40), i)
if i == 5 then
term.setBackgroundColor(colors.gray)
cPrint(string.rep(" ", 39).."X", i)
cPrint("Installing AdvLock...", i)
elseif i == 15 then
term.setBackgroundColor(colors.gray)
cPrint(string.rep(" ", 40), i)
else
term.setBackgroundColor(colors.gray)
term.setCursorPos(6, i)
write(" ")
term.setCursorPos(45, i)
write(" ")
end
sleep(0.05)
end
elseif status=="Cancel" then
consoleOutput("Cancelling installation...", colors.red)
sleep(1)
end
end
--[[
setup() -- run first setup screen.
while true do
event, button, x, y = os.pullEvent("mouse_click") -- Waiting for an mouse event
if button == 1 then -- Left mouse button
if x>=15 and x<=35 and y>=8 and y<=10 and inMain then -- Install button clicked
inMain = false
setup("Clicked")
elseif x==45 and y==5 and not inMain then
setup("Cancel")
inMain = true
setup()
elseif n == true then
inMain = true
setup()
end
else
end
end ]]
term.setCursorPos(1,17)
http://imgur.com/l9kX4g2
http://imgur.com/624H0qJ
Questions:
How do i make so the consoleOutput will automatic split a long string onto more lines, when reaching the max size of the custom console?
How do i make a "faster" way to make my console print and scroll without the text flooding out of the screen?
EDIT: wow.. did 300 + really visit this post? I have an idea that someone refreshed this topic many times… but if not, then if any of thoose 300+ people could help, then Do so :P/>/>/> Thanks
Please help me :)/>/>/>/>
Thanks in Advance