Advertisement
alestane

Map loader

Jan 1st, 2012
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.30 KB | None | 0 0
  1. local terrains = {
  2.     G = "grass",
  3.     D = "dirt",
  4.     R = "rock",
  5. }
  6.  
  7. return function (mapfile)
  8.     local new = {}
  9.     for line in io.lines(mapfile) do
  10.         local h = 1
  11.         local row = {}
  12.         for point in line:gmatch('.') do
  13.             row[h] = terrains[point]
  14.         end
  15.         table.insert(new, row)
  16.     end
  17.     return new
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement