CraftOS Themed Menu

Started by KingofGamesYami, Aug 13, 2018, 01:10 am

Previous topic - Next topic

KingofGamesYami

Reposted from here

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

pastebin get gbxiZJtc

Better description of usage:
Code Select
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
I'm a ComputerCraft veteran with over 3k posts on the old ComputerCraft Forum.  I'm mostly inactive in CC having moved on to bigger, more interesting projects but still contribute to the community.