Skip to content

Redirecting stdout #128

@Frityet

Description

@Frityet

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

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