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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:02:50+00:00 2026-06-03T06:02:50+00:00

I am actually trying to create a class in C++ to encapsulate calls of

  • 0

I am actually trying to create a class in C++ to encapsulate calls of Lua, actually trying to encapsulate a function to load a Lua script on the constructor, but the main problem is when I try to make a function call of the Lua script I can’t find how to store the multiple returns value and how to correctly push all the arguments.

I’m trying to find an idea of the implementaion of a function who call a lua fonction with any number of any type of parameter, (the function will push arguments and call the function, but i dont want dynamic cast for example to know if i have to “lua_pushnumber” or push string for example.

  • 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-03T06:02:51+00:00Added an answer on June 3, 2026 at 6:02 am

    You could try to accept an array of some type of variant class in your constructor, and use their type to determine how to pump them into Lua. On the other hand, there is really only two types that are interchangeable between C/C++ and Lua: string and number/double. A possible solution is to give pass in an array of strings (or a char** and an int, if you prefer), passing in your doubles as strings as well.

    You could then do your loadstring() call by appending a string representation of your string or double after the string “return “. When you execute the function pushed to the stack by loadstring(), the lua engine will push your variable (string or double with appropriate type) to the lua stack. You would have the overhead of string-parsing your doubles, but if you were dying for speed I bet you would be coding purely in C++ anyways 🙂 The advantage of this method is that you could actually pass in a function this way too: (i.e. “return function() print(“hello”); end”)

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

Sidebar

Related Questions

I'm trying to create a class with a constructor: class MyClass { public int
I am trying to create a UIImage from a byte array that is actually
I'm in psql trying to create a table for a python admin. It's actually
I'm trying to prevent A HREF from actually opening the link, but to execute
I am in the middle of (trying) to create a Class Library available for
I'm trying to create a sub-class of the JButton component that will enable or
Trying to create my own custom AttachedProperty for a WPF DependencyObject failed to actually
In a Scala Compiler Plugin, I'm trying to create a new class that implement
I'm trying to create a notification when an alarm fires. No problem so far.
I'm actually trying to create a login form matching with my database. The form

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.