lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hello Everyone,

I am trying to write a type of combination If Then statement and it doesn't seem to be working.  I want to write a statement where i can ensure a pattern of placing a gamepiece is being done correctly.  To do that I need a statement like below.  For instance the statement below is making sure the pieces in block "1,1" and "1,2" is correct.  I have 16 different blocks and depending on the game played in one level a person could be in 9 spots so I would need to check those spots.  Lets just say the spots are "1,1",  "1,2",  "1,3", "1,4",  "2,3",  "2,4",  "3,1",  "3,2",  "3,4"

How would I write an if then statement with those combinations in the code I have below?  Nothing I do works, so I know I'm doing something wrong.  


checkAllBlocks = function()
for i=1,#blocks do
if (blocks[i].x < 130 or blocks[i].y < 90) then
--DO STUFF HERE WHEN LEVEL ISN'T COMPLETED, PROBABLY NOTHING
return false
end
end
if (findBlock(1,1) == findBlock(1,2)) then 
native.showAlert("Uh-oh","You can't do that.",{"Try Again"});
--this stops our alert box from showing
return false
end
--DO STUFF HERE WHEN LEVEL IS COMPLETED
native.showAlert("level complete","success",{"Awesome!"});
return true
end