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

Redirecting stdout #128

Open
Frityet opened this issue Oct 23, 2024 · 0 comments
Open

Redirecting stdout #128

Frityet opened this issue Oct 23, 2024 · 0 comments

Comments

@Frityet
Copy link
Contributor

Frityet commented Oct 23, 2024

I am trying to redirect stdout to a <pre>, so I did

    const handleExecute = async () => {
        setOutput('')
        try {
            const lua = await getLuaState()
            const _G = lua.getGlobalTable()
            // const io = _G.get('io') as LuaTable
            _G.set('print', (args: any) => {
                console.log({ args })
                setOutput((prev) => prev + args + '\n')
                console.log("print(): " + args)
            })
            await lua.run(code);
        } catch (error: any) {
            setOutput("Error: " + error.message)
        }
    }

however args seems to be undefined for any input

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