Basically, I want a line of code to be executed once a for loop has finally ended. My for loop is designed to search a table and satisfy an if statement:
local list={ [1] = "string1", [2] = "string2"}
local string
for key,value in pairs(list) do
if string == value then
--blah,blah,blah
end
end
--part that is supposed to execute code once the for loop is completed
test if for loop has ended
Started by Varscott11, Jul 03 2016 10:14 PM
2 replies to this topic
#1
Posted 03 July 2016 - 10:14 PM
#2
Posted 03 July 2016 - 11:15 PM
What is the issue you're having? Your code is correct, logically, are you wanting to finish the loop once the if statement is satisfied?
You do have two issues:
- Your if statement will never fire because the 'string' variable has no value in it.
- You may experience issues because your variable is named 'string' which is an API within Lua, consider renaming it.
You do have two issues:
- Your if statement will never fire because the 'string' variable has no value in it.
- You may experience issues because your variable is named 'string' which is an API within Lua, consider renaming it.
Edited by theoriginalbit, 03 July 2016 - 11:18 PM.
#3
Posted 03 July 2016 - 11:18 PM
I ended up figuring out what I needed to do. I just needed to put the code I wanted to execute after the for loop's "end". Making that code execute, once the for loop is complete. I should have figured this out on my own. I guess it is late, and my brain is shutting down.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











