Here is a example program with it.
local running = true
--[[Menu Functions]]--
local function stop()
running = false
end
local function hey()
print("Hey")
end
--[[Menu Table]]--
local buttons = {
[1] = {buttonType = 1, startX = 1, endX = 1, startY = 1, endY = 1, buttonText = "&", command = hey},
[2] = {buttonType = 2, startX = 2, endX = 5, startY = 2, endY = 5, buttonText = "Hello", command = stop}
}
--[[Main Function]]--
function menu(menu)
for k,v in ipairs(menu) do
term.setCursorPos(menu[k].startX, menu[k].startY)
print(menu[k].buttonText)
end
while running do
event, p1, p2, p3 = os.pullEvent()
if event == "click" then
for k,v in ipairs(menu) do
if p3 == menu[k].buttonType then
if p1 >= menu[k].startX and p1 <= menu[k].endX and p2 >= menu[k].startY and p2 <= menu[k].endY then
menu[k].command()
end
end
end
end
end
end
term.clear()
menu(buttons)
It is pretty simple but very awesome!