I need help with this:
[code]Make a list with files from folder and a button to run a command with selected file[/code]
Thx very much.
Um. This is a request. Newbie questions forum is for asking for help with something you've already coded. Why don't you take a look at [url]http://wiki.garrysmod.com/?title=Guide_to_Derma[/url] and come back if you need help. And actually attempt to make it. Otherwise, please post in the Requests section.
[QUOTE=Skapocalypse;17044913]Um. This is a request. Newbie questions forum is for asking for help with something you've already coded. Why don't you take a look at [url]http://wiki.garrysmod.com/?title=Guide_to_Derma[/url] and come back if you need help. And actually attempt to make it. Otherwise, please post in the Requests section.[/QUOTE]
I already had seen that...
I know how to do the button, but the files list :S
Im making a Vgui for PAC ([url]http://www.facepunch.com/forumdisplay.php?f=337[/url])
[lua]require("datastream") --Shamefull CapsAdmin
function MyPanel(player)
local DermaPanel = vgui.Create( "DFrame" ) -- Creates the frame itself
DermaPanel:SetPos( 0,0 ) -- Position on the players screen
DermaPanel:SetSize( ScrW(), ScrH() ) -- Size of the frame
DermaPanel:SetTitle( "Ropero" ) -- Title of the frame
DermaPanel:SetVisible( true )
DermaPanel:SetDraggable( true ) -- Draggable by mouse?
DermaPanel:ShowCloseButton( true ) -- Show the close button?
DermaPanel:MakePopup() -- Show the frame
local TestingPanel = vgui.Create( "DPanel", DermaPanel )
TestingPanel:SetPos( 25, 50 )
TestingPanel:SetSize( ScrW() - 50, ScrH() - 100 )
TestingPanel.Paint = function() -- Paint function
surface.SetDrawColor( 50, 50, 50, 255 ) -- Set our rect color below us; we do this so you can see items added to this panel
surface.DrawRect( 0, 0, TestingPanel:GetWide(), TestingPanel:GetTall() ) -- Draw the rect
end
local DermaButton = vgui.Create( "DButton", TestingPanel )
DermaButton:SetText( "Refresh" )
DermaButton:SetPos( 20, ScrH() - 180 )
DermaButton:SetSize( ScrW() - 90, 25 )
DermaButton.DoClick = function ()
RunConsoleCommand( "pac_refresh" )
end
local DermaButton2 = vgui.Create( "DButton", TestingPanel )
DermaButton2:SetText( "Remove everything wear" )
DermaButton2:SetPos( 20, ScrH() - 140 )
DermaButton2:SetSize( ScrW() - 90, 25 )
DermaButton2.DoClick = function ()
RunConsoleCommand( "pac_removeparts" )
RunConsoleCommand( "pac_removepartsclient" )
end
end
concommand.Add("mymenu",MyPanel)[/lua]
Alright. now, what folder are you trying to make a list from? And what are you going to be listing?
Folder:
[code]data/PAC[/code]
Files:
[code]*.txt[/code]
Thx you very much ^^
Can some one tell me how to list a folder?
[code]
local list = file.Find("somefolder/*.txt")
for _, v in pairs(list) do
Print( v )
end
[/code]
Will print all the .txt files in the folder you specify.
[QUOTE=Skapocalypse;17063853][code]
local list = file.Find("somefolder/*.txt")
for _, v in pairs(list) do
Print( v )
end
[/code]
Will print all the .txt files in the folder you specify.[/QUOTE]
Lua is case sensitive, remember :P
[code]
local list = file.Find("somefolder/*.txt")
for _, v in pairs(list) do
print( v )
end[/code]
Sorry, you need to Log In to post a reply to this thread.