КС
Size: a a a
КС
КС
A
КС
T
A
КС
КС
КС
КС
A
function find_start(map, height, width)
local res = coord;
while map[res.y][res.x] ~= 'I' and res.y < height do
res.x = 1;
while map[res.y][res.x] ~= 'I' and res.x < width do
res.x = res.x + 1;
end
res.y = res.y + 1;
end
if res.y == height then
error("File has no start");
end
return res;
end
T
local map = {
{1, 2, 3, 3},
{1, 2, 3, "I"},
{1, 2, 3, 3},
}
local coord = {
x = 1, y = 1
}
local function find_start(map, height, width)
local res = coord;
while map[res.y][res.x] ~= 'I' and res.y < height do
res.x = 1;
while map[res.y][res.x] ~= 'I' and res.x < width do
res.x = res.x + 1;
end
res.y = res.y + 1;
end
if res.y == height then
error("File has no start");
end
return res;
end
print(find_start(map, 2, 4))
Я правильно понял, как это должно использоваться?CP
CP
T