added wolf's code
[swamp-bikeopera:code.git] / lib / map.lua
1 module("map", package.seeall)
2
3 require 'std'
4 require 'poly'
5
6 ---
7 --
8 function load() 
9     local ZONES = {}
10
11         for line in io.lines("/home/startx/projects/swamp-machine/trunk/src/test.csv") do
12             --print(line)
13             -- get the id
14             local id , name, coo = string.match(line, "^(%d+),\"(.-)\",(.-)$")
15                 if id and coo then
16                 --    print(id, coo)
17                 end
18                 coos = std.split(coo, ",")
19                 local area = {}
20                     for i=1, #coos, 2 do
21                        table.insert(area, { x = coos[i], y = coos[i+1] } )
22                     end
23                     table.insert(ZONES, area)
24         end
25
26 return ZONES
27 end
28
29
30