Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local hexnums = { [10] = "a", [11] = "b", [12] = "c", [13] = "d", [14] = "e", [15] = "f" }
- function parseValue(tMap, x, y, sChar)
- if tMap == nil then
- error("tMap is ?(a nil value)")
- end
- if tonumber(lchar, 16) then
- sChar = math.pow(2, tonumber(sChar, 16))
- if sChar == colors.white then
- tMap[y][x] = 0
- elseif sChar == colors.orange then
- tMap[y][x] = 1
- end
- end
- end
- function saveMap(tMap, _sPath1, sPath2, sizex, sizey)
- if not fs.exists(_sPath1) then return false
- elseif tMap == nil then return false end
- tMap = {}
- local file = fs.open(_sPath1, "r")
- local line = file:readLine()
- while line do
- tMap[#tMap+1] = {}
- for i=1,math.min(#line,sizex) do
- local lchar = string.sub(line,i,i)
- parseValue(i, #tMap, lchar)
- end
- if #tMap == sizey then break end
- line = file:readLine()
- end
- file:close()
- local f = fs.open(sPath2, "w")
- f.write(textutils.serialize(tMap))
- f.close()
- return true
- end
- function loadMap(sPath)
- local file = fs.open(sPath, "r")
- local data = file.readAll()
- file.close()
- return textutils.unserialize(data)
- end
- function checkValue(mapPath, x, y)
- local map = loadMap(mapPath)
- return map[y][x]
- end
Advertisement
Add Comment
Please, Sign In to add comment