• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalToWorld]LocalToWorld[/url] Can someone elaborate a little more on the arguments for LocalToWorld? I know the first and second are the vector position and angles of the entity you are converting from. But it's saying something about a system I have to translate from for the 3rd and 4th arguments?
[QUOTE=bosnian_cyco;52224265][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalToWorld]LocalToWorld[/url] Can someone elaborate a little more on the arguments for LocalToWorld? I know the first and second are the vector position and angles of the entity you are converting from. But it's saying something about a system I have to translate from for the 3rd and 4th arguments?[/QUOTE] It's whatever origin point the vector+angle you're converting are relative to. If they're relative to some entity, you just use ent:GetPos(), ent:GetAngles().
[QUOTE=bosnian_cyco;52224265][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalToWorld]LocalToWorld[/url] Can someone elaborate a little more on the arguments for LocalToWorld? I know the first and second are the vector position and angles of the [b]entity you are converting from[/b]. But it's saying something about a system I have to translate from for the 3rd and 4th arguments?[/QUOTE] If you're converting from an entity (emphasized above), use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url] and/or [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorldAngles]Entity:LocalToWorldAngles[/url] instead (whichever one you need). It's better in every way: easier to work with, and more readable in code. However, to answer your question: your entity's position and angles would go as the [b]3rd and 4th arguments.[/b] The position you want to convert would be the first argument, and the angle you want to convert would be the second - if you don't need to convert an angle, you can supply [b]Angle()[/b] as the second argument and it wouldn't affect the output vector (argument 2 is only used for the output angle).
[QUOTE=NeatNit;52224459]If you're converting from an entity (emphasized above), use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url] and/or [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorldAngles]Entity:LocalToWorldAngles[/url] instead (whichever one you need). It's better in every way: easier to work with, and more readable in code. However, to answer your question: your entity's position and angles would go as the [b]3rd and 4th arguments.[/b] The position you want to convert would be the first argument, and the angle you want to convert would be the second - if you don't need to convert an angle, you can supply [b]Angle()[/b] as the second argument and it wouldn't affect the output vector (argument 2 is only used for the output angle).[/QUOTE] Oh, okay. Understand now. The wiki description for the arguments was just not making sense to me. Thanks bud :)
[QUOTE=bosnian_cyco;52224486]Oh, okay. Understand now. The wiki description for the arguments was just not making sense to me. Thanks bud :)[/QUOTE] What specifically was confusing you? I'll try to rewrite it to be more clear, once I understand the source of confusion. :smile:
[QUOTE=NeatNit;52224556]What specifically was confusing you? I'll try to rewrite it to be more clear, once I understand the source of confusion. :smile:[/QUOTE] Might of just been me, but I was wondering what "system" it was talking about. That specifically was what confused me. e.g. [QUOTE] Translates the specified position and angle from the specified coordinate system into worldspace coordinates The origin of the system to translate from. [/QUOTE] [editline]13th May 2017[/editline] Also, another question. you guys know what would be causing this? - [url]http://prntscr.com/f7j8s6[/url] The code I have for that was working fine and tracing that rocket there, but now it's doing something I can't even really explain. It sort of 'stretches' across the map. What? In case it makes a difference - [code] local missile_effect_data = EffectData() missile_effect_data:SetOrigin( self:GetPos() ) missile_effect_data:SetMagnitude( 1 ) util.Effect( "MuzzleEffect", missile_effect_data ) util.Effect( "ElectricSpark", missile_effect_data ) [/code]
Never had this problem before, I'm having some artifacting around my pngs when drawing them in my HUDPaint hook, [IMG]https://i.gyazo.com/89de97c1d48ba2cc2bacdb4dec0a1d81.png[/IMG] The image itself is perfectly fine, I zoomed in and there's no white at all Original: [IMG]http://i.imgur.com/X9siJc6.png[/IMG] And here's how I'm drawing it: [CODE]local CompassIcon = Material("materials/assets/Compass.png") local function DrawHUD() surface.SetDrawColor(255,255,255,255) surface.SetMaterial(CompassIcon) surface.DrawTexturedRectRotated(150,150,43,43, 0) end hook.Add("HUDPaint", "CompassDrawHUD", DrawHUD)[/CODE] Is there some method or something I need to call to make sure it draws correctly? :s:
[QUOTE=DahDestroyer;52225409]Never had this problem before, I'm having some artifacting around my pngs when drawing them in my HUDPaint hook, [IMG]https://i.gyazo.com/89de97c1d48ba2cc2bacdb4dec0a1d81.png[/IMG] The image itself is perfectly fine, I zoomed in and there's no white at all Original: [IMG]http://i.imgur.com/X9siJc6.png[/IMG] And here's how I'm drawing it: [CODE]local CompassIcon = Material("materials/assets/Compass.png") local function DrawHUD() surface.SetDrawColor(255,255,255,255) surface.SetMaterial(CompassIcon) surface.DrawTexturedRectRotated(150,150,43,43, 0) end hook.Add("HUDPaint", "CompassDrawHUD", DrawHUD)[/CODE] Is there some method or something I need to call to make sure it draws correctly? :s:[/QUOTE] [url]http://wiki.garrysmod.com/page/Global/Material[/url] Added a note for your case.
[QUOTE=Robotboy655;52225517][url]http://wiki.garrysmod.com/page/Global/Material[/url] Added a note for your case.[/QUOTE] Thank you! I was unaware of this. Strange but I guess I can work around it, much appreciated!
I wrote this a while ago which might help you, it's sort of laggy when you do multiple in a row: [url]https://gist.github.com/meepdarknessmeep/a2bb9c61e2cca03e2a37b2d305b1e0e0[/url]
Hey, I'm trying to interface with a Node.JS server using gm_bromsock. I can make the connection and send data just fine; however, I have no idea how to receive data back. In my server, I have: [code]sock.write(JSON.stringify( AUTHENTICATION_SUCCESS )); [/code] But I have no idea how to read the JSON it's returning. I've considered using socket:ReceiveUntil, but I have no idea what terminator to look for. Socket:Receive() with no arguments seems to give me this: [code] [ERROR] lua/includes/modules/hook.lua:84: error in bromsock_C++ allocating buffer to receive 2037654139 bytes from 47.186.34.95:6969 1. v - [C]:-1 2. unknown - lua/includes/modules/hook.lua:84 [/code], but giving it an argument makes it do nothing. Just for example, in the Node.JS client, I have: [code] client.on('data', function(data) { //code } [/code] All I want to do is read the JSON packet it's returning.
[QUOTE=bosnian_cyco;52224958]Might of just been me, but I was wondering what "system" it was talking about. That specifically was what confused me. e.g.[quote]Translates the specified position and angle from the specified coordinate system into worldspace coordinates The origin of the system to translate from.[/quote][/QUOTE] Hmm. The thing is, "system" was part of "[url=https://en.wikipedia.org/wiki/Coordinate_system]coordinate system[/url]", I don't think that part can be rewritten - but I will add the word "coordinate" to the parameter descriptions. I'll also add a link to Entity:LocalToWorld, because too many people are using the global instead of the entity method. [editline]14th May 2017[/editline] Did some rewriting, how is it now? [url]http://wiki.garrysmod.com/page/Global/LocalToWorld[/url] Don't be gentle, if anything still confusing about it I want to know. To do: rewrite WorldToLocal in the same style/vocabulary
-snip- sorted
[QUOTE=NeatNit;52226462]Hmm. The thing is, "system" was part of "[url=https://en.wikipedia.org/wiki/Coordinate_system]coordinate system[/url]", I don't think that part can be rewritten - but I will add the word "coordinate" to the parameter descriptions. I'll also add a link to Entity:LocalToWorld, because too many people are using the global instead of the entity method. [editline]14th May 2017[/editline] Did some rewriting, how is it now? [url]http://wiki.garrysmod.com/page/Global/LocalToWorld[/url] Don't be gentle, if anything still confusing about it I want to know. To do: rewrite WorldToLocal in the same style/vocabulary[/QUOTE] No, it seems pretty descriptive and more clear. :) Just curious though, what's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalToWorld]LocalToWorld[/url] used for since [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url] is used for entities?
[QUOTE=bosnian_cyco;52227587]No, it seems pretty descriptive and more clear. :) Just curious though, what's [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/LocalToWorld]LocalToWorld[/url] used for since [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url] is used for entities?[/QUOTE] It's used for arbitrary positions that aren't tied to an entity. Say if you want a coordinate system not at (0,0,0), or at the same world rotation, you can translate between the two systems
Solution was to terminate each net.write with "\r\n" and then search for that line ending. Because JSON doesn't care about whitespace at the end, this allows it to interface with both the Node client and bromsock.
[QUOTE=code_gs;52227616]It's used for arbitrary positions that aren't tied to an entity. Say if you want a coordinate system not at (0,0,0), or at the same world rotation, you can translate between the two systems[/QUOTE] I see. Thanks for clearing that up for me. :cat:
[QUOTE=DahDestroyer;52227027]The nub is back :magic101: I am trying to make a cinematic "style" cutscene, where the camera rotated around an object, I understand how to set the view of a players screen using [CODE] render.RenderView( { origin = pos, angles = ang } ) [/CODE] But how can I translate the angles into a rotation relative to a prop instead of just up down left right etc. I don't want to rotate the object, I want to rotate the camera around the object, and that's what I'm not too sure about, anyone able to point me in the right direction or help me out here? would be much appreciated.[/QUOTE] To rotate around the object, use the object position + your offsets + the angles right, up or forward scaled by some number Here is some code I used in a CalcView hook to do this which rotated around an object based upon how much you moved your mouse left or right in the current frame [code] -- incAround stores how much we are modifying the pitch by -- goUp scales the angles so it rotates farther away if input.IsMouseDown(MOUSE_RIGHT) then local changeX = initPosX - gui.MouseX() incAround = incAround + changeX*.2 entAngles = Angle(actualAng.p, actualAng.y + incAround, actualAng.r) end view.origin = baseFood:GetPos() + baseFood:GetUp()*40 + (entAngles:Up() * goUp) [/code]
Hey, I was wondering how I could open a derma panel after someone as hold a button for x second. For example, I want a menu to open after the player hold the "T" button for 3 sec. Is there any hook that I could use ?
I've been trying to solve this issue all day and I just can't do it anymore. Can someone explain to me why when my DFrame opens the mouse cursor is visible, but faintly as it is flickering, and when a player clicks in the Dframe the primary attack is triggered? I can only access the DFrame by pressing escape! [code] local Frame = vgui.Create("DFrame") Frame:SetPos(300, 200) Frame:SetSize(400, 200) Frame:SetTitle("Prop menu") Frame:SetDraggable(false) Frame:SetVisible(false) Frame:ShowCloseButton(true) Frame:SetDeleteOnClose(false) Frame:SetBackgroundBlur(true) --Frame:SetMouseInputEnabled(true) Frame.OnClose = function() Frame:SetMouseInputEnabled(false) Frame:SetKeyboardInputEnabled(false) Frame:KillFocus() gui.EnableScreenClicker(false) Frame:SetVisible(false) end function showProps() gui.EnableScreenClicker(true) Frame:SetMouseInputEnabled(true) Frame:SetKeyboardInputEnabled(true) Frame:RequestFocus() Frame:SetVisible(true) Frame:MakePopup() end usermessage.Hook("props", showProps) [/code] [code] function GM:ShowHelp(ply) umsg.Start("props",ply) umsg.End() end [/code] Really making me question my career choice as a computer scientist not being able to fix this stupid little bug
[QUOTE=cody1111;52229616]I've been trying to solve this issue all day and I just can't do it anymore. Can someone explain to me why when my DFrame opens the mouse cursor is visible, but faintly as it is flickering, and when a player clicks in the Dframe the primary attack is triggered? I can only access the DFrame by pressing escape! [code] local Frame = vgui.Create("DFrame") Frame:SetPos(300, 200) Frame:SetSize(400, 200) Frame:SetTitle("Prop menu") Frame:SetDraggable(false) Frame:SetVisible(false) Frame:ShowCloseButton(true) Frame:SetDeleteOnClose(false) Frame:SetBackgroundBlur(true) --Frame:SetMouseInputEnabled(true) Frame.OnClose = function() Frame:SetMouseInputEnabled(false) Frame:SetKeyboardInputEnabled(false) Frame:KillFocus() gui.EnableScreenClicker(false) Frame:SetVisible(false) end function showProps() gui.EnableScreenClicker(true) Frame:SetMouseInputEnabled(true) Frame:SetKeyboardInputEnabled(true) Frame:RequestFocus() Frame:SetVisible(true) Frame:MakePopup() end usermessage.Hook("props", showProps) [/code] [code] function GM:ShowHelp(ply) umsg.Start("props",ply) umsg.End() end [/code] Really making me question my career choice as a computer scientist not being able to fix this stupid little bug[/QUOTE] Try making the DMenu in a separate function and call that function in showProps() instead of doing what you're currently doing.
How do I move the chat in front of all derma panels? [t]http://i.imgur.com/qCjVzIP.png[/t]
[QUOTE=RaptorJGW;52231011]How do I move the chat in front of all derma panels? [t]http://i.imgur.com/qCjVzIP.png[/t][/QUOTE] Does this work? [img]http://wiki.garrysmod.com/favicon.ico[/img] [URL="https://wiki.garrysmod.com/page/Panel/MoveToBack"]Panel:MoveToBack[/URL]
[QUOTE=Ryanrc;52230082]Try making the DMenu in a separate function and call that function in showProps() instead of doing what you're currently doing.[/QUOTE] Should I also remove the DeleteOnClose()? Since it will be created every time it's opened? EDIT: Still does the same thing, flickering cursor, no mouse input, can only get input by pressing ESCAPE first. Wtf is the issue here? [CODE]function createFrame() local Frame = vgui.Create("DFrame") Frame:SetPos(300, 200) Frame:SetSize(400, 200) Frame:SetTitle("Prop menu") Frame:SetDraggable(false) Frame:SetVisible(false) Frame:ShowCloseButton(true) --Frame:SetDeleteOnClose(false) Frame:SetBackgroundBlur(true) --Frame:SetMouseInputEnabled(true) Frame.OnClose = function() Frame:SetMouseInputEnabled(false) Frame:SetKeyboardInputEnabled(false) Frame:KillFocus() gui.EnableScreenClicker(false) Frame:SetVisible(false) end return Frame end function showProps() local Frame = createFrame() gui.EnableScreenClicker(true) Frame:SetMouseInputEnabled(true) Frame:SetKeyboardInputEnabled(true) Frame:RequestFocus() Frame:SetVisible(true) Frame:MakePopup() end[/CODE]
[QUOTE=Ryanrc;52231081]Does this work? [img]http://wiki.garrysmod.com/favicon.ico[/img] [URL="https://wiki.garrysmod.com/page/Panel/MoveToBack"]Panel:MoveToBack[/URL][/QUOTE] Nope
[QUOTE=cody1111;52231235]Should I also remove the DeleteOnClose()? Since it will be created every time it's opened? EDIT: Still does the same thing, flickering cursor, no mouse input, can only get input by pressing ESCAPE first. Wtf is the issue here? [CODE]function createFrame() local Frame = vgui.Create("DFrame") Frame:SetPos(300, 200) Frame:SetSize(400, 200) Frame:SetTitle("Prop menu") Frame:SetDraggable(false) Frame:SetVisible(false) Frame:ShowCloseButton(true) --Frame:SetDeleteOnClose(false) Frame:SetBackgroundBlur(true) --Frame:SetMouseInputEnabled(true) Frame.OnClose = function() Frame:SetMouseInputEnabled(false) Frame:SetKeyboardInputEnabled(false) Frame:KillFocus() gui.EnableScreenClicker(false) Frame:SetVisible(false) end return Frame end function showProps() local Frame = createFrame() gui.EnableScreenClicker(true) Frame:SetMouseInputEnabled(true) Frame:SetKeyboardInputEnabled(true) Frame:RequestFocus() Frame:SetVisible(true) Frame:MakePopup() end[/CODE][/QUOTE] This should work. I've tested it and it works correctly. [CODE]function showProps() local Frame = vgui.Create("DFrame") Frame:SetPos(300, 200) Frame:SetSize(400, 200) Frame:SetTitle("Prop menu") Frame:SetDraggable(false) Frame:SetBackgroundBlur(true) Frame:MakePopup() end usermessage.Hook("props", showProps)[/CODE] [CODE]function GM:ShowHelp(ply) umsg.Start("props", ply) umsg.End() end[/CODE]
[QUOTE=RaptorJGW;52231299]Nope[/QUOTE] Then the panel you're parenting to is in front of the chat. Derma is definitely not my area of expertise, but I think you should parent the score board to the HUD. See [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/ParentToHUD]Panel:ParentToHUD[/url]
[QUOTE=NeatNit;52231596]Then the panel you're parenting to is in front of the chat. Derma is definitely not my area of expertise, but I think you should parent the score board to the HUD. See [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Panel/ParentToHUD]Panel:ParentToHUD[/url][/QUOTE] You actually helped me to fix a different problem with this. The derma menus disappear now when you hit escape to go to the menu, which is good. But the chat is still behind the menu
[QUOTE=Ryanrc;52231475]This should work. I've tested it and it works correctly. [CODE]function showProps() local Frame = vgui.Create("DFrame") Frame:SetPos(300, 200) Frame:SetSize(400, 200) Frame:SetTitle("Prop menu") Frame:SetDraggable(false) Frame:SetBackgroundBlur(true) Frame:MakePopup() end usermessage.Hook("props", showProps)[/CODE] [CODE]function GM:ShowHelp(ply) umsg.Start("props", ply) umsg.End() end[/CODE][/QUOTE] I tried it just like this in my gamemode and I have the issue I mentioned before with mouse input. However, starting a brand new gamemode with just that code it works fine, that means it must be something else in my code causing the mouse input issue? I'll start slowly adding in things from my other cl_init to the new one and see what fucks it up. EDIT: I narrowed it down to a panel, model panel, and dframe all being drawn as the HUD paints being the issue. Commenting out the hud stuff (besides surface text drawing) seems to fix the problem. Gonna go ahead an set a variable to determine when the derma is open so that the HUD isn't drawn. Will report back [editline]15th May 2017[/editline] Finally it works! All I had to do was have a boolean for when the derma is open, and when it is, don't draw the stuff that broke mouse input. Thanks for the help, all
Is it possible to pixelate/down res the screen? (With the intention of stenciling it later) I was pretty sure there was something for that.
Sorry, you need to Log In to post a reply to this thread.