Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7758761
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T13:26:54+00:00 2026-06-01T13:26:54+00:00

I have Lua table, t , which I iterate: for k, v in pairs(t)

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T13:26:56+00:00Added an answer on June 1, 2026 at 1:26 pm

    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:

    function CoIterateTable(t)
      for k, v in pairs(t) do
        b = false
        my_func(v)
    
        while(b == false) do coroutine.yield() end
      end
    end
    
    local co = coroutine.create(CoIterateTable)
    
    assert(co.resume(t))
    --Coroutine has exited. Possibly through a yield, possibly returned.
    while(co.running()) do
      --your processing between iterations.
      assert(co.resume(t))
    end
    

    Note that changing the table referenced by t between iterations is not going to do something useful.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to Lua and I want to create a table [doh] which would
How to iterate over pairs of table elements in lua? I would like to
So currently I have a table in Lua that contains another table (much like
I have a C program which uses Lua for scripting. In order to keep
I have the following lua script : module(modoo,package.seeall) foo=1 bar={12,34} Which works fine using
I have a key => value table I'd like to sort in Lua. The
I have a Lua table and an index function like this: curIndex = 0
I have a lua table that I use as a hashmap, ie with string
I want to store a lua table where the keys are other lua tables.
I am new to Lua and want to print the contents of a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.