lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



As a sidenote (this applies to the '-l' loaded libraries, not 'require'd):

	-- Finding subscripts:
	--
local LUA_PATH= rawget(_G,"package") and package.path or os.getenv("LUA_PATH")
	assert( LUA_PATH, "Unable to get LUA_PATH!" )

	local MY_PATH
	for pat in string.gfind( LUA_PATH, "[^;]+" ) do
	    local try= string.gsub( pat, "?", "hamster" )
    	local fh= io.open(try,"r")
if fh then fh:close(); MY_PATH= string.gsub(try,"hamster%.lua",""); break end
	end
	assert(MY_PATH)

	local hamsterlibs= assert( dofile( MY_PATH.."hamster_libs.lua" ) )

I think it's rather rediculous for all this code to be needed (in _every_ Lua script that needs something from "where it came from") but currently, there does not seem to be a better way?

For me, this code is more or less duplicated in:

	hamster_core.lua
	hamster_gcc.lua
	hamster_evc.lua
	hamster_msc.lua
	hamster_custom.lua
	hamster.lua

..so you see the point? :)


3.2.2005 kello 00:07, David Burgess kirjoitti:

 No, they define the actual search path.
I changed my loadlib.c to save the library handles in the package
table.  You could do the same and maintain a list of where you
loaded things from. Beware that this all may change in work5.

I would prefer to have everything pretty much self-contained.

1) Add LUA_PATHSEP to luaconf.h
2) Push it into the package table in loadlib.c or lbaselib.c (i cant
remember which).

Recompile.

DB