Jump to content




GUI ( Menus )


  • You cannot reply to this topic
1 reply to this topic

#1 1vannn

  • Members
  • 111 posts
  • LocationOhio, USA

Posted 26 November 2012 - 12:33 PM

Does anyone know how you can make menus that goto other pages? Like 'Email' would goto a Email Client, etc..

#2 Kingdaro

    The Doctor

  • Members
  • 1,636 posts
  • Location'MURICA

Posted 26 November 2012 - 01:33 PM

The other "pages" could be other programs, and you could just have a program display a menu, you press a corresponding key, and then open up a specified function.

Menu options could be stored in one table, while the programs they open could be triggered by another.

local options = {'Email','Music','Web Browser','Exit'}
local programs = {'email','music','webbrowser'}

while true do
  term.clear()
  term.setCursorPos(1,1)

  print 'Select an Option'
  print ''

  for i=1, #options do
    print(i..'. '..options[i])
  end

  local _, char = os.pullEvent('char')
  local num = tonumber(char)
  if num then
    if programs[num] then
      shell.run(programs[num])
    elseif options[num] == 'Exit' then
      shell.run('clear')
      break
    end
  end
end

This program would print:
Select an Option

1. Email
2. Music
3. Web Browser
4. Exit

And pressing 1, for example, would go to the email program.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users