• Question About Console Warnings: Attempt to call a ______ value
    38 replies, posted
So anybody got any ideas?
[QUOTE=Whitellama;22989520]So anybody got any ideas?[/QUOTE] Fixed! [lua]local function up(path) path = path .. "../" -- All of these functions should be deleted or commented out Msg( path ) end local function open(path) print(file.Read(tostring(path))) end local function cancel() DermaPanel:Remove() end function FileDialog( ply, com, args ) -- CHANGE: IN PARAMETERS local DermaPanel = vgui.Create( "DFrame" ) -- CHANGE: MADE LOCAL DermaPanel:SetSize( 600, 800 ) DermaPanel:SetTitle( "Open File" ) DermaPanel:SetVisible( true ) DermaPanel:SetDraggable( true ) DermaPanel:ShowCloseButton( false ) DermaPanel:MakePopup() path = "../*" local DermaListView = vgui.Create( "DListView", DermaPanel ) DermaListView:SetPos( 25, 100 ) DermaListView:SetSize( 550, 625 ) DermaListView:SetMultiSelect( false ) DermaListView:AddColumn( "Name" ) DermaListView.BuildListBox = function(self) -- You may need to make this local again. self:Clear() for k,v in pairs(file.Find(path)) do -- CHANGE: REMOVED TOSTRING self:AddLine(v) -- Make sure v works end end DermaListView:BuildListBox() -- CHANGE: RUNS BUILD LIST BOX local DermaTextPath = vgui.Create( "DTextEntry", DermaPanel) DermaTextPath:SetValue( "Enter a directory within the garrysmod\\garrysmod\\data folder" ) DermaTextPath:SetPos( 25, 25 ) DermaTextPath:SetWide( 510 ) DermaTextPath:SetTall( 20 ) DermaTextPath:SetEnterAllowed( true ) function DermaTextPath:OnEnter() -- May need to add BuildListBox here path = DermaTextPath:GetValue() DermaListView:BuildListBox() -- You may need to remove this end local DermaButtonOpen = vgui.Create( "DButton", DermaPanel) DermaButtonOpen:SetText( "Open" ) DermaButtonOpen:SetPos( 475, 750 ) DermaButtonOpen:SetSize( 100, 25 ) DermaButtonOpen.DoClick = function() -- CHANGE: WROTE FUNCTION HERE print( file.Read( path ) ) -- May need to use tostring end local DermaButtonCancel = vgui.Create( "DButton", DermaPanel) DermaButtonCancel:SetText( "Cancel" ) DermaButtonCancel:SetPos( 25, 750 ) DermaButtonCancel:SetSize( 100, 25 ) DermaButtonCancel.DoClick = function() -- CHANGE: WROTE FUNCTION HERE DermaPanel:Remove() end local DermaButtonUp = vgui.Create( "DSysButton", DermaPanel ) DermaButtonUp:SetPos( 535, 25 ) DermaButtonUp:SetSize( 20, 20 ) DermaButtonUp:SetType( "up" ) DermaButtonUp.DoClick = function() -- CHANGE: WROTE FUNCTION HERE path = path .. "../" end end concommand.Add( "FileDialog", FileDialog ) [/lua] in the command line put [QUOTE] ../data/* [/QUOTE]
I've ran into another little problem with this. So I've been tweaking the up button to get it to work (if you haven't already noticed it didn't) and I have a question about strings. So when the user presses the up button it adds ..\ to the path which goes up one directory. Since the * is automatically placed the path turns into something like this: llama\*..\ and since the * is there the ..\ doesn't work properly. Is there a way to search a string and remove a certain character or group of characters? I think there is I'm just sure what it would be called. Could someone tell me how to do this? Or just tell me the name of the function so I can look it up.
[b][url=http://wiki.garrysmod.com/?title=String.gsub]String.gsub [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] :pseudo:
[QUOTE=commander204;23077703][b][url=http://wiki.garrysmod.com/?title=String.gsub]String.gsub [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] :pseudo:[/QUOTE] Thanks, that's exactly what I needed.
np!
Okay well I've got another question about manipulating strings. The problem is that after I press the up button to go one folder up from the llama folder it would look something like this: "llama\..\" in the text box for the path. As you can see it's working without the * (thanks to commander) but I would like to know if there is a way to find a chunk of a string and remove everything after it. I looked in the string section on the GMod Wiki but nothing seemed really obvious. I was thinking there might be a way to do it involving splitting strings but I don't know how I would do this. Could someone give me a point in the right direction?
string.sub(text , 0 , string.find(text , "and dan was boobies"))
Thanks FlapJack.
Sorry, you need to Log In to post a reply to this thread.