-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathminesweeper1.lua
More file actions
95 lines (88 loc) · 3.82 KB
/
minesweeper1.lua
File metadata and controls
95 lines (88 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
_G.Enabled = true
_G.Debugging = false -- change to true if the script doesnt work to see errors
function Split(s, delimiter)
result = {};
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
table.insert(result, match);
end
return result;
end
spawn(function()
while true do
wait(5)
if _G.Enabled then
local start = Vector3.new(41.5, 56.5, 72.5)
for i,tile in pairs(game.Workspace.g.Parts:GetChildren()) do
local posx = (tile.Position.X - start.x) / 5
local posz = (tile.Position.Z - start.Z) / 5
tile.Name = tostring(posx) .. "|" .. tostring(posz)
end
else
break
end
end
end)
while true do
wait(0.3)
if _G.Enabled then
if game.Workspace.g.Parts:FindFirstChild("0|0") then
function thescript()
local numbertiles = {}
for i,tile in pairs(game.Workspace.g.Parts:GetChildren()) do
if tile.BrickColor == BrickColor.new("Daisy orange") then
table.insert(numbertiles, tile)
end
end
for i,tile in pairs(numbertiles) do
local tilepos = Split(tile.Name, "|")
local tilex = tonumber(tilepos[1])
local tilez = tonumber(tilepos[2])
local totalnearbybombs = 0
local totalpossiblebombs = 0
local safetiles = {}
for x=-1, 1, 1 do
for z=-1, 1, 1 do
if game.Workspace.g.Parts:FindFirstChild(tostring(tilex + x) .. "|" .. tostring(tilez + z)) then
local nearbytile = game.Workspace.g.Parts[tostring(tilex + x) .. "|" .. tostring(tilez + z)]
if nearbytile.BrickColor == BrickColor.new("Really red") then
totalpossiblebombs = totalpossiblebombs + 1
totalnearbybombs = totalnearbybombs + 1
end
if nearbytile.BrickColor == BrickColor.new("Moss") or nearbytile.BrickColor == BrickColor.new("Shamrock") then
totalpossiblebombs = totalpossiblebombs + 1
table.insert(safetiles, nearbytile)
end
end
end
end
--print(tile.Name, tonumber(tile.SurfaceGui.TextLabel.Text), totalnearbybombs, totalpossiblebombs)
if totalnearbybombs == tonumber(tile.SurfaceGui.TextLabel.Text) then
for i,stile in pairs(safetiles) do
if stile.Color ~= Color3.new(0, 1, 0) then
stile.Color = Color3.new(0, 1, 0)
end
end
elseif totalpossiblebombs == tonumber(tile.SurfaceGui.TextLabel.Text) then
for i,stile in pairs(safetiles) do
if stile:FindFirstChild("TouchInterest") then
stile.TouchInterest:Destroy()
end
if stile.Color ~= Color3.new(1, 0, 0) then
stile.Color = Color3.new(1, 0, 0)
end
end
end
end
end
if _G.Debugging then
thescript()
else
pcall(function()
thescript()
end)
end
end
else
break
end
end