twt_thunder Posted February 15, 2015 Share Posted February 15, 2015 Hey I am working on my mod modernfront, based on ETpub 1.0.0And I wondered how to make the lua api look for a folder inside the modfolder called luascripts as in ETnam mod??What do I change to make it work? Quote Link to comment Share on other sites More sharing options...
Zelly Posted February 15, 2015 Share Posted February 15, 2015 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) twt_thunder 1 Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 15, 2015 Author Share Posted February 15, 2015 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 Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 18, 2015 Author Share Posted February 18, 2015 ok, I see I wont get more help here.. Thx for your help @zelly Quote Link to comment Share on other sites More sharing options...
Management gaoesa Posted February 18, 2015 Management Share Posted February 18, 2015 In ETPub based Lua modules, the scripts are read in the qboolean G_LuaInit() function at g_lua.c. I think that is the place to make the modifications. I would suggest adding a cvar for the directory, similar to g_mapConfigs and g_mapScriptDirectory cvars. twt_thunder 1 Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 18, 2015 Author Share Posted February 18, 2015 thx @gaoesa , no I actually want to lock it to that directory.. would be much easier for server admins Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 18, 2015 Author Share Posted February 18, 2015 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!! Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 18, 2015 Author Share Posted February 18, 2015 ok, it still loads it from modfolder.. so it must be something else Quote Link to comment Share on other sites More sharing options...
Dragonji Posted February 18, 2015 Share Posted February 18, 2015 (edited) Just have a look at how it's done in g_mapConfigs and g_mapScriptDirectory cases Edited February 18, 2015 by Dragonji Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 18, 2015 Author Share Posted February 18, 2015 problem solved by Jenkins, now it even autoloads lua from luascripts folder cant be easier than thatjust need to find out the limit of luas Quote Link to comment Share on other sites More sharing options...
Dragonji Posted February 18, 2015 Share Posted February 18, 2015 Does it load everything what's placed there? I don't think it's wanted behaviour. Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 19, 2015 Author Share Posted February 19, 2015 Does it load everything what's placed there? I don't think it's wanted behaviour.why not, its very easy for an serveradmin then?! Quote Link to comment Share on other sites More sharing options...
Dragonji Posted February 19, 2015 Share Posted February 19, 2015 I personally would like to have control over loaded Luas so I can only load mods I really want, not all mods from the specific directory. It works this way in every single ET modification. Quote Link to comment Share on other sites More sharing options...
ETsneak Posted February 19, 2015 Share Posted February 19, 2015 Either way, would be nice to have a lua folder to have the lua modules all in a folder instead of loose in the mod directory twt_thunder 1 Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 20, 2015 Author Share Posted February 20, 2015 I personally would like to have control over loaded Luas so I can only load mods I really want, not all mods from the specific directory. It works this way in every single ET modification.I know, but why have lua mods in that folder if you not gonna use them^^ Quote Link to comment Share on other sites More sharing options...
Dragonji Posted February 20, 2015 Share Posted February 20, 2015 Hmm, testing purposes? Quote Link to comment Share on other sites More sharing options...
Purple Posted February 20, 2015 Share Posted February 20, 2015 Hmm, testing purposes?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 Quote Link to comment Share on other sites More sharing options...
Purple Posted February 20, 2015 Share Posted February 20, 2015 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 changejust because he doesn't have the coder tag doesn't mean he can't code Quote Link to comment Share on other sites More sharing options...
Zelly Posted February 21, 2015 Share Posted February 21, 2015 To be fair, he was asking about the C API part which I don't know about But yes, if it loads all lua files recursively that would be bad for projects like myn. Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 21, 2015 Author Share Posted February 21, 2015 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 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 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 Quote Link to comment Share on other sites More sharing options...
Zelly Posted February 21, 2015 Share Posted February 21, 2015 (edited) 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 February 21, 2015 by Zelly twt_thunder 1 Quote Link to comment Share on other sites More sharing options...
twt_thunder Posted February 21, 2015 Author Share Posted February 21, 2015 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.