Help with script

Posts 112 of 12 · Page 1 of 1
Help with script
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.

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
If anyone could help with this it would be much apprieciated.
Generally when you get nil value errors its because something doesn't exist.
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.
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
Quote Originally Posted by MeepDarknessMeep View Post
Could always store the webpages you have visited in a table. ;P
That would make sense, but the method to get URLs I think is broken too, and the new wiki is shit. It doesn't list the methods you can use.

Edit: To clarify, is doesn't list the Panel.Html methods (That I can find)
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?
Quote Originally Posted by tyguy550 View Post
Just store the web pages in a table, when the back button is clicked, go to the last item in the table?
And please, tell me how to get the current URL. The method listed in the old wiki does not work (That I can manage) and the new wiki doesn't list the methods
Quote Originally Posted by LordOfGears2 View Post
And please, tell me how to get the current URL. The method listed in the old wiki does not work (That I can manage) and the new wiki doesn't list the methods
I made a variable called CurrentPage and whenever you enter a url and click go or hit enter, it gets the value of the text box and stores it into CurrentPage, it also sets the CurrentPage whenever you click the home button to return your homepage.
Posts 112 of 12 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Need help?