[QUOTE=Sheeplie;47965271]Hey, what would I use to make a non-default-derma button, just like an image or some vgui I could click.
Also, how can I rotate a Dmodelpanel that's already made still- I just need it to be still in a better position.[/QUOTE]
You can use DImage to display a simple image, if you want to go further than that you can define your own control basing off another with [url=http://wiki.garrysmod.com/page/vgui/Register]vgui.Register[/url] or simply override a panel's paint function (panel.Paint = function(p, w, h) ... end)
And you can rotate using:
[lua]
local e = modelpanel:GetEntity();
e:SetAngles(Angle(0, 0, 0));
[/lua]
If you want to rotate the actual panel, it'd be more difficult.
[editline]15th June 2015[/editline]
What's a nice way of having data shared across a panel and subpanels? Here's a lovely paint diagram:
[img]http://i.imgur.com/fVpZBGW.png[/img]
Both "Left" and "Right" panels are children of BasePanel, they need to be able to modify data that all three panels have access to.
Ideally I want to be able to set data they'll all have access to by doing BasePanel:SetSomething and I want to avoid doing:
[lua]
child:GetParent():GetSomething()
[/lua]
Because it just doesn't feel very neat, anyone got some cool ideas?
[QUOTE=>>oubliette<<;47965555]You can use DImage to display a simple image, if you want to go further than that you can define your own control basing off another with [url=http://wiki.garrysmod.com/page/vgui/Register]vgui.Register[/url] or simply override a panel's paint function (panel.Paint = function(p, w, h) ... end)
And you can rotate using:
[lua]
local e = modelpanel:GetEntity();
e:SetAngles(Angle(0, 0, 0));
[/lua]
If you want to rotate the actual panel, it'd be more difficult.
[editline]15th June 2015[/editline]
What's a nice way of having data shared across a panel and subpanels? Here's a lovely paint diagram:
[img]http://i.imgur.com/fVpZBGW.png[/img]
Both "Left" and "Right" panels are children of BasePanel, they need to be able to modify data that all three panels have access to.
Ideally I want to be able to set data they'll all have access to by doing BasePanel:SetSomething and I want to avoid doing:
[lua]
child:GetParent():GetSomething()
[/lua]
Because it just doesn't feel very neat, anyone got some cool ideas?[/QUOTE]
[Lua]
BasePanel.something
LeftPanel:GetParent ().something[/lua]
[QUOTE=highvoltage;47965687][Lua]
BasePanel.something
LeftPanel:GetParent ().something[/lua][/QUOTE]
That's what I wanted to avoid doing.
Anyone know if you can somehow mute an NPC's sounds?
[QUOTE=>>oubliette<<;47965724]That's what I wanted to avoid doing.[/QUOTE]
could always define your own functions on the panels, but that would still require doing what you don't like.
Would entity-driving be useful for creating a custom third-person camera? I assume not, I don't feel like replacing all of the player physics.
Is there a way to clear Awesomium's cache? It seems the only way to guarantee the page actually updates is to restart Gmod completely. I am doing as much testing outside Gmod in Chrome as I can but some things (like JS <-> Lua stuff) have to be tested in Gmod. It's quite irritating having to restart the entire application each time.
[QUOTE=BL00DB4TH;47969460]Is there a way to clear Awesomium's cache? It seems the only way to guarantee the page actually updates is to restart Gmod completely. I am doing as much testing outside Gmod in Chrome as I can but some things (like JS <-> Lua stuff) have to be tested in Gmod. It's quite irritating having to restart the entire application each time.[/QUOTE]
Apply something at the end of the URL when you reload it... For example your original URL may be:
[I]/views/template.html[/I]
When you reload, just tack on a timestamp at the end or something:
[I]/views/template.html?1234567[/I]
The difference in URL's should trick the browser to pull down new contents.
Anyone know how would I make a Dmodelpanel's eyes / head follow my mouse?
I'm trying to use ScreenToLocal with gui.MousePos() to get the mouse's direction, hopefully I'm doing that right.
Anyone know how to make a DCheckBox set an NW bool to true when it's checked and set an NW bool to false when it's unchecked?
I've updated my srcds and keep getting this message when I try to connect to it.
[quote]The server you are trying to connect to is running a newer version of the game.[/quote]
This only happens on my local test server (from what I see), which is the only reason why I didn't post this in the Help & Support section. The VERSION variable on the client is 150601 and the VERSION variable on the server is 150614, but I don't know how to update the client? Shouldn't it be updated automatically? I have it set to do that. Are the versions supposed to be different? One for the server and one for the client?
[img]http://i.imgur.com/f8mmL9m.png[/img]
Sounds like your server is on the dev branch (did you add "-beta dev" to SteamCMD's app_update for some reason?).
[editline]15th June 2015[/editline]
[QUOTE=A Fghtr Pilot;47971277]Anyone know how to make a DCheckBox set an NW bool to true when it's checked and set an NW bool to false when it's unchecked?[/QUOTE]
Override the OnChange method?
[url]http://wiki.garrysmod.com/page/DCheckBox/OnChange[/url]
[QUOTE=Bo98;47972354]Sounds like your server is on the dev branch (did you add "-beta dev" to SteamCMD's app_update for some reason?).
[editline]15th June 2015[/editline]
Override the OnChange method?
[url]http://wiki.garrysmod.com/page/DCheckBox/OnChange[/url][/QUOTE]
I've changed it to the dev branch before, but it should have been reverted back to the live one, because these are the commands I'm currently using.
[quote]steamcmd.exe +login anonymous +app_update 4020 validate force_install_dir C:\SteamCMD\garrysmod\ +quit[/quote]
[QUOTE=Bo98;47972354]Sounds like your server is on the dev branch (did you add "-beta dev" to SteamCMD's app_update for some reason?).
[editline]15th June 2015[/editline]
Override the OnChange method?
[url]http://wiki.garrysmod.com/page/DCheckBox/OnChange[/url][/QUOTE]
Thanks! That really helped. Everything works perfectly now.
[editline]15th June 2015[/editline]
[code]--cl_init.lua
util.PrecacheModel( "models/player/combine_soldier.mdl" )
local df = vgui.Create( "DFrame" )
df:SetPos( 100, 100 )
df:SetSize( 600, 500 )
df:SetTitle( "Loadout Selection" )
df:ShowCloseButton( false )
df:Hide()
local dmodpan = vgui.Create( "DModelPanel", df )
dmodpan:SetModel( "models/player/combine_soldier.mdl" )
dmodpan:SetSize( 200, 200 )
dmodpan:SetPos( 60, 80 )
function dmodpan:LayoutEntity( ent ) return end
local idlestance = dmodpan:GetEntity():LookupSequence( "idle_passive" )
dmodpan:GetEntity():SetSequence( idlestance )
local dcbl = vgui.Create( "DCheckBoxLabel", df )
dcbl:SetPos( 280, 80 )
dcbl:SetValue( false )
dcbl:SetText( "Testing" )
function dcbl:OnChange( bVal )
if ( bVal == true ) then
LocalPlayer():SetNWBool( "SpawnWithAR2", true )
print(LocalPlayer():GetNWBool( "SpawnWithAR2" ) )
elseif ( bVal == false ) then
LocalPlayer():SetNWBool( "SpawnWithAR2", false )
print(LocalPlayer():GetNWBool( "SpawnWithAR2" ) )
end
end
function GM:ContextMenuOpen()
return false
end
function GM:OnContextMenuOpen()
gui.EnableScreenClicker( true )
df:Show()
end
function GM:OnContextMenuClose()
gui.EnableScreenClicker( false )
df:Hide()
end
[/code]
[code]--init.lua
function GM:PlayerSpawn( ply )
ply:SetModel( "models/player/combine_soldier.mdl" )
ply:SetupHands()
if ply:GetNWBool( "SpawnWithAR2", true ) then
ply:Give( "hl2_ar2" )
end
end
[/code]
Even if I select my check box to set the NW bool to false, it still gives me the weapon upon me spawning. Why is this? How can I fix it?
[editline]Edited:[/editline]
So, apparently the second argument for GetNWBool is the fallback value. So, I made a mistake there. But, if I set the fallback value to false and then do an == statement like so:
[code]if ply:GetNWBool( "SpawnWithAR2", false ) == true then[/code]
then it doesn't give me the weapon at all. I thought NWbools could be used both clientside and serverside?
Quick question, haven't messed with this stuff in ages. Concerning addons on a server, are the only files deployed to the client on join the ones sent with AddCSLuaFile?
[QUOTE=Shane;47974266]Quick question, haven't messed with this stuff in ages. Concerning addons on a server, are the only files deployed to the client on join the ones sent with AddCSLuaFile?[/QUOTE]
Those and anything in autorun/ or autorun/client
[QUOTE=Ott;47974670]Those and anything in autorun/ or autorun/client[/QUOTE]
I'm assuming autorun/server is still server side only then? I'm not sure what all has changed since the old gmod.
[QUOTE=A Fghtr Pilot;47972734]Thanks! That really helped. Everything works perfectly now.
[editline]15th June 2015[/editline]
[code]--cl_init.lua
util.PrecacheModel( "models/player/combine_soldier.mdl" )
local df = vgui.Create( "DFrame" )
df:SetPos( 100, 100 )
df:SetSize( 600, 500 )
df:SetTitle( "Loadout Selection" )
df:ShowCloseButton( false )
df:Hide()
local dmodpan = vgui.Create( "DModelPanel", df )
dmodpan:SetModel( "models/player/combine_soldier.mdl" )
dmodpan:SetSize( 200, 200 )
dmodpan:SetPos( 60, 80 )
function dmodpan:LayoutEntity( ent ) return end
local idlestance = dmodpan:GetEntity():LookupSequence( "idle_passive" )
dmodpan:GetEntity():SetSequence( idlestance )
local dcbl = vgui.Create( "DCheckBoxLabel", df )
dcbl:SetPos( 280, 80 )
dcbl:SetValue( false )
dcbl:SetText( "Testing" )
function dcbl:OnChange( bVal )
if ( bVal == true ) then
LocalPlayer():SetNWBool( "SpawnWithAR2", true )
print(LocalPlayer():GetNWBool( "SpawnWithAR2" ) )
elseif ( bVal == false ) then
LocalPlayer():SetNWBool( "SpawnWithAR2", false )
print(LocalPlayer():GetNWBool( "SpawnWithAR2" ) )
end
end
function GM:ContextMenuOpen()
return false
end
function GM:OnContextMenuOpen()
gui.EnableScreenClicker( true )
df:Show()
end
function GM:OnContextMenuClose()
gui.EnableScreenClicker( false )
df:Hide()
end
[/code]
[code]--init.lua
function GM:PlayerSpawn( ply )
ply:SetModel( "models/player/combine_soldier.mdl" )
ply:SetupHands()
if ply:GetNWBool( "SpawnWithAR2", true ) then
ply:Give( "hl2_ar2" )
end
end
[/code]
Even if I select my check box to set the NW bool to false, it still gives me the weapon upon me spawning. Why is this? How can I fix it?
[editline]Edited:[/editline]
So, apparently the second argument for GetNWBool is the fallback value. So, I made a mistake there. But, if I set the fallback value to false and then do an == statement like so:
[code]if ply:GetNWBool( "SpawnWithAR2", false ) == true then[/code]
then it doesn't give me the weapon at all. I thought NWbools could be used both clientside and serverside?[/QUOTE]
While NWVars can be set clientside, it does not get sent back to the server.
[editline]16th June 2015[/editline]
[QUOTE=man with hat;47972623]I've changed it to the dev branch before, but it should have been reverted back to the live one, because these are the commands I'm currently using.[/QUOTE]
Try setting the -beta to a non-existent branch. Eg. "-beta none"
Is there a way to have the fall damage hook be called for shorter falls? As of right now, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/GetFallDamage]GM/GetFallDamage[/url] is only called if the speed of the fall is somewhere above ~570.
[editline]16th June 2015[/editline]
[QUOTE=Revenge282;47978203]Is there a way to have the fall damage hook be called for shorter falls? As of right now, [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/GetFallDamage]GM/GetFallDamage[/url] is only called if the speed of the fall is somewhere above ~570.[/QUOTE]
Got it using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/OnPlayerHitGround]GM/OnPlayerHitGround[/url]
Anyone know of a command or something to code that will display serverside hitboxes, client side hitboxes, and bullet tracers? Using this for debugging not hacking xP
Edit: Simple search on the Wiki for the word Hitbox solved pretty much everything :P
I can't get numbers to random. I'm using math.random now and it always prints the same numbers regardless. I feel like this is a really stupid question but I am at the end of my tether with this.
[code]local SpinValue = { math.random(1, 5), math.random(1, 5), math.random(1, 5), }
function ENT:Use( activator, caller )
if ( !activator:IsPlayer() ) then return end
print(SpinValue[1], SpinValue[2], SpinValue[3])
return
end
function ENT:Think()
end[/code]
The value from math.random is stored when you create the table and will never change. Move the table to a hook where it needs to be updated.
i.e.
If you defined SpinValue in ENT:Use, you would get a different value each time.
[QUOTE=Greetings;47980046]The value from math.random is stored when you create the table and will never change. Move the table to a hook where it needs to be updated.
i.e.
If you defined SpinValue in ENT:Use, you would get a different value each time.[/QUOTE]
Thank you so much! I can't believe I didn't realise!
Question withdrawn >_< I'm a stoop...
[QUOTE=Kogitsune;47956417]Try using a mesh, something like:
[code]local t = Matrix( )
local ang = self:GetAngles( )
t:Translate( self:GetPos( ) )
t:Scale( scale or 1 )
t:Rotate( ang )
render.OverrideDepthEnable( true, true )
self.Mat = self.Mat or Material( self:GetMaterial( ), "VertexLitGeneric smooth" )
cam.PushModelMatrix( t )
render.SetMaterial( self.Mat )
render.SetLightmapMaterial( self.Mat:GetTexture( "$basetexture" ) )
render.ComputeLighting( self:GetPos( ), ang:Forward( ) )
mesh.Begin( MATERIAL_QUADS, 1 )
mesh.Position( upperleft )
mesh.Normal( normal_ul ) -- This should be the normal of the ground under the point
mesh.TexCoord( 0, 0, 0 )
mesh.Color( r, g, b )
mesh.AdvanceVertex( )
mesh.Position( upperright )
mesh.Normal( normal_ur )
mesh.TexCoord( 0, 1, 0 )
mesh.Color( r, g, b )
mesh.AdvanceVertex( )
mesh.Position( lowerright )
mesh.Normal( normal_lr )
mesh.TexCoord( 0, 1, 1 )
mesh.Color( r, g, b )
mesh.AdvanceVertex( )
mesh.Position( lowerleft )
mesh.Normal( normal_ll )
mesh.TexCoord( 0, 0, 1 )
mesh.Color( r, g, b )
mesh.AdvanceVertex( )
mesh.End( )
cam.PopModelMatrix( )
render.OverrideDepthEnable( false, false )[/code]
You might even be able to get away with mesh.QuadEasy:
[code]cam.PushModelMatrix( t )
render.SetMaterial( self.Mat )
render.SetLightmapMaterial( self.Mat:GetTexture( "$basetexture" ) )
render.ComputeLighting( self:GetPos( ), ang:Forward( ) )
mesh.QuadEasy( self:GetPos( ), ang:Forward( ), sizex, sizey )
end[/code]
This untested, but might help.[/QUOTE]
Am I supposed to draw this somewhere specific? I can't get it to draw in the entities draw hook
[editline]16th June 2015[/editline]
Here is the full draw code with debugging stuff that shows my math is at least good:
[lua]function ENT:Draw()
local vecs = {Vector(dist,0,0),Vector(0,dist,0),Vector(0,0,dist),Vector(-dist,0,0),Vector(0,-dist,0),Vector(0,0,-dist)}
local results = {}
for k,v in ipairs(vecs) do
local tr = util.QuickTrace( self:GetPos(), v, self )
if tr.Hit then
local tr2 = util.QuickTrace( self:GetPos(), tr.HitNormal*-dist, self )
if tr2.Hit then results[tr2.HitNormal] = tr2.HitPos end
end
end
for normal,pos in pairs(results) do
debugoverlay.Cross( pos, 4, 0.22, Color(0,255,0), true )
debugoverlay.Line( self:GetPos(), pos, 0.22, Color(255,0,0), true )
local t = Matrix( )
local ang = normal:Angle()
t:Translate( pos )
t:Scale( scale or Vector(1,1,1) )
t:Rotate( ang )
render.OverrideDepthEnable( true, true )
Mat = Material( self:GetMaterialName(), "VertexLitGeneric smooth" )
cam.PushModelMatrix( t )
render.SetMaterial( Mat )
render.SetLightmapTexture( Mat:GetTexture( "$basetexture" ) )
render.ComputeLighting( pos, ang:Forward( ) )
local r,g,b,a = 255,255,255,255
mesh.Begin( MATERIAL_QUADS, 1 )
local position = pos+(ang:Up()*(self:GetH()/2))+(-ang:Right()*(self:GetW()/2))
debugoverlay.Axis( position, ang, 4, 0.22, true )
debugoverlay.Line( self:GetPos(), position, 0.22, Color(255,0,0), true )
--print(position)
mesh.Position( position )--upperleft
mesh.Normal( normal ) -- This should be the normal of the ground under the point
mesh.TexCoord( 0, 0, 0 )
mesh.Color( r, g, b, a )
mesh.AdvanceVertex( )
position = pos+ (ang:Up()*(self:GetH()/2))+(ang:Right()*(self:GetW()/2))
debugoverlay.Axis( position, ang, 4, 0.22, true )
debugoverlay.Line( self:GetPos(), position, 0.22, Color(255,0,0), true )
mesh.Position( position )--upperright
mesh.Normal( normal )
mesh.TexCoord( 0, 1, 0 )
mesh.Color( r, g, b, a )
mesh.AdvanceVertex( )
position = pos+(-ang:Up()*(self:GetH()/2))+(ang:Right()*(self:GetW()/2))
debugoverlay.Axis( position, ang, 4, 0.22, true )
debugoverlay.Line( self:GetPos(), position, 0.22, Color(255,0,0), true )
mesh.Position( position )--lowerright
mesh.Normal( normal )
mesh.TexCoord( 0, 1, 1 )
mesh.Color( r, g, b, a )
mesh.AdvanceVertex( )
position = pos+(-ang:Up()*(self:GetH()/2))+(-ang:Right()*(self:GetW()/2))
debugoverlay.Axis( position, ang, 4, 0.22, true )
debugoverlay.Line( self:GetPos(), position, 0.22, Color(255,0,0), true )
mesh.Position( position )--lowerleft
mesh.Normal( normal )
mesh.TexCoord( 0, 0, 1 )
mesh.Color( r, g, b, a )
mesh.AdvanceVertex( )
mesh.End( )
--]]
cam.PopModelMatrix( )
render.OverrideDepthEnable( false, false )
end
end[/lua]
You know how right after you die for a few seconds (or until you click a button) your camera goes third person around your corpse? How could I check when a player enters/exits that. GetObserverMode/Target both don't work. Mode will always return 0 and Target wont return anything.
[QUOTE=Bo98;47977372]Try setting the -beta to a non-existent branch. Eg. "-beta none"[/QUOTE]
Wow, it worked. Thanks!
[lua]NAME:SetPos( 0, 0 )
NAME:SetSize(ScrW()*0.3,ScrH()*0.3)
NAME.Paint = function ()
draw.DrawText( "REEL MACHINE", "MachineName", MF:GetWide()/2, MF:GetTall()*0.05, Color( 255, 255, 255, 30 ), TEXT_ALIGN_CENTER )
end[/lua]
Is there any way to make a font or text scale? I'm also using a 'custom font' which is just Impact. I'm also scared my code is unnecessary or ugly, if so I'm sorry! I'm kinda new to this.
[lua]local function MF()
surface.CreateFont( "MachineName", {
font = "Impact",
size = 90,
weight = 500,
blursize = 0,
scanlines = 0,
antialias = true,
underline = false,
italic = false,
strikeout = false,
symbol = false,
rotary = false,
shadow = false,
additive = false,
outline = true,
} )[/lua]
[B]E:[/B]
Oh nevermind I found out myself! Using ScreenScale :)
I have this in autorun:
[lua]
AddCSLuaFile( "levels/sh_levels.lua" )
AddCSLuaFile( "levels/cl_levels.lua" )
include( "levels/sh_levels.lua" )
if SERVER then
include( "levels/sv_levels.lua" )
else
include( "levels/cl_levels.lua" )
end
[/lua]
However it doesn't run until I save the file and refresh it, am I doing something wrong?
[lua] SLOTS:SetPos(0,20)
SLOTS:SetSize(ScrW()*0.5,ScrH()*0.5)
SLOTS.Paint = function ()
draw.RoundedBox( 5, ((MF:GetWide()/2)-MF:GetWide()*0.3/2), MF:GetTall()*0.175, MF:GetWide()*0.3, MF:GetTall()*0.625, Color( 255, 255, 255, 30 ) )
draw.RoundedBox( 5, ((MF:GetWide()/2)-MF:GetWide()*0.3-MF:GetWide()*0.16), MF:GetTall()*0.175, MF:GetWide()*0.3, MF:GetTall()*0.625, Color( 255, 255, 255, 30 ) )
draw.RoundedBox( 5, ((MF:GetWide()/2)+MF:GetWide()*0.3-MF:GetWide()*0.14), MF:GetTall()*0.175, MF:GetWide()*0.3, MF:GetTall()*0.625, Color( 255, 255, 255, 30 ) )
draw.DrawText( "1", "MachineName", MF:GetWide()*0.5, MF:GetTall()*0.375, Color( 255, 255, 255, 30 ), TEXT_ALIGN_CENTER )
draw.DrawText( "1", "MachineName", MF:GetWide()*0.81225, MF:GetTall()*0.375, Color( 255, 255, 255, 30 ), TEXT_ALIGN_CENTER )
draw.DrawText( "1", "MachineName", MF:GetWide()*0.2, MF:GetTall()*0.375, Color( 255, 255, 255, 30 ), TEXT_ALIGN_CENTER )
end
SPINPANEL:SetPos( (MF:GetWide()/2)-MF:GetWide()*0.3/2, MF:GetTall()*0.175)
SPINPANEL:SetSize(MF:GetWide()*0.3, MF:GetTall()*0.625)
[/lua]
[img]http://i.imgur.com/qozsWch.png[/img]
Can someone figure out why these aren't aligning even though they are using the same values?
Sorry, you need to Log In to post a reply to this thread.