Skip to content

sol::property and sol::readonly_property providing function instead of getter? #1735

Open

Description

@gradylink

so I have this code:

extension.luaState["input"].get<sol::table>().set("mouseX", sol::property([]() { return Input::mousePointer.x; }));

when I try to log input.mouseX on the Lua side, I get:

function: 0x7bfc5bc65fe0

but if I log input.mouseX() then I get the correct integer output (Input::mousePointer.x is an int.) I don't think I'm doing anything wrong here, if I am, please point it out. I'd also like to note that I'm using Lua 5.1.

Activity

  1. C3pa commented on Nov 16, 2025

    @C3pa
    Contributor

    Maybe bind your "input" as a usertype instead of a table? Then you can use sol::property to bind a getter and a setter function, which will allow you to access it as a property instead of a function call. Example here.

  2. gradylink commented on Nov 29, 2025

    @gradylink
    Author

    Still getting the issue with this syntax:

            extension.luaState["input"]["mouseX"] = sol::readonly_property([]() { return Input::mousePointer.x; });
  3. changed the title [-]`sol::property` providing function instead of getter?[/-] [+]`sol::property` and `sol::readonly_property` providing function instead of getter?[/+] on Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions