Get CS2D Path
4 replies



28.09.16 03:02:29 am
Hello, i need the cs2d path, for function io.enumdir
is this code working? it is for me, but just want know if working others.
Also, is other way to get this?
is this code working? it is for me, but just want know if working others.
Also, is other way to get this?
Code:
1
2
3
4
5
6
7
2
3
4
5
6
7
for path in string.gmatch(package.path, "[^;]+") do
local to = string.find(path, "[\\|/]lua[\\|/]%?%.lua$")
if to then
cs2dpath = string.sub(path, 1, to - 1)
break
end
end
local to = string.find(path, "[\\|/]lua[\\|/]%?%.lua$")
if to then
cs2dpath = string.sub(path, 1, to - 1)
break
end
end
ah no, it searchs (cs2d folder)/lua/?.lua in package.path
just save the start of /lua/?.lua, and save from start to it.
@
xNir: i need cs2d folder, not the current script path.
just save the start of /lua/?.lua, and save from start to it.
@

Code:
1
2
3
2
3
luapath = string.match(package.path, ";[^;]+;([^%?]+)")
luapath = string.gsub(luapath, "\\", "/") -- Remove this if not necessary
cs2dpath = string.gsub(luapath, "lua/", "")
luapath = string.gsub(luapath, "\\", "/") -- Remove this if not necessary
cs2dpath = string.gsub(luapath, "lua/", "")



