Generally when you get nil value errors its because something doesn't exist.
Hey guys, so im working on a web browser script just to practice with lua and ive run into a problem.
I tried to make a back button but when i click on the button it gives me this error -
[ERROR] lua/webbrowser.lua:60: attempt to call method 'HTMLBack' (a nil value)
I looked at the gmod lua wiki and the method it showed for going to the previous page was Panel:HTMLBack(), yet it still give me this error
Here is my code for the main frame, html page, and the back button.
If anyone could help with this it would be much apprieciated.Code:local Web = vgui.Create( "DFrame" ) Web:SetPos( 50, 50 ) Web:SetSize( ScrW() - 90, ScrH() - 90 ) Web:SetTitle( "Web Browser" ) Web:SetVisible( true ) Web:SetDraggable( true ) Web:ShowCloseButton( true ) Web:MakePopup() HTMLTest = vgui.Create( "HTML", Web ) HTMLTest:SetPos( 25, 50 ) HTMLTest:SetSize(ScrW() - 125, ScrH() - 150 ) HTMLTest:OpenURL( HomePage ) BackButton = vgui.Create( "DButton", Web ) BackButton:SetSize( 50, 24 ) BackButton:SetPos( 24, 24 ) BackButton:SetText( "Back" ) BackButton.OnMousePressed = function() HTMLTest:HTMLBack() end
Generally when you get nil value errors its because something doesn't exist.
Last edited by Wasps; 06-29-2013 at 10:28 AM.
No, i made HTMLTest a vgui and then used that for the HTMLBack. Should'nt it work just like HTMLTest:SetPos and the other ones?
Obviously not.
To be honest I don't know exactly why it's not working, I have never bothered making a web browser within gmod apart from a generic webpage that redirects.
But that error basically says that HTMLBack() doesn't exist.
And it doesn't help that you are using the maurits wiki to learn outdated forms of web stuff for gmod.
Last edited by Wasps; 06-29-2013 at 10:49 AM.
well its one of the methods listed here:
maurits [DOT] tv/data/garrysmod/wiki/wiki.garrysmod [DOT] com/index01b1 [DOT] html
the only reason i can think its not working, is that the method was changed in gmod13 like some other things and the wiki hasnt updated it yet.
Maurits will never be updated, it's a cache of the old wiki.
And you are out of luck if that's the case, the new wiki doesn't even mention HTMLBack()
To be honest if you want to learn Lua i'd suggest sticking to simpler things.
Could always store the webpages you have visited in a table. ;P
yea thats what im going to do, i just need to do some more reading on tables they are a bit confusing to me atm
Just store the web pages in a table, when the back button is clicked, go to the last item in the table?