Advertisement
Descaii

Maze crap

Jul 28th, 2014
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.23 KB | None | 0 0
  1. -- Maze generation --
  2. local MZ = {}
  3. SZ = 100
  4. for x = 1,SZ do
  5.     for y = 1,SZ do
  6.         local N = {}
  7.         N.X = x
  8.         N.Y = y
  9.         N.Taken = false
  10.         table.insert(MZ,N)
  11.     end
  12. end
  13. for i,v in pairs(MZ) do
  14.     Sides = {Top = MZ[i-SZ],
  15.         Bottom = MZ[i+SZ],
  16.         Front = MZ[i+1],
  17.         Back = MZ[i-1],
  18.         TopRight = MZ[i-(SZ-1)],
  19.         TopLeft = MZ[i-(SZ+1)],
  20.         BottomLeft = MZ[i+(SZ-1)],
  21.         BottomRight = MZ[i+(SZ+1)]}
  22.     if Sides.Top and Sides.Bottom and Sides.Front and Sides.Back and Sides.TopRight and Sides.TopLeft and Sides.BottomLeft and Sides.BottomRight then
  23.         local N = math.random(1,8)
  24.         local G = Sides[N]
  25.         if G and G.Taken == false then
  26.             v.Taken = true
  27.         end
  28.         local TK = true
  29.         for i,v in pairs(Sides) do
  30.             if v.Taken then
  31.                 TK = false
  32.             end
  33.         end
  34.         v.Taken = TK
  35.     end
  36. end
  37. GS = 5
  38. Player=game.Players.LocalPlayer
  39. PlayerGui=Player:WaitForChild("PlayerGui")
  40. Screen=Instance.new("ScreenGui",PlayerGui)
  41. for i,v in pairs(MZ) do
  42.     if v.Taken then
  43.         local S = Instance.new("Frame",Screen)
  44.         S.Size = UDim2.new(0,GS,0,GS)
  45.         S.Position = UDim2.new(0,v.X*GS,0,v.Y*GS)
  46.     else
  47.         local S = Instance.new("Frame",Screen)
  48.         S.Size = UDim2.new(0,GS,0,GS)
  49.         S.Position = UDim2.new(0,v.X*GS,0,v.Y*GS)
  50.         S.BackgroundColor3 = Color3.new(0,0,0)
  51.     end
  52. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement