Forum

> > CS2D > Servers > fast way to servertransfer.lst
Forums overviewCS2D overview Servers overviewLog in to reply

English fast way to servertransfer.lst

1 reply
To the start Previous 1 Next To the start

old fast way to servertransfer.lst

MaksDragon OP
User Off Offline

Quote
For example, i add maps to my server and manual add gfx/sfx to servertransfer.lst. but sometimes its take little bit TIME.
Maybe i can add it fast? maybe some script or anything?

old Re: fast way to servertransfer.lst

reverend_insanity
User Off Offline

Quote
Hmm, I have this. I used it to add a whole directory of gfx images or sfx sounds to my servertransfer.lst:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
sourcefolder = "C:\\Program Files (x86)\\Steam\\steamapps\\common\\CS2D\\"
exportfolder = "gfx\\!infinity!"

_, lazy = string.find(sourcefolder..exportfolder, "CS2D")

function lua_mainexport()
	file = io.open("sys/lua/servertransfer_ex.lst", "w+") or io.tmpfile()

	local text = string.gsub(lua_subexport(sourcefolder..exportfolder), "\\", "/")
	file:write(text)
	file:close()
	print("DONE")
end

function lua_subexport(heavyname)
	local name = ""
	for file in io.popen('dir "'..heavyname..'\\" /b /o:e'):lines() do
		local lightname = string.sub(heavyname, lazy+2)
		if lua_typeexport(file) == "none" then
			print("IGNORED FILE: "..file.." (UNSUPPORTED EXTENSION)")
        elseif lua_typeexport(file) == "file" then	
			print("FILE: "..lightname.."\\"..file)
			name = name..lightname.."\\"..file.."\n"
        elseif lua_typeexport(file) == "dir" then
			local folder = heavyname.."\\"..file
			print("DIRECTORY: "..lightname.."\\"..file)
			name = name..lua_subexport(folder)
		end
	end
	return name
end

supported_extensions = {"wav", "ogg", "png", "map", "lst", "bmp", "jpg"}

function lua_typeexport(file)
	for k, x in pairs(supported_extensions) do
		if string.find(file, "."..x) then 
			return "file"
		end
	end
	
	if file:match("%.") then
		return "none"
	end
	return "dir"
end
lua_mainexport()

Moreover, I found this: You can iterate through image and sfx entities
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function getKeysAsString(dict)
    local keys = {}
    for key, _ in pairs(dict) do
        table.insert(keys, key)
    end
    return table.concat(keys, '\n')
end

function automaptransfer(copy)
	local files = {}

	files["maps/"..map("name")..".map"] = true
	files["gfx/tiles/"..map("tileset")] = true
	for _,e in pairs(entitylist()) do
		if (entity(e.x,e.y,"type") == 22 or entity(e.x,e.y,"type") == 23) then -- Env_Sprite and Env_Sound
			files[entity(e.x,e.y,"str0")] = true
		end
	end

	local FileABC = io.open("sys/lua/servertransfer_2.lst","w+")
	if FileABC then
		FileABC:write(getKeysAsString(files))
		FileABC:close()
	end

	print("Servertransfer completed")
end

automaptransfer(false)

Hopefully this'll help.
Sorry, this is a really old code of mine. I really can't focus enough to edit it for your exact case right now nor do I have time to make them more efficient.
To the start Previous 1 Next To the start
Log in to reply Servers overviewCS2D overviewForums overview