Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- map = {"x","x","x","x","x","x","x","x","x",
- "x","-","-","x","-","-","x","-","x",
- "x","x","-","x","x","-","x","-","x",
- "x","-","-","-","-","-","x","-","x",
- "x","-","-","-","-","-","-","-","x",
- "x","-","x","-","x","-","x","-","x",
- "x","-","-","x","-","-","-","-","x",
- "x","-","-","x","x","x","-","-","x",
- "x","x","x","x","x","x","x","x","x"}
- charx = 2
- chary = 2
- charpos = 11
- turn = 0
- npcon = false
- start = true
- credits = {"Developer: Urumasi", "Map: Urumasi", "Textures: Urumasi"}
- function drawNPC(nx,ny,npos,nchar,nmode)
- npcon = true
- npcx = nx
- npcy = ny
- npcchar = nchar
- npcmode = nmode
- npcpos = npos
- drawMap()
- end
- function updateNPC()
- if npcmode == "dumb" then
- turn = math.random(1,4)
- if (turn == 1) and (map[npcpos-9] == "-") then
- npcpos = npcpos-9
- npcy = npcy-1
- elseif (turn == 2) and (map[npcpos+9] == "-") then
- npcpos = npcpos+9
- npcy = npcy+1
- elseif (turn == 3) and (map[npcpos-1] == "-") then
- npcpos = npcpos-1
- npcy = npcx-1
- elseif (turn == 4) and (map[npcpos+1] == "-") then
- npcpos = npcpos+1
- npcy = npcx+1
- end
- end
- end
- function drawMap()
- shell.run("clear")
- print("+--+--+-+")
- print("| | | |")
- print("+- +- | |")
- print("| ' |")
- print("| |")
- print("| O O O |")
- print("| , |")
- print("| +-- |")
- print("+-------+")
- if npcon then
- term.setCursorPos(npcx,npcy)
- write(npcchar)
- end
- term.setCursorPos(charx,chary)
- print("&")
- end
- function move(side)
- if (side == "w") and (map[charpos-9] == "-") then
- charpos = charpos-9
- chary = chary-1
- elseif (side == "s") and (map[charpos+9] == "-") then
- charpos = charpos+9
- chary = chary+1
- elseif (side == "a") and (map[charpos-1] == "-") then
- charpos = charpos-1
- charx = charx-1
- elseif (side == "d") and (map[charpos+1] == "-") then
- charpos = charpos+1
- charx = charx+1
- end
- drawMap()
- end
- function drawCredits()
- shell.run("clear")
- print("\n\n\n"..credits[1])
- sleep(1)
- shell.run("clear")
- print("\n\n"..credits[1])
- print(credits[2])
- sleep(1)
- shell.run("clear")
- print("\n"..credits[1])
- print(credits[2])
- print(credits[3])
- sleep(1)
- shell.run("clear")
- print(credits[1])
- print(credits[2])
- print(credits[3])
- sleep(1)
- shell.run("clear")
- print(credits[2])
- print(credits[3])
- sleep(1)
- shell.run("clear")
- print(credits[3])
- sleep(1)
- shell.run("clear")
- sleep(1)
- drawMap()
- end
- function drawMenu()
- shell.run("clear")
- print("Back")
- print("Exit game")
- mc = true
- while mc do
- local event, param1, param2, param3 = os.pullEvent("mouse_click")
- if param1 == 1 then
- if (param2 > 0) and (param2 < 5) and (param3 == 1) then
- mc = false
- drawMap()
- end
- if (param2 > 0) and (param2 < 10) and (param3 == 2) then
- mc = false
- start = false
- shell.run("clear")
- end
- end
- end
- end
- drawMap()
- while start do
- local event, param1 = os.pullEvent("char")
- if (param1 == "w") or (param1 == "a") or (param1 == "s") or (param1 == "d") then
- move(param1)
- end
- if param1 == "c" then
- drawCredits()
- end
- if param1 == "l" then
- shell.run("clear")
- print("+++ +++ ++++")
- print("+ + + + +")
- print("++ +++ + ++")
- print("+ + + + +")
- print("+ + + ++++")
- print("\nVersion: 0.1")
- print("\n156 lines of code!")
- print("\nChangelog:")
- print("Initial release!")
- print("\nWIP: NPCs")
- print("\n\nPress any key to return.")
- event, param1 = os.pullEvent("char")
- drawMap()
- end
- if param1 == "m" then
- drawMenu()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment