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

Is this an issue with moonnuklear or my lua code? #13

Open
awsdert opened this issue Mar 22, 2021 · 1 comment
Open

Is this an issue with moonnuklear or my lua code? #13

awsdert opened this issue Mar 22, 2021 · 1 comment

Comments

@awsdert
Copy link

awsdert commented Mar 22, 2021

The error (with paths stripped)

?/gasp/src/../OTG/lua/init.lua:27: ?/gasp/src/../OTG/lib/moonnuklear.so: undefined symbol: lua_newuserdatastack traceback:

My lua code

function Require(name,report_lib_error)
	if not name then
		trace()
		return nil
	end
	local path = os.getenv("GASP_PATH") .. "/lib/" .. name .. ".so"
	local func, err = loadlib(path,'luaopen_' .. name)
	if not func then
		if report_lib_error then
			dump_lua_stack()
			error(err .. debug.traceback())
			return nil
		end
		path = os.getenv("GASP_PATH") .. "/lua/" .. name
		func, err = loadfile(path)
		if not func then
			dump_lua_stack()
			error(err .. debug.traceback())
			return nil
		end
	end
	return func, pcall( func )
end
@awsdert
Copy link
Author

awsdert commented Mar 22, 2021

Never mind it was an issue with my code, for anyone who saw this and was curious about how I fixed it here's the code:

function _RequireLib(dir,name,report_attempts,error_on_failure)
	local paths, p, v, ret, err = { name, name .. ".so" }
	for p, v in pairs(paths) do
		if not ret then
			local path = dir .. "/" .. v
			ret, err = loadlib(path,'luaopen_' .. name)
			if report_attempts then
				print("Trying " .. path)
			end
		end
	end
	if error_on_failure and not ret then
		dump_lua_stack()
		error( err .. _trace() )
	end
	return ret, err
end

function _RequireLua( name, report_attempts )
	local dir = os.getenv("GASP_PATH")
	local paths, p, v, ret, err =
	{
		name
		, name .. ".lua"
		, "lua/" .. name
		, "lua/" .. name .. ".lua"
	}
	for p, v in pairs(paths) do
		if not ret then
			local path = dir .. "/" .. v
			ret, err = loadfile(path)
			if report_attempts then
				print("Trying " .. path)
			end
		end
	end
	if not ret then
		dump_lua_stack()
		error( (err or "nil\n") .. _trace() )
	end
	return pcall( ret ), err, ret
end

function Require(name,report_attempts,onlylibs)
	if not name then
		trace()
		return nil
	end
	local ret, err = _RequireLib
	(
		os.getenv("GASP_PATH") .. "/lib", name, report_attempts, onlylibs
	)
	if not ret then 
		return _RequireLua( name, report_attempts )
	end
	return ret, err
end

I'll leave the issue open since the title can fit more than just my own post, peops can just post their own here if they don't which is
the source like I didn't

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