Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --MENU
- --VARIABLES
- local version = "ULTIMATE WOOD CHOPPER BETA 0.9.5 prerelease"
- local w,h = term.getSize()
- local select, menu = 1, 1
- local running = true
- rednet.open("back")
- --PRINT
- local function printCentered(str, ypos)
- term.setCursorPos(w/2 - #str/2, ypos)
- term.write(str)
- end
- local function printRight(str, ypos)
- term.setCursorPos(w-#str, ypos)
- term.write(str)
- end
- function clearScreen()
- term.clear()
- term.setCursorPos(1,1)
- term.clear()
- end
- function drawHeader(title, line)
- printCentered(title, line)
- printCentered(string.rep("-", w), line+1)
- end
- function drawCopyright()
- printRight("by UNOBTANIUM", h)
- end
- --MENUS
- local menupoint = {
- {"Chop", "Turtle Interactions", "Help", "Credits", "Quit",nil,nil},
- {"Farm","Single Tree","Back",nil,nil,nil},
- {"Standard Farm","Expanded Farm","Variables","Back",nil,nil,nil},
- {},
- {"Standard Farm","Expanded Farm","Back",nil,nil,nil,nil},
- {"Debug","Move Down","Back",nil,nil,nil,nil},
- {"Help Programs","Help Interface","Back",nil,nil,nil,nil},
- {"General 1x1 Tree","General 2x2 Tree","Back",nil,nil,nil,nil},
- {"Movement","Actions","Back",nil,nil,nil,nil,nil},
- {"Forward","Back","Up","Down","Turn Left","Turn Right","Back"},
- {"Refuel","Dig","Select","Back",nil,nil,nil},
- {"Up","Front","Down","Back",nil,nil,nil}
- }
- local menupointselected = {
- {">> Chop <<", ">> Turtle Interactions <<", ">> Help <<", "> Credits <", "> Quit <",nil, nil},
- {">> Farm <<",">> Single Tree <<","> Back <",nil,nil,nil,nil},
- {"> Standard Farm <","> Expanded Farm <","> Variables <","> Back <",nil,nil,nil},
- {},
- {"> Standard Farm <","> Expanded Farm <","> Back <",nil,nil,nil,nil},
- {">> Debug <<","> Move Down <","> Back <",nil,nil,nil,nil},
- {">> Help Programs <<","> Help Interface <","> Back <",nil,nil,nil,nil},
- {"> General 1x1 Tree <","> General 2x2 Tree <","> Back <",nil,nil,nil,nil},
- {">> Movement <<",">> Actions <<","> Back <",nil,nil,nil,nil},
- {"> Forward <","> Back <","> Up <","> Down <","> Turn Left <","> Turn Right <","> Back <"},
- {"> Refuel <",">> Dig <<","> Select <","> Back <",nil,nil,nil},
- {"> Up <","> Front <","> Down <","> Back <",nil,nil,nil}
- }
- local menupointnext = {
- {2, 9, 7, "credits", "quit"},
- {3,8,1},
- {"standard","expanded","variables",2},
- {},
- {"debugstandard","debugexpanded",6},
- {5,"godown",7},
- {6,"helpinterface",1},
- {"onebyone","twobytwo",2},
- {10,11,1},
- {"forward","back","up","down","left","right",9},
- {"refuel",12,"select",9},
- {"digup","digfront","digdown",10}
- }
- function drawMenu()
- drawHeader(version, 1)
- if menu == 1 then
- drawCopyright()
- end
- for i=1,7 do
- if menupoint[menu][i] then
- if select == i then
- printCentered(menupointselected[menu][i], i+4)
- else
- printCentered(menupoint[menu][i], i+4)
- end
- end
- end
- end
- --RUN MENU
- function waitseconds(i)
- message = ""
- clearScreen()
- print("Sending command...")
- id, message = rednet.receive(1)
- if message == "started" then
- print("Started program...")
- sleep(0.1)
- print("Program in process...")
- sleep(i)
- else
- print("No waiting turtle around...")
- sleep(2)
- end
- end
- function runMenu()
- while running do
- clearScreen()
- drawMenu(menu)
- local id, key = os.pullEvent("key")
- if key == 200 or key == 17 then
- select = select-1
- end
- if key == 208 or key == 31 then
- select = select+1
- end
- if select == 0 then
- for i=7,1,-1 do
- if menupoint[menu][i] then
- select = i
- break
- end
- end
- end
- if not menupoint[menu][select] then
- select = 1
- end
- if key == 14 or key == 30 then
- for i=7,1,-1 do
- if menupoint[menu][i] then
- select = i
- break
- end
- end
- if type(menupointnext[menu][select]) == "string" then
- clearScreen()
- running = false
- break
- elseif type(menupointnext[menu][select]) == "number" then
- menu = menupointnext[menu][select]
- for i=7,1,-1 do
- if menupoint[menu][i] then
- select = i
- break
- end
- end
- end
- end
- clearScreen()
- if key == 28 or key == 32 then
- if type(menupointnext[menu][select]) == "string" then
- rednet.broadcast(menupointnext[menu][select])
- if menupointnext[menu][select] == "quit" then
- running = false
- break
- elseif menupointnext[menu][select] == "credits" then
- drawMenuCredits()
- elseif menupointnext[menu][select]== "helpinterface" then
- FWChelp()
- elseif menupointnext[menu][select] == "godown"
- or menupointnext[menu][select] == "standard"
- or menupointnext[menu][select] == "expanded"
- or menupointnext[menu][select] == "debugstandard"
- or menupointnext[menu][select] == "debugexpanded"
- or menupointnext[menu][select] == "onebyone"
- or menupointnext[menu][select] == "twobytwo"
- or menupointnext[menu][select] == "standardnobonemeal"
- or menupointnext[menu][select] == "expandednobonemeal" then
- waitseconds(3)
- elseif menupointnext[menu][select] == "forward"
- or menupointnext[menu][select] == "back"
- or menupointnext[menu][select] == "up"
- or menupointnext[menu][select] == "down"
- or menupointnext[menu][select] == "left"
- or menupointnext[menu][select] == "right"
- or menupointnext[menu][select] == "refuel"
- or menupointnext[menu][select] == "select"
- or menupointnext[menu][select] == "digup"
- or menupointnext[menu][select] == "digfront"
- or menupointnext[menu][select] == "digdown" then
- waitseconds(0)
- elseif menupointnext[menu][select] == "variables" then
- clearScreen()
- print("Changing the variables are not available in the rednet version. Please use the normal uwc program to do that. The turtle will use these in the rednet version as well.")
- sleep(5)
- end
- elseif type(menupointnext[menu][select]) == "number" then
- menu = menupointnext[menu][select]
- select = 1
- end
- end
- end
- end
- function FWChelp()
- print("Welcome to the UWC Help Interface!")
- print("If you have any question, suggestions, bugs or feedback, let me know: Type")
- print("computercraft forum ultimate wood chopper")
- print("in Google and write a post or PM at me ;D")
- read()
- end
- function drawMenuCredits()
- drawHeader(version,1)
- printCentered("all nicknames from the CC forums!!",3)
- printCentered("- IDEA, CODEING & PUBLISHER -",5)
- printCentered("unobtanium",6)
- printCentered("- HELPING WITH CODING -",8)
- printCentered("theoriginalbit, Mtdj2, NitrogenFingers", 9)
- printCentered("- SPECIAL THANKS GOES TO -",11)
- printCentered("Hoppingmad9, xInDiGo, Seleck",12)
- printCentered("Permutation, PhilHibbs, DavEdward ",13)
- read()
- clearScreen()
- drawHeader(version,1)
- printCentered("- MENTIONABLES -",3)
- printCentered("HotGirlEAN, snoxx, steel_toed_boot,",4)
- printCentered("Zagi, Kylun, Kravyn, PhaxeNor, ughzug",5)
- printCentered("sjkeegs, atlas, Minithra, TheFan",6)
- printCentered("grumpysmurf, Quickslash78, lewanator1",7)
- printCentered("behedwin, TESTimonSHOOTER",8)
- printCentered("Kevironi, Fuzzlewhumper, Bigdavie",9)
- printCentered("Viproz, Bigjimmy12, bomanski, punchin",10)
- printCentered("oxgon, ahwtx, zilvar2k11",11)
- printCentered("The_Ianator, Coolkrieger3", 12)
- read()
- clearScreen()
- drawHeader(version,1)
- printCentered(version,1)
- printCentered("And last but not least",6)
- printCentered("You, the users and players :D",7)
- printCentered("Thank you everybody!!!", 10)
- read()
- end
- -- MAIN PROGRAM
- while running == true do
- runMenu()
- end
Advertisement
Add Comment
Please, Sign In to add comment