Skip to content

Is it possible to preload modules written in Lua passed as strings? #119

Closed
@fiatjaf

Description

@fiatjaf

Something like

L := lua.NewState()
defer L.Close()
L.PreloadString("mymodule", `
local mymodule = {}

function mymodule.foo()
    print("Hello World!")
end

return mymodule
`)
L.DoString(`
local mymodule = require "mymodule"
mymodule.foo()
`)

I imagine it should be possible, but can't find the correct documentation for it.

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