Stream functions library for Lua (14)
Not sure if it can do what i need.
Basically i want all maps in the "maps/" folder to be in an infinite menu. Can someone help me? (I have the infinite menu already)
function get_map_table(d) local t = {} -- Detect OS if ( os.execute("uname -o") == "GNU/Linux" ) then -- We're on a GNU/Linux machine, will list only maps local s = os.execute("ls -aX maps/ | grep *.map") for w in string.gmatch(s, "[^\n]+") do t[#t+1] = w end return t else -- Assume Windows, will list all files even if they aren't maps (you could filter it out by removing any strings that don't end with '.map') local s = os.execute("dir /B maps/") for w in string.gmatch(s, "[^\n]+") do t[#t+1] = w end return t end end
parse("maps")
function ScanMap(ext) 	local temp={} 	local lpstr=io.popen("dir /b maps\\") 	for w in lpstr:read("*a"):gmatch("[^\n]+") do 		if w:sub(-4)==".map" then 			table.insert(temp,ext==true and w:sub(1,-5) or w) 		end 	end 	lpstr:close() 	return temp end
maplist = {} function grabmaps(txt) 	if (txt ~= "----- Maps -----") then 		maplist[#maplist+1] = txt 	end end function showMaps() 	addhook("log","grabmaps") 	parse("maps") 	freehook("log","grabmaps") end
os.execute('dir "maps" > tmp') maps2={} for file in io.lines("tmp") do if file:sub(-4) == ".map" then table.insert(maps2,string.sub(file,38,-5)) end end os.execute('del tmp') --windows addhook("say","_say") function _say(id,txt) 	if txt == "!lol" then 		for _,map in ipairs(maps2) do 			msg(map) --showing that it works 		end 	end end function selectmenu(id, page) 	local page = page or 1 	local pages = math.ceil(#maps2 / 6) 	if page < 1 then page = pages end 	if page > pages then page = 1 end 	local m = 'Start a vote for a new map P'.. page 	for i = 6 * page - 5, 6 * page do 		if maps2[i] then m = m ..', '.. maps2[i] else m = m ..',' end 	end 	if page == pages then m = m ..',,<<- First page' else m = m ..',,Next page -->' end 	if page == 1 then m = m ..',Last page ->>' else m = m ..',<-- Previvius page' end 	menu(id, m) end