Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- menu = 1
- x,y = term.getSize()
- char = "^"
- currentX = 0
- currentY = 0
- if not fs.exists("N-LeafG") then
- fs.makeDir("N-LeafG")
- end
- function Message(text, text2)
- for i=1,x-1 do
- term.setCursorPos(i, y-3)
- write("-")
- end
- term.setCursorPos(1, y-2)
- print(text)
- term.setCursorPos(1, y-1)
- print(text2)
- local event, a, b = os.pullEvent("key")
- for i=1,x-1 do
- term.setCursorPos(i, y-3)
- write(" ")
- end
- for i=1,x-1 do
- term.setCursorPos(i, y-2)
- write(" ")
- end
- for i=1,x-1 do
- term.setCursorPos(i, y-1)
- write(" ")
- end
- end
- local function cPrint(text)
- local x2,y2 = term.getCursorPos()
- term.setCursorPos(math.ceil((x / 2) - (text:len() / 2)), y2)
- print(text)
- end
- function newObject(pos1, pos2, item)
- if pos1 - currentX < x then
- term.setCursorPos(pos1 - currentX, pos2 - currentY)
- write(item)
- if pos1- currentX == x/2 and pos2- currentY == y/2 then
- if char == "v" then --up
- currentY = currentY -1
- elseif char == "^" then --down
- currentY = currentY +1
- elseif char == ">" then --left
- currentX = currentX -1
- elseif char == "<" then --right
- currentX = currentX +1
- end
- world()
- end
- end
- end
- function world()
- term.clear()
- term.setCursorPos(1,y-3)
- term.setCursorPos(x/2, y/2)
- write(char) --CHARACTER
- newObject(3,3,"X")
- end
- function game()
- if not fs.exists("N-LeafG/player") then
- term.clear()
- term.setCursorPos(1,y-3)
- Message("Hello, there!", "Glad to meet you!")
- Message("Welcome to the world of NeXiMoN", "My name is OAK.")
- Message("This world...", "")
- Message("...is inhabited far and wide by", "creatures called NeXiMon.")
- Message("But first,", "tell me about yourself.")
- Message("Lets begin with your name.", "What is it?")
- term.clear()
- term.setCursorPos(1,1)
- print("YOUR NAME?")
- input = read() --Input is defined here
- term.clear()
- Message("Ah, I remember now.", "Hello " ..input)
- term.clear()
- term.setCursorPos(1,1)
- print("P")
- Message("This is my grandson.", "")
- Message("He's been your rival since you both", "were kids.")
- Message("Erm... What was his name again?", "")
- term.clear()
- term.setCursorPos(1,1)
- print("RIVAL'S NAME?")
- input2 = read()
- term.clear()
- term.setCursorPos(x/2, y/2)
- write("^")
- Message("A world of dreams and adventures", "with NeXiMon awaits! Let's go!")
- name = fs.open("N-LeafG/player", "w")
- name:writeLine(input)--error here
- name:close()
- lol = fs.open("N-LeafG/rival", "w")
- lol:writeLine(input2)
- lol:close()
- end
- while true do
- world()
- local e,key = os.pullEvent( "key" )
- if key == 17 or key == 200 then --up
- currentY = currentY -1
- char = "^"
- elseif key == 31 or key == 208 then --down
- currentY = currentY +1
- char = "v"
- elseif key == 203 or key == 30 then --left
- currentX = currentX -1
- char = "<"
- elseif key == 205 or key == 32 then --right
- currentX = currentX +1
- char = ">"
- end
- end
- end
- function start()
- term.clear()
- term.setCursorPos(1,1)
- cPrint("NeXiMoN Leaf Green")
- cPrint("")
- if menu == 1 then
- cPrint("[ Load Game ]")
- else cPrint("Load Game") end
- if menu == 2 then
- cPrint("[ Reset Data ]")
- else cPrint("Reset Data") end
- if menu == 3 then
- cPrint("[ Quit ]")
- else cPrint("Quit") end
- end
- start()
- while true do
- local e,key = os.pullEvent( "key" )
- if key == 17 or key == 200 then
- if menu > 1 then
- menu = menu - 1
- start()
- end
- elseif key == 31 or key == 208 then
- if menu < 3 then
- menu = menu + 1
- start()
- end
- elseif key == 28 then
- break
- end
- end
- if menu == 3 then
- os.reboot()
- elseif menu == 2 then
- term.clear()
- term.setCursorPos(1,1)
- write("Are you sure? (y/n)")
- input = read()
- if input == "y" then
- shell.run("rm", "N-LeafG")
- print("Deleted!")
- sleep(1)
- os.reboot()
- else
- os.reboot()
- end
- elseif menu == 1 then
- game()
- end
- --2 pages
Advertisement
Add Comment
Please, Sign In to add comment