Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Instances:
- local Clone = Instance.new("Frame")
- local TextLabel = Instance.new("TextLabel")
- --Properties:
- Clone.Name = "Clone"
- Clone.Parent = nil
- Clone.BackgroundColor3 = Color3.fromRGB(255, 176, 247)
- Clone.BorderColor3 = Color3.fromRGB(199, 116, 192)
- Clone.BorderSizePixel = 2
- Clone.Size = UDim2.new(0, 50, 0, 50)
- TextLabel.Parent = Clone
- TextLabel.AnchorPoint = Vector2.new(0.5, 0.5)
- TextLabel.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
- TextLabel.BackgroundTransparency = 1.000
- TextLabel.BorderColor3 = Color3.fromRGB(0, 0, 0)
- TextLabel.BorderSizePixel = 0
- TextLabel.Position = UDim2.new(0.5, 0, 0.5, 0)
- TextLabel.Size = UDim2.new(0.699999988, 0, 0.699999988, 0)
- TextLabel.Font = Enum.Font.SourceSans
- TextLabel.Text = " "
- TextLabel.TextColor3 = Color3.fromRGB(0, 0, 0)
- TextLabel.TextScaled = true
- TextLabel.TextSize = 14.000
- TextLabel.TextWrapped = true
- local x = 10
- local y = 10
- local bombs = 15
- local g = NP("Minesweeper",true,x*50,(y*50)+30)
- local map = {}
- local function isNumber(x)
- if x == "0" or x == "1" or x == "2" or x == "3" or x == "4" or x == "5" or x == "6" or x == "7" or x == "8" or x == "9" then
- return true
- else
- return false
- end
- end
- local function zerofill(xx,yy)
- local tofill = {{xx,yy,0}} -- { {x,y,0} } 0 is amount of times dided
- local cx,cy = xx,yy
- local canfill = true
- while canfill do
- --wait(.5)
- local oldcount = #tofill
- for i=1,oldcount do
- local v = tofill[i]
- if v[3] == 0 then
- v[3] = v[3] + 1
- -- west
- if v[2]-1 >= 1 then
- if map[v[1]][v[2]-1][1] == "0" then
- local clone = g.OuterFrame:FindFirstChild(map[v[1]][v[2]-1][2])
- clone.TextLabel.Text = " "
- clone.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- table.insert(tofill,{v[1],v[2]-1,0})
- else
- local clon = g.OuterFrame:FindFirstChild(map[v[1]][v[2]-1][2])
- clon.TextLabel.Text = map[v[1]][v[2]-1][1]
- clon.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- end
- end
- -- south
- if v[1]-1 >= 1 then
- if map[v[1]-1][v[2]][1] == "0" then
- local clone = g.OuterFrame:FindFirstChild(map[v[1]-1][v[2]][2])
- clone.TextLabel.Text = " "
- clone.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- table.insert(tofill,{v[1]-1,v[2],0})
- else
- local clon = g.OuterFrame:FindFirstChild(map[v[1]-1][v[2]][2])
- clon.TextLabel.Text = map[v[1]-1][v[2]][1]
- clon.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- end
- end
- -- east
- if v[2]+1 <= y then
- if map[v[1]][v[2]+1][1] == "0" then
- local clone = g.OuterFrame:FindFirstChild(map[v[1]][v[2]+1][2])
- clone.TextLabel.Text = " "
- clone.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- table.insert(tofill,{v[1],v[2]+1,0})
- else
- local clon = g.OuterFrame:FindFirstChild(map[v[1]][v[2]+1][2])
- clon.TextLabel.Text = map[v[1]][v[2]+1][1]
- clon.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- end
- end
- -- south
- if v[1]+1 <= x then
- if map[v[1]+1][v[2]][1] == "0" then
- local clone = g.OuterFrame:FindFirstChild(map[v[1]+1][v[2]][2])
- clone.TextLabel.Text = " "
- clone.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- table.insert(tofill,{v[1]+1,v[2],0})
- else
- local clon = g.OuterFrame:FindFirstChild(map[v[1]+1][v[2]][2])
- clon.TextLabel.Text = map[v[1]+1][v[2]][1]
- clon.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- end
- end
- else
- table.remove(tofill,i)
- break
- end
- end
- if oldcount == #tofill then
- --print("DFGNJKGK")
- canfill = false
- end
- --print("loop")
- end
- end
- --[[local function zerofill(xx,yy)
- print('looped')
- if xx > 0 and xx <= x and yy > 0 and yy <= y then -- isFillable part 1
- local clone = g.OuterFrame:FindFirstChild(map[xx][yy][2])
- if map[xx][yy][1] == "0" then -- isFillable part 2
- clone.TextLabel.Text = " "
- clone.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- else
- clone.TextLabel.Text = map[xx][yy][1]
- clone.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- end
- zerofill(xx+1,yy)
- zerofill(xx-1,yy)
- zerofill(xx,yy-1)
- zerofill(xx,yy+1)
- else
- return
- end
- end]]
- for i=1,x do
- local xgrid = {}
- for ii=1,y do
- local clon = Clone:Clone()
- clon.Position = UDim2.new(0,(i-1)*50,0,(ii-1)*50)
- clon.Parent = g.OuterFrame
- clon.Name = "a"..tostring(math.random(111111111,999999999))
- table.insert(xgrid,{"0",clon.Name})
- local left = Instance.new("BoolValue",clon)
- left.Name = "Button"
- left.Changed:Connect(function(change)
- if change == true then
- if clon.TextLabel.Text ~= " " then
- if map[i][ii][1] == "bomb" then
- clon.TextLabel.Text = "💣"
- else
- if map[i][ii][1] ~= "0" then
- clon.TextLabel.Text = map[i][ii][1]
- clon.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- else
- clon.TextLabel.Text = " "
- clon.BackgroundColor3 = Color3.fromRGB(255*.85, 176*.85, 247*.85)
- zerofill(i,ii)
- end
- end
- left.Value = false
- end
- end
- end)
- local right = Instance.new("BoolValue",clon)
- right.Name = "ButtonRight"
- right.Changed:Connect(function(change)
- if change == true then
- if not isNumber(clon.TextLabel.Text) and clon.TextLabel.Text ~= " " then
- if string.byte(clon.TextLabel.Text) == 240 then
- clon.TextLabel.Text = " "
- else
- clon.TextLabel.Text = "🚩"
- end
- end
- right.Value = false
- end
- end)
- end
- table.insert(map,xgrid)
- end
- local currentb = 0
- while currentb ~= bombs do
- local randomx = math.random(1,x)
- local randomy = math.random(1,y)
- if map[randomx][randomy][1] ~= "bomb" then
- map[randomx][randomy][1] = "bomb"
- currentb = currentb + 1
- if randomx-1 >= 1 and randomx-1 <= x and randomy-1 >= 1 and randomy-1 <= y and map[randomx-1][randomy-1][1] ~= "bomb" then
- local num = tonumber(map[randomx-1][randomy-1][1])+1
- map[randomx-1][randomy-1][1] = tostring(num)
- end
- if randomx-1 >= 1 and randomx-1 <= x and randomy >= 1 and randomy <= y and map[randomx-1][randomy][1] ~= "bomb" then
- local num = tonumber(map[randomx-1][randomy][1])+1
- map[randomx-1][randomy][1] = tostring(num)
- end
- if randomx-1 >= 1 and randomx-1 <= x and randomy+1 >= 1 and randomy+1 <= y and map[randomx-1][randomy+1][1] ~= "bomb" then
- local num = tonumber(map[randomx-1][randomy+1][1])+1
- map[randomx-1][randomy+1][1] = tostring(num)
- end
- if randomx >= 1 and randomx <= x and randomy-1 >= 1 and randomy-1 <= y and map[randomx][randomy-1][1] ~= "bomb" then
- local num = tonumber(map[randomx][randomy-1][1])+1
- map[randomx][randomy-1][1] = tostring(num)
- end
- if randomx >= 1 and randomx <= x and randomy+1 >= 1 and randomy+1 <= y and map[randomx][randomy+1][1] ~= "bomb" then
- local num = tonumber(map[randomx][randomy+1][1])+1
- map[randomx][randomy+1][1] = tostring(num)
- end
- --
- if randomx+1 >= 1 and randomx+1 <= x and randomy-1 >= 1 and randomy-1 <= y and map[randomx+1][randomy-1][1] ~= "bomb" then
- local num = tonumber(map[randomx+1][randomy-1][1])+1
- map[randomx+1][randomy-1][1] = tostring(num)
- end
- if randomx+1 >= 1 and randomx+1 <= x and randomy >= 1 and randomy <= y and map[randomx+1][randomy][1] ~= "bomb" then
- local num = tonumber(map[randomx+1][randomy][1])+1
- map[randomx+1][randomy][1] = tostring(num)
- end
- if randomx+1 >= 1 and randomx+1 <= x and randomy+1 >= 1 and randomy+1 <= y and map[randomx+1][randomy+1][1] ~= "bomb" then
- local num = tonumber(map[randomx+1][randomy+1][1])+1
- map[randomx+1][randomy+1][1] = tostring(num)
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement