Advertisement
billysback

square checking thingy

Oct 19th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1. local function getCell(x, y)
  2.     if grid[x] ~= nil then if grid[x][y] ~= nil then return grid[x][y] end end
  3.     return nil
  4. end
  5.  
  6. local function checkCell(x,y)
  7.     local coords = { { {-1, 0}, {-1, -1}, {0, -1}}, { {-1, 0}, {-1, 1}, {0, 1} }, { {0, 1}, {1, 1}, {1, 0} }, { {1, 0}, {1, -1}, {0, -1} } }
  8.     local ok = false
  9.     for i=1,#coords do
  10.         local n = 0
  11.         local coord = coords[i]
  12.         for j=1,#coord do
  13.             local co = coord[j]
  14.             --n = n + 1
  15.             if getCell(unpack(co)) == 1 then n = n + 1 end
  16.         end
  17.         if n == #coord then
  18.             ok = true
  19.         end
  20.     end
  21.     return ok
  22. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement