English Get CS2D Path

4 replies
Goto Page
To the start Previous 1 Next To the start
28.09.16 03:02:29 am
Up
Waldin
User
Offline Off
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?
Code:
1
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
user Waldin (2014) has written:
can be create 3D option for tiles on 3D
user DC (2014) has written:
@user Waldin: This is a 2D game. there are no 3D tiles.
changelog (2017) has written:
ADDED Experimental 3D rendering mode
28.09.16 10:02:59 am
Up
xNir
User
Offline Off
Code:
1
scriptpath = string.match(string.sub(debug.getinfo(1).source, 2), "(.+/)")
28.09.16 02:40:25 pm
Up
VADemon
User
Offline Off
cs2dpath (cs2d folder?) doesn't end with .lua. What do you need?
28.09.16 03:24:18 pm
Up
Waldin
User
Offline Off
ah no, it searchs (cs2d folder)/lua/?.lua in package.path
just save the start of /lua/?.lua, and save from start to it.

@user xNir: i need cs2d folder, not the current script path.
user Waldin (2014) has written:
can be create 3D option for tiles on 3D
user DC (2014) has written:
@user Waldin: This is a 2D game. there are no 3D tiles.
changelog (2017) has written:
ADDED Experimental 3D rendering mode
28.09.16 11:19:08 pm
Up
xNir
User
Offline Off
Code:
1
2
3
luapath = string.match(package.path, ";[^;]+;([^%?]+)")
luapath = string.gsub(luapath, "\\", "/") -- Remove this if not necessary
cs2dpath = string.gsub(luapath, "lua/", "")
To the start Previous 1 Next To the start