• Having a problem with derma sliders.
    2 replies, posted
I'm trying to make a simple lives counter addon and I've run into a little problem with the OnValueChanged function. Whenever I try to override the function, I get an error that says: [ERROR] lua/myscript.lua:41: function arguments expected near '=' 1. unknown - lua/myscript.lua:0 On the wiki, the function only has one argument so I doubt the amount of arguments is the problem. There is a lack of any examples or further documentation about this which is pretty frustrating. Anyone have an ideas what I'm doing wrong? [CODE]local NumSlider = vgui.Create("DNumSlider", Frame) NumSlider:SetPos( 100,23 ) NumSlider:SetWide( 200 ) NumSlider:SetMax( 1000 ) NumSlider:SetMin( 0 ) NumSlider:SetDecimals(0) NumSlider:OnValueChanged = function( number ) net.Start("TicketAmount") net.WriteInt( number, 16 ) net.SendToServer() end[/CODE]
[QUOTE=Moat;51523609]Your "NumSlider:OnValueChanged = function( number )" should be [lua] NumSlider.OnValueChanged = function( self, number ) -- or function NumSlider:OnValueChanged( number ) [/lua][/QUOTE] Thank you so much for your quick reply! The second one worked but the first one didn't for some reason. I'll just use this one for now.
Sorry, you need to Log In to post a reply to this thread.