Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug output console don't relay keypress #1181

Open
Peter-Oestergaard opened this issue May 4, 2024 · 0 comments
Open

Debug output console don't relay keypress #1181

Peter-Oestergaard opened this issue May 4, 2024 · 0 comments

Comments

@Peter-Oestergaard
Copy link

Wrapping getch() for use in Lua:

#include "lua.h"
#include "lauxlib.h"

static int lua_getch(lua_State *L)
{
    int ch = getch();
    lua_pushinteger(L, ch);
    return 1;
}

static const luaL_Reg functions[] = {
    {"getch", lua_getch},
    {NULL, NULL} /* sentinel */
};

int
__declspec(dllexport)
luaopen_adventureAux(lua_State *L)
{
    luaL_newlib(L, functions);
    return 1;
}

Function using the wrapper:

function INKEYS()
    return string.char(lib.getch())
end

When calling the INKEYS() function the expected behavior is for the application to wait for a key to be pressed. And when it happens it will return a string containing the character.

This works if I run the application in a regular terminal.

The problem:
When running in the ZeroBrane Studio debugger the Output window just shows a prompt that echoes whatever characters I press.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant