Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ Just Walk ]]--
- --[[ Just Does Games ]]--
- --[[ Init ]]--
- local sx,sy = term.getSize() if sx ~= 51 or sy ~= 19 or not term.isColor() then print("Display Error.") return end
- local px,py = 2,2
- local player_color = "lightBlue"
- local pallet_0 = {"black","white","red","orange","yellow","green","blue","purple"}
- local pallet_loaded = pallet_0
- local col_x = {}
- local col_y = {}
- local mp_mem = {}
- local currentMapx = 0
- local currentMapy = 0
- local Dir = "maps"
- local mp_beta = {"maps/mp_beta/mp_0-0/mp.lua", "maps/mp_beta/mp_0-0/mp_col.lua", "maps/mp_beta/mp_0-1/mp.lua", "maps/mp_beta/mp_0-1/mp_col.lua", "maps/mp_beta/mp_1-0/mp.lua", "maps/mp_beta/mp_1-0/mp_col.lua", "maps/mp_beta/mp_1-1/mp.lua", "maps/mp_beta/mp_1-1/mp_col.lua"}
- local mp_beta_files = {
- '234567822222222222222222222222222222222222222222222',
- '311111111111111111111111111111111111111111111111111',
- '411111111111111111111111111111111111111111111111111',
- '511111111111111111111111111111111111111111111111111',
- '611111111111111111111111111111111111111111111111111',
- '711111111111111111111111111111111111111111111111111',
- '811111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111222222222222222222222222222222222222222111112',
- '111111111111111111111111111111111111111111111111111',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000111111111111111111111111111111111111111000001',
- '211111222222222222222222222222222222222222222111112',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111111',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '811111111111111111111111111111111111111111111111112',
- '711111111111111111111111111111111111111111111111111',
- '611111111111111111111111111111111111111111111111111',
- '511111111111111111111111111111111111111111111111111',
- '411111111111111111111111111111111111111111111111111',
- '311111111111111111111111111111111111111111111111111',
- '234567822222222222222222222222222222222222222222222',
- '100000111111111111111111111111111111111111111000001',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '100000000000000000000000000000000000000000000000000',
- '111111111111111111111111111111111111111111111111111',
- '222222222222222222222222222222222222222222228765432',
- '111111111111111111111111111111111111111111111111113',
- '111111111111111111111111111111111111111111111111114',
- '111111111111111111111111111111111111111111111111115',
- '111111111111111111111111111111111111111111111111116',
- '111111111111111111111111111111111111111111111111117',
- '211111111111111111111111111111111111111111111111118',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '211111222222222222222222222222222222222222222111112',
- '111111111111111111111111111111111111111111111111111',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '100000111111111111111111111111111111111111111000001',
- '211111222222222222222222222222222222222222222111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '111111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111112',
- '211111111111111111111111111111111111111111111111118',
- '111111111111111111111111111111111111111111111111117',
- '111111111111111111111111111111111111111111111111116',
- '111111111111111111111111111111111111111111111111115',
- '111111111111111111111111111111111111111111111111114',
- '111111111111111111111111111111111111111111111111113',
- '222222222222222222222222222222222222222222228765432',
- '100000111111111111111111111111111111111111111000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '100000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '000000000000000000000000000000000000000000000000001',
- '111111111111111111111111111111111111111111111111111'
- }
- if not fs.exists("maps/mp_beta") then
- term.clear() term.setCursorPos(1,1) write("Loading Map Chunks 0 / 8")
- local tmp = 1
- for i=1, #mp_beta do
- local file = fs.open(mp_beta[i], "w")
- for i=1, 19 do
- file.writeLine(tostring(mp_beta_files[tmp]))
- tmp = tmp + 1
- end
- file.close() sleep(.000001)
- term.clear() term.setCursorPos(1,1) write("Loading Map Chunks "..i.." / 8")
- end
- end
- --[[ Init ]]--
- --[[ Functions ]]--
- function clr() term.clear() end
- function cp(x,y) term.setCursorPos(x,y) end
- function sb(col) term.setBackgroundColor(colors[col]) end
- function st(col) term.setTextColor(colors[col]) end
- function drawPlayer()
- cp(px,py) sb(player_color) write(" ")
- end
- function loadMap(mapDir, pallet)
- mp_mem = {}
- if mapDir ~= nil and fs.exists(mapDir.."/mp.lua") then
- if pallet == nil then pallet = {"black","black","black","black","black","black","black","black","black"} end
- local file = fs.open(mapDir.."/mp.lua", "r")
- clr() cp(1,1)
- for i=1, 19 do
- local map = file.readLine()
- for character in map:gmatch(".") do
- if type(tonumber(character)) ~= "number" then error("drawMap Requires a Valid Map") end
- if term.getBackgroundColor ~= pallet[tonumber(character)] then sb(pallet[tonumber(character)]) end write(" ")
- if #mp_mem == 0 then mp_mem[1] = pallet[tonumber(character)] else mp_mem[#mp_mem+1] = pallet[tonumber(character)] end
- end if i ~= 19 then print("") end
- end
- sb("black") cp(1,1)
- else
- end
- end
- function loadCol(mapDir)
- col_x = {}
- col_y = {}
- if mapDir ~= nil and fs.exists(mapDir.."/mp_col.lua") then
- local file = fs.open(mapDir.."/mp_col.lua", "r")
- for i=1, 19 do
- local col = file.readLine() local cnt = 1
- for character in col:gmatch(".") do
- if type(tonumber(character)) ~= "number" then error("loadCol Requires a Valid Col") end
- if tonumber(character) == 1 then if #col_x == 0 then col_x[1] = cnt else col_x[#col_x+1] = cnt end if #col_y == 0 then col_y[1] = i else col_y[#col_y+1] = i end end cnt = cnt + 1
- end
- end
- end
- end
- function isCol(x,y)
- for i=1, #col_x do
- if x == col_x[i] then
- if y == col_y[i] then
- return true
- end
- end
- end
- return false
- end
- function animateScreen(direction)
- sb("black")
- if direction == "up" then
- cp(1,sy)
- for i=1, sy do
- for i=1, sx do
- write(" ")
- end
- cp(1,sy-i) sleep(.01)
- end
- elseif direction == "down" then
- cp(1,1)
- for i=1, sy do
- for i=1, sx do
- write(" ")
- end
- cp(1,1+i) sleep(.01)
- end
- elseif direction == "left" then
- elseif direction == "right" then
- elseif direction == "blank" then
- clr() sleep(.1)
- end
- end
- --[[ Functions ]]--
- --[[ Main ]]--
- function main()
- loadMap("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy, pallet_loaded)
- loadCol("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy)
- drawPlayer()
- local running = true
- while running do
- sleep(.00001) a,i = os.pullEvent("key")
- if i == keys.w then
- if not isCol(px,py-1) then
- cp(px,py)
- if #mp_mem > 0 then sb(mp_mem[(51*(py-1))+px]) else sb("black") end write(" ")
- py = py - 1
- cp(px,py) sb(player_color) write(" ")
- end
- elseif i == keys.a then
- if not isCol(px-1,py) then
- cp(px,py)
- if #mp_mem > 0 then sb(mp_mem[(51*(py-1))+px]) else sb("black") end write(" ")
- px = px - 1
- cp(px,py) sb(player_color) write(" ")
- end
- elseif i == keys.s then
- if not isCol(px,py+1) then
- cp(px,py)
- if #mp_mem > 0 then sb(mp_mem[(51*(py-1))+px]) else sb("black") end write(" ")
- py = py + 1
- cp(px,py) sb(player_color) write(" ")
- end
- elseif i == keys.d then
- if not isCol(px+1,py) then
- cp(px,py)
- if #mp_mem > 0 then sb(mp_mem[(51*(py-1))+px]) else sb("black") end write(" ")
- px = px + 1
- cp(px,py) sb(player_color) write(" ")
- end
- elseif i == keys.q then
- sb("black") clr() cp(1,1) sleep(.1) running = false
- end
- if px < 1 then
- currentMapx = currentMapx - 1
- px = sx animateScreen("blank")
- loadMap("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy, pallet_loaded)
- loadCol("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy)
- drawPlayer()
- elseif px > sx then
- currentMapx = currentMapx + 1
- px = 1 animateScreen("blank")
- loadMap("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy, pallet_loaded)
- loadCol("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy)
- drawPlayer()
- elseif py < 1 then
- currentMapy = currentMapy - 1
- py = sy animateScreen("up")
- loadMap("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy, pallet_loaded)
- loadCol("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy)
- drawPlayer()
- elseif py > sy then
- currentMapy = currentMapy + 1
- py = 1 animateScreen("down")
- loadMap("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy, pallet_loaded)
- loadCol("maps/mp_beta/mp_"..currentMapx.."-"..currentMapy)
- drawPlayer()
- end
- end
- end
- main()
- --[[ Main ]]--
Advertisement
Add Comment
Please, Sign In to add comment