Reposted from here (http://www.computercraft.info/forums2/index.php?/topic/20087-ui-craftos-themed-menu/)
Alright, so I was bored and I saw a post in Ask A Pro where someone was creating a menu, and I thought, "You know, I could probably make a simple yet flexible menu". It turned out a bit better than I expected, and a lot more challenging. However, I present the final result to you today.
Here's how it works: You give the function a title and a bunch of options. It displays the title and allows the users to scroll through the options, creating multiple pages if necessary. Additionally, if you run it on an advanced computer (this is compatible with normal computers), it will color the brackets yellow. There's probably a million different ways to code this thing, but here's what I've come up with: Demo with GravityScore & 1lann's HTML Emulator (http://gravlann.github.io/?pastebin=5X5A1tF1)
pastebin get gbxiZJtc (http://www.pastebin.com/gbxiZJtc)
Better description of usage:
local option = menu( "Select an option", "option_1", "option_2", "option_3" )
if option == "option_3" then
--#do stuff
elseif option == "option_2" then
--#do stuff
elseif option == "option_1" then
--#do stuff
end
why are you hardcoding key values?
Instead of hard coding keys, look at the keys api (https://tweaked.cc/module/keys.html).
This will also help with the (unlikely) case if GLFW changes the order of their keycodes your program will still work.
the keycodes changed in 1.13 (https://tweaked.cc/reference/breaking_changes.html) because minecraft changed to lwjgl 3, it will probably happen again with lwjgl 4