Hello, i've been struggling the whole day with derma. I tryed all what i could after searching for different functions and posts
I have 2 different issues over here.
* The slider value ( The one circled in green ) will not update when the slider is moving, or if i go by replacing the text it wont move the slider. Althought it does when closing and re opening because the idea is storing that value for a while
* The Red text wont update either, I tried using refresh function with [I]Frame[/I] and with [I]label[/I] variables ( took the local out first, of course ). But it wont change anything at all in the derma.
[IMG]https://k61.kn3.net/F/C/F/A/9/C/756.png[/IMG]
A bit more visual for if i'm being clear enought. The yelow represents the aproximate value on the slider, the red the min and max values. Then we got the circle which should have text updating.
[lua]
function ENT:Think()
if label:IsVisible() then
labelText = "ref"
label:Refresh(true)
end
end
function Derma()
labelText = "First Scan the vessel before displaying any data!"
local Frame = vgui.Create( "DFrame" )
Frame:SetPos( 5, 5 )
Frame:SetSize( ScrW()/2.5, ScrH()/2.5 )
Frame:SetTitle( "Name window" )
Frame:SetVisible( true )
Frame:SetDraggable( true )
Frame:Center()
Frame:SetPos( ScrW()/2 , ScrH()/2)
Frame:ShowCloseButton( true )
Frame:MakePopup()
local slider = vgui.Create("DNumSlider")
slider:SetParent(Frame)
slider:SetSize( ScrW()/5, 10)
slider:SetPos(50,330)
slider:SetMin(-100)
slider:SetMax(100)
slider:SetDecimals(0)
slider:SetValue(sliderValue)
slider:SetText("Scan elevation")
slider.ValueChanged = function(pSelf, fValue)
sliderValue = fValue
Frame:Refresh(true)
end
local button = vgui.Create( "DButton" )
button:SetParent(Frame)
button:SetPos( 450, 300 )
button:SetSize(ScrW()/10,ScrH()/20)
button:SetText("Scan!")
button.DoClick = function()
net.Start('ScanExecute')
net.WriteInt(sliderValue,8)
net.SendToServer()
end
label = vgui.Create("DLabel")
label:SetParent(Frame)
label:SetPos(50,50)
label:SetText(labelText)
label:SetSize(300,100)
label:SetTextColor(Color(255,50,50,255))
local checkbox = vgui.Create("DCheckBoxLabel")
checkbox:SetParent(Frame)
checkbox:SetPos(450,270)
checkbox:SetText("Enable Scan Visualization")
checkbox:SetValue( ticked )
checkbox:SizeToContents()
function checkbox:OnChange( val )
if val then
ticked = true
else
ticked = false
end
end
end[/lua]
Thanks for taking a time for reading this :)
What have you done so far to solve your issue? Ever consider [url]https://wiki.garrysmod.com/page/Net_Library_Usage[/url]
The easy way to do this is to do things like this is to save the things you want to update outside the function (but not globally!)
client-side
[code]
local my_updateable_element1, my_updateable_element2, ...
function make_my_gui()
my_updateable_element1 = vgui.Create("DLabel")
my_updateable_element2 = vgui.Create("DButton")
my_updateable_element2.DoClick = function(self)
net.Start("foo")
net.SendToServer()
end
:
:
end
make_my_gui()
net.receive("bar",function()
print("I received a message from the server!")
my_updateable_element1:SetText(net.ReadString())
end)
[/code]
server-side
[code]
util.AddNetworkString("foo")
util.AddNetworkString("bar")
net.Receive("foo",function(ln,ply)
print("I received a message from the client!")
net.Start("bar")
net.WriteString("Oh snap, this label updated!")
net.Send(ply)
end)
[/code]
[QUOTE=Apickx;51491050]The easy way to do this is to do things like this is to save the things you want to update outside the function (but not globally!)
client-side
[code]
local my_updateable_element1, my_updateable_element2, ...
function make_my_gui()
my_updateable_element1 = vgui.Create("DLabel")
my_updateable_element2 = vgui.Create("DButton")
my_updateable_element2.DoClick = function(self)
net.Start("foo")
net.SendToServer()
end
:
:
end
make_my_gui()
net.receive("bar",function()
print("I received a message from the server!")
my_updateable_element1:SetText(net.ReadString())
end)
[/code]
server-side
[code]
util.AddNetworkString("foo")
util.AddNetworkString("bar")
net.Receive("foo",function(ln,ply)
print("I received a message from the client!")
net.Start("bar")
net.WriteString("Oh snap, this label updated!")
net.Send(ply)
end)
[/code][/QUOTE]
If i create the panel outside the function it will popup, and there goes my isVisible verification
edit: if i only create the label then i get a failed attempt to index upvalue "frame" ( a nil value )
Sorry, you need to Log In to post a reply to this thread.