Posted 08 December 2012 - 05:50 AM
Hello!
I've got a question: At this code, when there are more entries then possible (like you got 9 lines left and got 16 selections to list) how to make it scroll in different "pages"
Thank you!
Rickydaan
I've got a question: At this code, when there are more entries then possible (like you got 9 lines left and got 16 selections to list) how to make it scroll in different "pages"
function menu( table )
local selected = 1
local nx,ny = term.getCursorPos()
local stop = false
while not stop do
for _,content in ipairs(table) do
term.setCursorPos(nx,ny+_-1)
if _ == selected then print("-> "..content)
else
print(" "..content)
end
end
event,char = os.pullEvent()
if event == "key" and char == 208 then if selected ~= #table then selected = selected+1 end end
if event == "key" and char == 200 then if selected ~= 1 then selected = selected-1 end end
if event == "key" and char == 28 then stop = true return table[selected] end
end
end
Thank you!
Rickydaan