Jump to content

how to change where the lua is located?


twt_thunder

Recommended Posts

package.path and package.cpath

local mod_path = string.gsub( et.trap_Cvar_Get("fs_basepath"),"\\","/") .. "/" .. et.trap_Cvar_Get("fs_game") .. "/"
package.path = package.path .. ";" .. mod_path .. "luascripts/?.lua"

That is what it looks like in lua. I think this is what you want. (Changing it in in the c api, may be different though im not sure)

Link to comment
Share on other sites

package.path and package.cpath

local mod_path = string.gsub( et.trap_Cvar_Get("fs_basepath"),"\\","/") .. "/" .. et.trap_Cvar_Get("fs_game") .. "/"
package.path = package.path .. ";" .. mod_path .. "luascripts/?.lua"

That is what it looks like in lua. I think this is what you want. (Changing it in in the c api, may be different though im not sure)

probably but I belive there is more to it, so I will wait for a coder to answear me .. I am no coder so I need to know both wich file to change and what to change

Link to comment
Share on other sites

I did this in g_lua.c:

// set LUA_PATH and LUA_CPATH
	trap_Cvar_VariableStringBuffer( "fs_basepath", basepath, sizeof( basepath ) );
	trap_Cvar_VariableStringBuffer( "fs_homepath", homepath, sizeof( homepath ) );
	trap_Cvar_VariableStringBuffer( "fs_game", gamepath, sizeof( gamepath ) );

	luaPath = va( "%s%s%s%s?.lua;%s%s%s%slualibs%s/luascripts/?.lua",
		homepath, LUA_DIRSEP, gamepath, LUA_DIRSEP,
		homepath, LUA_DIRSEP, gamepath, LUA_DIRSEP, LUA_DIRSEP );

	luaCPath = va( "%s%s%s%slualibs%s?.%s",
		homepath, LUA_DIRSEP, gamepath, LUA_DIRSEP, LUA_DIRSEP, EXTENSION );

	// add fs_basepath if different from fs_homepath
	if( Q_stricmp( basepath, homepath ) ) {
		luaPath = va( "%s%s%s%s?.lua;%s%s%s%slualibs%s/luascripts/?.lua;%s",
			basepath, LUA_DIRSEP, gamepath, LUA_DIRSEP,
			basepath, LUA_DIRSEP, gamepath, LUA_DIRSEP, LUA_DIRSEP, luaPath );

		luaCPath = va( "%s%s%s%slualibs%s?.%s;%s",
			basepath, LUA_DIRSEP, gamepath, LUA_DIRSEP, LUA_DIRSEP, EXTENSION,
			luaCPath );
	}

but it still doesnt find the scripts

 

just say:

lua_api:no scripts loaded

 

argh, driving me nuts!!

Link to comment
Share on other sites

unsafe to start, and with mods like lesm and upcoming ones this could be a huge problem, just for the simple fact its loading everysingle lua file over and over and we don't want this :)

why is it unsafe to start?

 

To be fair, he was asking about the C API part which I don't know about :D

 

But yes, if it loads all lua files recursively that would be bad for projects like myn.

I didnt think this far, but I am not sure your project is needed on this mod yet :)

 

just because he doesn't have the coder tag doesn't mean he can't code :D

 

I am absolutely no coder, but even I start to find my way around on smaller things, first code I did as actually worked was to change path on the binocs so it loads the new one...lol

Link to comment
Share on other sites

why is it unsafe to start?

 

I didnt think this far, but I am not sure your project is needed on this mod yet :)

We just mean, if the core lua that has the et_CallBacks in it requires a extra lua module.

Example:

etdir/silent/luascripts/main.lua <-- File that has et callbacks etc. that we want loaded, it also had a line like require "util.json" or something similar.

etdir/silent/luascripts/util/json.lua <--- File that we wouldn't want to be loaded to ET

 

Obviously we wouldn't want et to load json.lua, as there would be no et callbacks in it and it would be loaded via main.lua already.

 

In other words it doesn't apply only to my project. Usually it is just one file but not always.

Edited by Zelly
Link to comment
Share on other sites

We just mean, if the core lua that has the et_CallBacks in it requires a extra lua module.

Example:

etdir/silent/luascripts/main.lua <-- File that has et callbacks etc. that we want loaded, it also had a line like require "util.json" or something similar.

etdir/silent/luascripts/util/json.lua <--- File that we wouldn't want to be loaded to ET

 

Obviously we wouldn't want et to load json.lua, as there would be no et callbacks in it and it would be loaded via main.lua already.

 

In other words it doesn't apply only to my project. Usually it is just one file but not always.

Aaah, ok that makes sense....well back to development then..

It was just a thought to make things easier for admins, but I do quite get it.

Thanx for a good explanation

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...