iMr.WiFi..! Posted February 14, 2018 Share Posted February 14, 2018 (edited) Hello guys! as i write in title, I have small question it's about loop! i've small loop, ok? i want stop loop in every value and calls a functions and wait a response from function, if function give any value i want to continue the loop! anyone have idea or suggest to help me at this? Edited February 14, 2018 by iMr.WiFi..! Link to comment
Overkillz Posted February 14, 2018 Share Posted February 14, 2018 Inside the loop if value == "whatever" then -- whatever u want to do return end Link to comment
Moderators IIYAMA Posted February 14, 2018 Moderators Share Posted February 14, 2018 If not A-sync, then: function testFunction () return math.random(1000) % 2 == 0 end function start () for i=1, 1000 do local value = testFunction() if value then print(value) else break end end end start() If A-sync, use: https://www.lua.org/pil/9.1.html Link to comment
iMr.WiFi..! Posted February 14, 2018 Author Share Posted February 14, 2018 2 hours ago, Overkillz said: Inside the loop if value == "whatever" then -- whatever u want to do return end There timer on function before give a value. 1 hour ago, IIYAMA said: If not A-sync, then: function testFunction () return math.random(1000) % 2 == 0 end function start () for i=1, 1000 do local value = testFunction() if value then print(value) else break end end end start() If A-sync, use: https://www.lua.org/pil/9.1.html Will coroutine working in mta? because 'os' and 'io' libraries weren't worked with me! Link to comment
Moderators IIYAMA Posted February 14, 2018 Moderators Share Posted February 14, 2018 (edited) Coroutine does work. Edited February 14, 2018 by IIYAMA 1 Link to comment
iMr.WiFi..! Posted February 14, 2018 Author Share Posted February 14, 2018 1 hour ago, IIYAMA said: Coroutine does work. Thanks! that works. 1 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now