Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[Local Variables]]--
- local termWidth, termHeight = term.getSize()
- local selectItem = 1
- local turtleId
- local isWirelessTurtle
- local messageOutputFileName
- --[Wireless Print Functions]--
- isWirelessTurtle = peripheral.isPresent("right")
- if (isWirelessTurtle == true) then
- turtleId = os.getComputerLabel()
- rednet.open("right")
- end
- function writeMessage(message)
- print(message)
- -- If this turtle has a modem, then write the message to red net
- if (isWirelessTurtle == true) then
- if (turtleId == nil) then
- rednet.broadcast(message)
- else
- -- Broadcast the message (prefixed with the turtle's id)
- rednet.broadcast("[".. turtleId.."] "..message)
- end
- end
- if (messageOutputFileName ~= nil) then
- -- Open file, write message and close file (flush doesn't seem to work!)
- local outputFile = io.open(messageOutputFileName, "a")
- outputFile:write(message)
- outputFile:write("\n")
- outputFile:close()
- end
- end
- --[[menu methods]]--
- function farmsize()
- term.clear()
- term.setCursorPos(1,1)
- term.write("please input a width of farm and length")
- end
- function farmtype()
- term.clear()
- term.setCursorPos(1,1)
- term.write("please select a farm type")
- end
- function potatoes()
- end
- function wheat()
- end
- function carrots()
- end
- function sugarcane()
- end
- function help()
- term.clear()
- term.setCursorPos(1,1)
- term.write("=========================================")
- term.write("==This program is made by: The Stuntman==")
- term.write("==Set turtle one block behind first row==")
- term.write("==on the left most corner of your farm ==")
- term.write("==make sure there is a chest behind it ==")
- term.write("==then run the program and use menu ==")
- term.write("=========================================")
- sleep(10)
- menu()
- end
- function Exit()
- running = false
- end
- --[[Menu Definitions ]]--
- term.write("my name is" ..is.getComputerLabel)
- term.write("please select from the following")
- mainMenu = (
- [1] = { text = "Farm Size" }, handler = farmsize),
- [2] = { text = "Farm Type" }, handler = farmtype),
- [3] = { text = "Help" }, handler = help),
- [4] = { text = "Exit"}, handler )
- )
- --[[print menu]]--
- function printMenu( menu )
- for i=1, #menu do
- if i == selectedItem then
- print ("> "..menu[i].text)
- else
- print(" "..menu[i].text)
- end
- end
- end
- --[[ Handler Method]]--
- 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 == key.down then
- if selectedItem < #menu then
- selectedItem = selectedItem + 1
- end
- end
- function onItemSelected( menu )
- menu[selectedItem].handler()
- end
- --[[ Main method ]]--
- function main()
- while running do
- term.clear()
- term.setCursorPos(1,1)
- printMenu(mainMenu)
- even, key = os.pullEvent("key")
- onKeyPressed(key,mainMenu)
- end
- end
- menu()
Advertisement
Add Comment
Please, Sign In to add comment