I have Lua table, t, which I iterate:
for k, v in pairs(t) do
b = false
my_func(v)
end
and want iteration to pause until b global variable changes to true
Is it possible is Lua?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Unless you’re in a coroutine, there’s no concept of a Lua variable changing value without your code doing it. So you would be pausing until something that can’t possibly happen happens. Lua is inherently single-threaded.
As previously stated, you can use a coroutine to do this, but you’ll have to modify your code accordingly:
Note that changing the table referenced by
tbetween iterations is not going to do something useful.