mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-10-04 18:41:51 +00:00
ResPaths.findRaw
This commit is contained in:
parent
bedcc438f4
commit
0e69db13be
4 changed files with 29 additions and 26 deletions
|
|
@ -19,25 +19,10 @@ static fs::path resolve_path(lua_State* L, const std::string& path) {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: move to ResPaths
|
||||
static int l_file_find(lua_State* L) {
|
||||
std::string path = lua_tostring(L, 1);
|
||||
|
||||
auto& packs = scripting::engine->getContentPacks();
|
||||
for (int i = packs.size()-1; i >= 0; i--) {
|
||||
auto& pack = packs[i];
|
||||
if (fs::exists(pack.folder / fs::path(path))) {
|
||||
lua_pushstring(L, (pack.id+":"+path).c_str());
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
auto resDir = scripting::engine->getResPaths()->getMainRoot();
|
||||
if (fs::exists(resDir / fs::path(path))) {
|
||||
lua_pushstring(L, ("core:"+path).c_str());
|
||||
return 1;
|
||||
}
|
||||
luaL_error(L, "file not found %q", path.c_str());
|
||||
return 0;
|
||||
lua_pushstring(L, scripting::engine->getResPaths()->findRaw(path).c_str());
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_file_resolve(lua_State* L) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue