Function AddDir(dir) Problems

So right now I am trying to make the clients on my server download custom songs to route through PCMOD2. I already have the PCmod2 side of the matter all working.

What I am having trouble with is getting my AddDir function to work so that the client downloads these custom songs.

My current function is as follows

[lua]

  1. function AddDir(dir) // recursively adds everything in a directory to be downloaded by client
    2. local list = file.FindDir("…/"…dir…"/")
    3. for _, fdir in pairs(list) do
    4. if fdir != “.svn” then // don’t spam people with useless .svn folders
    5. AddDir(fdir)
    6. end
    7. end
    8.
    9. for k,v in pairs(file.Find("…/"…dir…"/
    ")) do
  2.     <span class="highlight">resource</span>.AddFile(dir.."/"..v)  
    
  3. end  
    
  4. end
  5. AddDir(“sound/music”)
    [/lua]

So as you can see I am trying to make the client download everything within the “sound/music” directory, the music being a custom added folder within my server.

I currently have this script listed under “resources.lua” in my “lua/autorun/server” directory.

Anyone know how to get this working?

Maybe skip copy 'n pasting from lua tags without knowing how to do it propperly?
You got the liner numbers in there :tinfoil:

[editline]07:51PM[/editline]

And you also did some fail with highlighting. Remember to press View Plain and copy from there

Actually no, I don’t post a lot on facepunch as you can see by my post count so when I tried to do the [lua] quotes they failed when I previewed my post so really quickly found another thread replied it to get the [lua][/lua] code and put it in, I guess when I previewed it again I didn’t realize it wasn’t quite lined up, and apparently I didn’t realize my numbers pasted over.

Here it is in my Notepad++ http://tinypic.com/view.php?pic=mr1o2&s=5 , Happy?

Anyone else willing to help? Code pasted in pic above/below still not working…



function AddDir(dir) // recursively adds everything in a directory to be downloaded by client
	local list = file.FindDir("../"..dir.."/*")
	for _, fdir in pairs(list) do
		if fdir != ".svn" then // don't spam people with useless .svn folders
			AddDir(fdir)
		end
	end
 
	for k,v in pairs(file.Find("../"..dir.."/*")) do
		<span class="highlight">resource</span>.AddFile(dir.."/"..v)
	end
end
 
AddDir("sound/music")


(That picture ended up bigger than I anticipated)

You still got a little highlight fail here though: <span class=“highlight”>resource</span>.AddFile(dir…"/"…v)

Oh, what’s wrong with it exactly?

How about something like…


<span class="highlight">AddDir</span>(dir)

?

But don’t I need .addfile in there?

That isn’t part of the Lua syntax, that is the result of you (or someone who gave you the code) searching on facepunch and its fail attempt to highlight the words you searched. Just remove the html code (<span class=“highlight”> and </span>) from the code and it should be ok.

Alright, it’s working now, thank you very much.