here is my logic..
This is the screen or print:
LOLS
EXIST
When you press Up arrow key
This will show up
LOLS <--
when you press down this will show up
EXISTS <--
by default you will see this
LOLS <--
Exists.
Please help me
Posted 29 May 2014 - 07:56 AM
Posted 29 May 2014 - 09:54 AM
pastebin get sYgbxW5S menu
Posted 29 May 2014 - 01:48 PM
local menu_options = {
"Option 1";
"Option 2";
}
local menu_index = 1
while true do
--# Start with drawing the menu
term.clear()
term.setCursorPos( 1,1 )
-- Loop through all menu options
for i = 1, #menu_options do
if menu_index == i then -- Check if the variable menu_index is equal to the current index
print( ">" .. menu_options[i] ) -- if it is, then print it with '>'
else
print( menu_options[i] ) -- if it isn't then print it regulary
end
end
--# Handle key input
--[[
os.pullEvent first returns the event that was pulled, then the key.
by putting "key" as an argument in the os.pullEvent function we
limit it to pull that event, so in this case it isn't needed to check
which event that was pulled
--]]
local event, param1 = os.pullEvent( "key" )
if param1 == keys.up then
if menu_index > 1 then
menu_index = menu_index - 1
end
elseif param1 == keys.down then
if menu_index < #menu_options then
menu_index = menu_index + 1
end
end
end
Hope this helped
Posted 29 May 2014 - 03:16 PM
0 members, 1 guests, 0 anonymous users