Jump to content

[Question] How can i continue the loop after getting thing from value?


iMr.WiFi..!

Recommended Posts

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 by iMr.WiFi..!
Link to comment
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...