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 5933007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:54:49+00:00 2026-05-22T14:54:49+00:00

In my lua script I need to call a function which takes an arbritary

  • 0

In my lua script I need to call a function which takes an arbritary number of arguments with, well, an arbitrary number of arguments…

I am building up my arguments as a table as I cant know how many arguments there will be.

Sample code:

local result = call.someFunc();
local arguments = {}

for k,v in pairs(result) do
    table.insert(arguments, v.name)
end

-- here I would like to somehow pass the whole table and each item in the table
-- is then passed as a single argument to "someOtherFunc"
call.someOtherFunc(arguments[1], arguments[2], arguments[3] ....) 

I am pretty new to lua, in PHP e. g. I would use call_user_func_array – is there something similiar in 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-05-22T14:54:49+00:00Added an answer on May 22, 2026 at 2:54 pm

    foo(unpack(arguments)) is equivalent to foo(arguments[1], arguments[2], ...).

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

Sidebar

Related Questions

In my Lua script I'm trying to create a function with a variable number
Lua has a really nice no-parenthesis call syntax that coupled with function closures allow
Does Lua support something like C's __LINE__ macro, which returns the number of the
Call main.lua script at each game loop iteration - is it good or bad
I have the following lua script : module(modoo,package.seeall) foo=1 bar={12,34} Which works fine using
In a C app when I call a Lua script, do the variables in
In a C function called from my Lua script, I'm using luaL_ref to store
I have a lua script which is run using the command line interpreter, the
I'm writing a lua script, and one of the things it does is copy
Just tried to execute a small Lua script, but unfortunately I'm doing something wrong.

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.