[QUOTE=G4MB!T;47266474]If you go to the skyscraper doors or any doors that are naturally 90 degrees to those and it works I'll beg you for the solution D:[/QUOTE]
Is this what you're looking for?
[vid]http://puu.sh/got1U/7b8b793f41.webm[/vid]
[QUOTE=bobbleheadbob;47267780]I'll draw this out and give you the answer.
[editline]google[/editline]
Google came up with this:
R=V−2N(V⋅N)
R = reflected vector
V = Input Vector
N = Plane Normal
So
[lua]
function math.VectorReflect(vec,norm)
local ref = vec - 2 * norm * vec:Dot(norm)
return ref
end
[/lua][/QUOTE]
Curious, what did you google? Obviously I suck at google.
Also... I need to take more math classes or something because I don't know anything about dot products... is that just multiplication of two vectors?
So, this wouldn't work, then?
[code]function math.VectorReflect(vec,norm)
local ref = vec - 2 * norm * ( vec * norm )
return ref
end[/code]
[editline]6th March 2015[/editline]
Research... no, vec * norm wouldn't work. I withdraw the question.
[editline]6th March 2015[/editline]
I was gonna do a proper edit but it messed up the quote... so I guess double post, I forgot to thank you, bobbleheadbob, for helping me out! Thank you very much!
[editline]6th March 2015[/editline]
Or not double post...
[QUOTE=Revenge282;47267810]-What I'm looking for[/QUOTE]
Yes :D! Do you think it would be possible to help me at all? I'm not asking for copy/paste code or anything.
[QUOTE=GreyGeist;47267746]What is wrong with this recoil code? Seems to be extremely broken, to the point that the player's pitch can actually go way beyond where it should. How can I clamp this?
[/QUOTE]
Angles are between -180 and 180; you can use math.NormalizeAngle( Angle( 360, 0, 0 ).p ); for it to become 180. There are other methods of doing this too and you can manually clamp it by knowing the range - for example, this snippet to calculate the current angle yaw or whatever should be if rotating it at a set speed ( bound to time ) with an offset so other entities won't be in sync ( calculate self.Offset from 0-360 on entity creation ):
[code]//
// Handles repetitive smooth rotational calculations into 1 line without the confusion and normalizes the angle ( -180 )
//
function math.rotate( _speed, _offset )
return ( ( RealTime( ) * ( _speed || 180 ) + ( _offset || 0 ) ) % 360 ) - 180;
end
[/code]
But, the solution for you could be simplified to simply be math.min or math.max of a value, you can also clamp the value... I'd recommend something like the rotation where it assumes 0-360 and subtracts 180 after it is done. math.Clamp( ( blah + 180 + kickback ) % 360, 0, 360 ) - 180; or so...
Are there any lua implementations of a symmetric encryption system?
Wanting to send stuff over sockets without stuff being seen in plain text..
Anyone know how to stop this?
[vid]http://puu.sh/goXRI/4f54b2ac3e.webm[/vid]
I have tried [url]http://wiki.garrysmod.com/page/Vehicle/SetVehicleEntryAnim[/url] but it would seem that that function doesn't do anything (or has nothing to do with the problem at hand).
[QUOTE=unrezt;47269961]Anyone know how to stop this?
[ video ]
I have tried [url]http://wiki.garrysmod.com/page/Vehicle/SetVehicleEntryAnim[/url] but it would seem that that function doesn't do anything (or has nothing to do with the problem at hand).[/QUOTE]
I just tried entering this very seat in vanilla sandbox, not seeing this issue. What version of gmod are you even on? It looks like gmod 9 or something
[QUOTE=Neat-Nit;47270591]I just tried entering this very seat in vanilla sandbox, not seeing this issue. What version of gmod are you even on? It looks like gmod 9 or something[/QUOTE]
I'm using a shitty laptop on low settings. If it isn't clear, the issue is that for the 1-2 seconds while entering the vehicle, you can't move the camera.
[QUOTE=G4MB!T;47268414]Yes :D! Do you think it would be possible to help me at all? I'm not asking for copy/paste code or anything.[/QUOTE]
Pretty much just do a trace on the door and get the normal, then get your angle from that. I can help you out more on Steam, I sent a request.
[QUOTE=Revenge282;47270750]Pretty much just do a trace on the door and get the normal, then get your angle from that. I can help you out more on Steam, I sent a request.[/QUOTE]
Awesome thanks :D I accepted but it says you were online 14 hours ago?
[QUOTE=Drakehawke;47263933]Code for GMGC.SaveLog?[/QUOTE]
[CODE]
GMGC.Dir = "gmgc"
GMGC.File = "gamemode_gamecounter"
GMGC.StrDir = string.format("%s/%s.txt",GMGC.Dir,GMGC.File)
GMGC.Counter = {}
[/CODE]
[CODE]
function GMGC.SaveLog()
file.Write(GMGC.StrDir, util.TableToJSON(GMGC.Counter))
end
[/CODE]
So this kind of goes with my last question but what is the thing that you call for the total amount of ammo a player has on the currently equipped gun? I already have the amount that the player has in the current clip.
Is there a function to collapse a sparse table into a sequential table?
for example:
1 = "One"
5 = "Five"
1200 = "Twelve-Hundred"
would become:
1 = "One"
2 = "Five"
3 = "Twelve-Hundred"
if not I might just make a Pull Request for it - sounds generic enough.
[editline]7th March 2015[/editline]
Oh and here's why:
[img]http://i.gyazo.com/b51740d7b6d5243992293f5a02b41bc5.png[/img]
[url]http://www.lua.org/cgi-bin/demo[/url][lua]local tab = {[1] = "One", [5] = "Five", [1200] = "Twelve-Hundred", abc = "Alphabet"}
print("=== BEFORE (ipairs) ===")
for k, v in ipairs(tab) do print(k,v) end
print("=== BEFORE (pairs) ===")
for k, v in pairs(tab) do print(k,v) end
local keys = {}
for k in pairs(tab) do
if type(k) == "number" then table.insert(keys, k) end
end
table.sort(keys)
local collapsedtab = {}
for k, v in ipairs(keys) do table.insert(collapsedtab, tab[v]) end
print("=== AFTER (ipairs) ===")
for k, v in ipairs(collapsedtab) do print(k,v) end
print("=== AFTER (pairs) ===")
for k, v in pairs(collapsedtab) do print(k,v) end[/lua]
(sorry for the ugly code, I literally did this in the browser)
Nup. You could make your own though.
How would I change RichText font?
[QUOTE=VIoxtar;47275602]How would I change RichText font?[/QUOTE]
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/SetFontInternal]Panel:SetFontInternal[/url]
[QUOTE=Neat-Nit;47274959]Is there a function to collapse a sparse table into a sequential table?
for example:
1 = "One"
5 = "Five"
1200 = "Twelve-Hundred"
would become:
1 = "One"
2 = "Five"
3 = "Twelve-Hundred"
if not I might just make a Pull Request for it - sounds generic enough.
[/QUOTE]
Check this page:
[url]http://lua-users.org/wiki/SortedIteration[/url]
Hey!, Anyone got any idea on how you make a circular avatar image?
Thanks in advanced for any replies!
You mean in a HUD?
[QUOTE=AIX-Who;47276612]Hey!, Anyone got any idea on how you make a circular avatar image?
Thanks in advanced for any replies![/QUOTE]
You'd have to use stencils for that, I think I have a code that does this, actually.
[editline]n[/editline]
Well, here it is, untested.
[lua]local PANEL = {}
function PANEL:Init()
self.Avatar = vgui.Create("AvatarImage", self)
self.Avatar:SetPaintedManually(true)
end
function PANEL:PerformLayout()
self.Avatar:SetSize(self:GetWide(), self:GetTall())
local sin, cos, rad = math.sin, math.cos, math.rad
local function GeneratePoly(x, y, radius, quality)
local circle = {}
local tmp = 0
for i = 1, quality do
tmp = rad( i * 360) / quality
circle[i] = {x = x + cos(tmp) * radius, y = y + sin(tmp) * radius}
end
return circle
end
self.Poly = GeneratePoly(self:GetWide()/2, self:GetTall()/2, self:GetWide()/2, self:GetWide()*2)
end
function PANEL:Paint(w, h)
render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilWriteMask( 1 )
render.SetStencilTestMask( 1 )
render.SetStencilFailOperation( STENCILOPERATION_REPLACE )
render.SetStencilPassOperation( STENCILOPERATION_ZERO )
render.SetStencilZFailOperation( STENCILOPERATION_ZERO )
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_NEVER )
render.SetStencilReferenceValue( 1 )
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawPoly(self.Poly)
render.SetStencilFailOperation( STENCILOPERATION_ZERO )
render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
render.SetStencilZFailOperation( STENCILOPERATION_ZERO )
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
render.SetStencilReferenceValue( 1 )
self.Avatar:SetPaintedManually(false)
self.Avatar:PaintManual()
self.Avatar:SetPaintedManually(true)
render.SetStencilEnable(false)
render.ClearStencil()
end
vgui.Register("DRoundedAvatar", PANEL)[/lua]
I don't actually know who wrote this, but if whomever doesnt want it posted, just PM me or something. But, thanks a lot to whoever did, really helpful.
[editline]n[/editline]
Any methods on how to check if a DScrollPanel has the VBar open? Looks a little odd when theres this big space where the VBar should be.
[QUOTE=Author.;47276648]You'd have to use stencils for that, I think I have a code that does this, actually.
[editline]n[/editline]
Well, here it is, untested.
[lua]local PANEL = {}
function PANEL:Init()
self.Avatar = vgui.Create("AvatarImage", self)
self.Avatar:SetPaintedManually(true)
end
function PANEL:PerformLayout()
self.Avatar:SetSize(self:GetWide(), self:GetTall())
local sin, cos, rad = math.sin, math.cos, math.rad
local function GeneratePoly(x, y, radius, quality)
local circle = {}
local tmp = 0
for i = 1, quality do
tmp = rad( i * 360) / quality
circle[i] = {x = x + cos(tmp) * radius, y = y + sin(tmp) * radius}
end
return circle
end
self.Poly = GeneratePoly(self:GetWide()/2, self:GetTall()/2, self:GetWide()/2, self:GetWide()*2)
end
function PANEL:Paint(w, h)
render.ClearStencil()
render.SetStencilEnable(true)
render.SetStencilWriteMask( 1 )
render.SetStencilTestMask( 1 )
render.SetStencilFailOperation( STENCILOPERATION_REPLACE )
render.SetStencilPassOperation( STENCILOPERATION_ZERO )
render.SetStencilZFailOperation( STENCILOPERATION_ZERO )
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_NEVER )
render.SetStencilReferenceValue( 1 )
surface.SetDrawColor(255, 255, 255, 255)
surface.DrawPoly(self.Poly)
render.SetStencilFailOperation( STENCILOPERATION_ZERO )
render.SetStencilPassOperation( STENCILOPERATION_REPLACE )
render.SetStencilZFailOperation( STENCILOPERATION_ZERO )
render.SetStencilCompareFunction( STENCILCOMPARISONFUNCTION_EQUAL )
render.SetStencilReferenceValue( 1 )
self.Avatar:SetPaintedManually(false)
self.Avatar:PaintManual()
self.Avatar:SetPaintedManually(true)
render.SetStencilEnable(false)
render.ClearStencil()
end
vgui.Register("DRoundedAvatar", PANEL)[/lua]
[editline]n[/editline]
Any methods on how to check if a DScrollPanel has the VBar open? Looks a little odd when theres this big space where the VBar should be.[/QUOTE]
That worked perfectly, thanks very much man :)
Although i apparently have no avatar and its just a question mark, it may be something on my side
When changing player eye angles with calcview, why is the game still treating the mouse input as if the view was normal? If i rotate the players view 180 degrees on the roll or pitch axis the mouse movement gets inverted, how can I get around this?
[QUOTE=Author.;47276698]Try something like this;
[lua]local avatar = vgui.Create("DRoundedAvatar")
avatar.Avatar:SetPlayer( LocalPlayer() )[/lua][/QUOTE]
Oh i love you, thanks so much for this :)
This is kind of embarrassing but I find myself having to ask...
[lua]SERVER and CLIENT[/lua]Is there any situation in which this is true?
[QUOTE=Neat-Nit;47276815]This is kind of embarrassing but I find myself having to ask...
[lua]SERVER and CLIENT[/lua]Is there any situation in which this is true?[/QUOTE]
No. Only a bad addon can cause this.
Hey guys is there a way to make a circle and crop everything on the outside of the circle?
[QUOTE=GoldTrigger;47277312]Hey guys is there a way to make a circle and crop everything on the outside of the circle?[/QUOTE]
What do you mean? Crop everything on the [B]outside[/B] of the circle?
You mean have the circle in focus and white background or what?
GoldTrigger just misunderstood a link I gave him in another thread (it's partly my fault - I just posted a link with no explanation).
GoldTrigger, the answer you're looking for is just a few posts above, in Post #4503 and #4505.
-snip-
Can't really ask for help on a system I designed :/
Sorry, you need to Log In to post a reply to this thread.