Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back")
- local termWidth, termHeight = term.getSize()
- local selectedItem = 1
- local onMainMenu = true
- function Choice1()
- term.clear()
- term.setCursorPos(1,1)
- print("Traitement des données ...")
- print("Patientez S.V.P ...")
- rednet.send(83, "If10")
- local senderId, message, protocol = rednet.receive(6)
- print("Stone : " ..message)
- rednet.send(83, "If30")
- local senderId, message, protocol = rednet.receive(6)
- print("Emeraude : " ..message)
- rednet.send(83, "If40")
- local senderId, message, protocol = rednet.receive(6)
- print("Diamand : " ..message)
- rednet.send(83, "If50")
- local senderId, message, protocol = rednet.receive(6)
- print("Sable : " ..message)
- rednet.send(83, "If100")
- local senderId, message, protocol = rednet.receive(6)
- print("Glass : " ..message)
- rednet.send(83, "If90")
- local senderId, message, protocol = rednet.receive(6)
- print("Clear Glass: " ..message)
- print("----------------------" .."Inser OK to Exit")
- dd= read()
- end
- function Choice2()
- term.clear()
- term.setCursorPos(1,1)
- print("CHOICE 2")
- sleep(1)
- end
- function Exit()
- onMainMenu = false
- end
- mainMenu = {
- [1] = { text = "Statut des Service", handler = Choice1 },
- [2] = { text = "Choice 2", handler = Choice2 },
- [3] = { text = "Exit", handler = Exit },
- }
- function printMenu( menu )
- for i=1,#menu do
- if i == selectedItem then
- print(">> "..menu[i].text)
- else
- print(" "..menu[i].text)
- end
- end
- end
- function onKeyPressed( key, menu )
- if key == keys.enter then
- onItemSelected(menu)
- elseif key == keys.up then
- if selectedItem > 1 then
- selectedItem = selectedItem - 1
- end
- elseif key == keys.down then
- if selectedItem < #menu then
- selectedItem = selectedItem + 1
- end
- end
- end
- function onItemSelected( menu )
- menu[selectedItem].handler()
- end
- function main()
- while onMainMenu do
- term.clear()
- term.setCursorPos(1,1)
- printMenu(mainMenu)
- event, key = os.pullEvent("key")
- onKeyPressed(key,mainMenu)
- end
- end
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement