Posted 04 February 2015 - 10:24 PM
Hello,
I'm working on a Database and I got some problems with it. So I thought lets ask it here
maybe someone here can help me out.
This two functions up here will print all logs and will print the Header. But
when a Log Message the bottom of the screen the thing will mess up and some things will just print
into other messages. Thats that,
Then we have another problem that with my scrolling event of the Logs.
That is not working correctly at all, maybe someone can see a litle problem.
Then the page where the users will be printed, I want to use key arrows to scroll down too.
The problem is that when I reached the top I will be able to go down but it wont scroll down.
Scroll system:
Key press:
I guess you will think, what alot of problems. I know
I'm still learning and I just want to know how to fix this such
things. I dont suspect someone can answer all problems, but I hope someone can just
answer some. Like the printing logs thing is the biggest problem.
This picture will show you what I meant with printing in other logs.
Thankyou,
Jasper
I'm working on a Database and I got some problems with it. So I thought lets ask it here
maybe someone here can help me out.
function logview.printHeader()
term.setCursorPos(1,1)
term.setBackgroundColor(colors.gray)
term.clearLine()
term.setCursorPos(1,2)
term.clearLine()
term.setCursorPos(1,3)
term.clearLine()
term.setCursorPos(2,2)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.gray)
if offline == 0 then
term.write(" x ")
elseif offline == 1 then
term.write(" > ")
end
term.setCursorPos(6,2)
term.setBackgroundColor(colors.gray)
term.setTextColor(colors.white)
term.write(Log_Running_Status)
-- Buttons --
term.setBackgroundColor(colors.cyan)
term.setTextColor(colors.white)
term.setCursorPos(18,2)
term.write(" Options ")
term.setBackgroundColor(colors.blue)
term.setTextColor(colors.white)
term.setCursorPos(28,2)
term.write(" Log ")
term.setCursorPos(34,2)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.gray)
write(" Accounts ")
term.setTextColor(colors.gray)
term.setBackgroundColor(colors.white)
term.setCursorPos(45,2)
write(" Quit ")
end
function logview.printLogs(offset)
lineNumber = 3
-- Print the layout --
term.setCursorPos(34,2)
term.setTextColor(colors.gray)
term.setBackgroundColor(colors.white)
term.write(" Accounts ")
term.setBackgroundColor(colors.white)
term.clear()
logview.printHeader()
if #log > 0 then
for i = offset, offset + 16 do
if i > #log then break end
if log[i][2] == "Info" then
term.setCursorPos(1,lineNumber+1)
term.setTextColor(colors.blue)
write("["..log[i][2].."] ")
term.setTextColor(colors.lightGray)
x, y = term.getCursorPos()
term.setCursorPos(x,y)
write(log[i][1])
xP, lineNumber = term.getCursorPos()
elseif log[i][2] == "Success" then
term.setCursorPos(1,lineNumber+1)
term.setTextColor(colors.green)
write("["..log[i][2].."] ")
term.setTextColor(colors.lightGray)
x, y = term.getCursorPos()
term.setCursorPos(x,y)
write(log[i][1])
xP, lineNumber = term.getCursorPos()
elseif log[i][2] == "Warning" then
term.setCursorPos(1,lineNumber+1)
term.setTextColor(colors.red)
write("["..log[i][2].."] ")
term.setTextColor(colors.lightGray)
x, y = term.getCursorPos()
term.setCursorPos(x,y)
write(log[i][1])
xP, lineNumber = term.getCursorPos()
elseif log[i][2] == "Error" then
term.setCursorPos(1,lineNumber+1)
term.setTextColor(colors.red)
write("["..log[i][2].."] ")
term.setTextColor(colors.lightGray)
x, y = term.getCursorPos()
term.setCursorPos(x,y)
write(log[i][1])
xP, lineNumber = term.getCursorPos()
elseif log[i][2] == "Alert" then
term.setCursorPos(1,lineNumber+1)
term.setTextColor(colors.red)
write("["..log[i][2].."] ")
term.setTextColor(colors.lightGray)
x, y = term.getCursorPos()
term.setCursorPos(x,y)
write(log[i][1])
xP, lineNumber = term.getCursorPos()
end
logview.printHeader()
end
end
end
This two functions up here will print all logs and will print the Header. But
when a Log Message the bottom of the screen the thing will mess up and some things will just print
into other messages. Thats that,
Then we have another problem that with my scrolling event of the Logs.
function logview.userScrolls()
while true do
event, amount = os.pullEvent()
if event == "mouse_scroll" then
logstartTime = 0
local loglastOffset = logCurrentOffset
if logCurrentOffset + amount <= 1 then
logCurrentOffset = 1
elseif (amount + logCurrentOffset + 15 >= #log) then
logCurrentOffset = #log - 15
if logCurrentOffset <= 1 then
logCurrentOffset = 1
end
else
logCurrentOffset = logCurrentOffset + amount
end
if logCurrentOffset ~= loglastOffset then
logview.printLogs(logCurrentOffset)
end
end
end
end
That is not working correctly at all, maybe someone can see a litle problem.
Then the page where the users will be printed, I want to use key arrows to scroll down too.
The problem is that when I reached the top I will be able to go down but it wont scroll down.
Scroll system:
function userScrolls()
while true do
event, amount = os.pullEvent()
if event == "mouse_scroll" then
startTime = 1
local lastOffset = currentOffset
if currentOffset + amount <= 1 then
currentOffset = 1
elseif (amount + currentOffset + 11 >= #currentUsers) then
currentOffset = #currentUsers - 11
if currentOffset <= 1 then
currentOffset = 1
end
else
currentOffset = currentOffset + amount
end
if currentOffset ~= lastOffset then
printUsers(currentOffset)
end
end
end
end
Key press:
elseif s == 200 then
keyAmount = 1
keyAm = keyAm - 1
if selectedRow then
if selectedRow == 1 then
else
selectedRow = selectedRow - 1
selectedAccount = Users[selectedRow]
printUsers(currentOffset)
end
end
elseif s == 208 then
keyAmount = 1
keyAm = keyAm + 1
if selectedRow then
if selectedRow == 12 then
else
selectedRow = selectedRow + 1
selectedAccount = Users[selectedRow]
printUsers(currentOffset)
end
end
I guess you will think, what alot of problems. I know
I'm still learning and I just want to know how to fix this such
things. I dont suspect someone can answer all problems, but I hope someone can just
answer some. Like the printing logs thing is the biggest problem.
This picture will show you what I meant with printing in other logs.
Thankyou,
Jasper