Code: Select all
if level.rComplete[*numbers 1-8*] and level.cComplete[*numbers 1-8*] then
level.complete = true
else
level.complete = false
end
Code: Select all
if level.rComplete[*numbers 1-8*] and level.cComplete[*numbers 1-8*] then
level.complete = true
else
level.complete = false
end
Code: Select all
function isLevelCompleted()
for _, goal in ipairs(level.rComplete) do
if not goal then return false end
end
for _, goal in ipairs(level.cComplete) do
if not goal then return false end
end
return true
end
I want to have something that would do this:MadByte wrote:I can't see what you want to know from your tiny bit of code. You need to explain what you want to accomplish,
otherwise I just can guess.
- What kind of game are you working on?
- What is "rComplete" and "cComplete" ?
Code: Select all
if level.rComplete[1] and level.rComplete[2] and level.rComplete[3] and level.rComplete[4] and level.rComplete[5] and level.rComplete[6] and level.rComplete[7] and level.rComplete[8] and level.cComplete[1] and level.cComplete[2] and level.cComplete[3] and level.cComplete[4] and level.cComplete[5] and level.cComplete[6] and level.cComplete[7] and level.cComplete[8] then
level.complete = true
else
level.complete = false
end
Code: Select all
--Example Time --
level.data = {
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
{1, 1, 2, 2, 1, 1, 2, 1, 2, 2},
}
Code: Select all
for x = 0, level.width do
for y = 0, level.height do
if level.data[x][y] == 1 then
-- do stuff
end
end
end
Code: Select all
function checkCompleted()
for x = 0, level.width do
for y = 0, level.height do
if level.data[x][y] ~= 1 then return end
end
end
return true
end
Code: Select all
function checkComplete()
--Columns--
for i=1, #level.cComplete do
if not level.cComplete[i] then return false
end
--Rows--
for i=1, #level.rComplete do
if not level.rComplete[i] then return false
end
return true
end
Code: Select all
level.complete = true
for i = 1,8,1 do
if not level.rComplete[i] or not level.cComplete[i] then
level.complete = false
break
end
end
Wow, cant believe I missed such an obvious solution. Thank you a lot! Works perfectly fine for me.Rickton wrote:If you know it's always going to be 8x8, you can keep it pretty simple:Code: Select all
level.complete = true for i = 1,8,1 do if not level.rComplete[i] or not level.cComplete[i] then level.complete = false break end end
Users browsing this forum: Bing [Bot] and 202 guests