• Problems That Don't Need Their Own Thread v3.0
5,003 replies, posted
<snip> figured it out
Is there a way to see what scripts are taking up the most memory/ generating the most lag?
[QUOTE=DevShinx;47699248]Is there a way to see what scripts are taking up the most memory/ generating the most lag?[/QUOTE] [url]https://github.com/oubliette32/DBugR[/url] this is very useful
I know there was a thread lying around with useful code sniplets but I can't find it so, how can I make strobing colors with sine and stuff?
[QUOTE=LUModder;47699433]I know there was a thread lying around with useful code sniplets but I can't find it so, how can I make strobing colors with sine and stuff?[/QUOTE] [code]math.abs( math.sin( CurTime() * X ) ) * Y[/code] CurTime() should be multiplied by a large number to get a strobe. X is that CurTime() Multiplier. Y is the highest value for your color, so... 255 for full bright... Basically CurTime() keeps the sin / cosine changing. You take the absolute value of it because sin and cosine will return negative and positive values, not just positive. For ridiculously fast strobing, try CurTime() * 62.8
Not sure if I'm being very very stupid here, but. [LUA] -- sample table set. pie = {} pie["test"] = 1 pie["tree"] = 23 -- This line should copy pie into Entity(1).PieTable right? Entity(1).PieTable = pie Entity(1).PieTable["test"] = 2 PrintTable(pie) [/LUA] Ok, so an obviously quick typed example of what I mean. Hope I typed it right as I'm not on a PC, anyway. PrintTable(pie) is outputting pie["test"] = 2 pie["tree"] = 23 Why is the value of pie["test"] changing? I thought doing Entity(1).PieTable would copy the pie table into the entity var PieTable, not link it in some way.
[QUOTE=Pantho;47701739]Not sure if I'm being very very stupid here, but. [LUA] -- sample table set. pie = {} pie["test"] = 1 pie["tree"] = 23 -- This line should copy pie into Entity(1).PieTable right? Entity(1).PieTable = pie Entity(1).PieTable["test"] = 2 PrintTable(pie) [/LUA] Ok, so an obviously quick typed example of what I mean. Hope I typed it right as I'm not on a PC, anyway. PrintTable(pie) is outputting pie["test"] = 2 pie["tree"] = 23 Why is the value of pie["test"] changing? I thought doing Entity(1).PieTable would copy the pie table into the entity var PieTable, not link it in some way.[/QUOTE] Because it's passed by reference, rather than by value. both pie["test"] and Entity(1).PieTable["test"] are pointing to the same place in memory. (they are referencing the same thing) you might have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/Copy]table.Copy[/url]
[QUOTE=Blasteh;47701760]Because it's passed by reference, rather than by value. both pie["test"] and Entity(1).PieTable["test"] are pointing to the same place in memory. (they are referencing the same thing) you might have to use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/table/Copy]table.Copy[/url][/QUOTE] Is this just because it's a table and is this normal LUA practice or gmod buggery?
[QUOTE=Pantho;47701791]Is this just because it's a table and is this normal LUA practice or gmod buggery?[/QUOTE] It'll be a Lua thing; different languages might do things differently, but it's usually something to check for if you need/don't need the functionality. edit: this might explain it better: [url]http://www.lua.org/pil/2.5.html[/url] edit2: functions, tables, and userdata are passed by reference, everything else is passed by value
Technically speaking, no variable is passed by reference in Lua. That would imply the following: [code] function Test( a, b ) a, b = 2, { 2 } end a, b = 1, { 1 } Test( a, b ) -- If b were passed by reference, it would now contain the number 2. But it doesn't. [/code] Instead, the value of the variable 'b' is a reference to a table. The same rules apply for functions, userdata, strings and coroutine-threads. Hell, you can argue every data-type works this way seeing as the rest are immutable. tl;dr: The only reason tables feel different is because their contents can change. Every value works this way and no variable is passed by reference.
Another one that's confusing me... [IMG]http://share.bybservers.co.uk/2015-05-11_18-41-42.png[/IMG] Line 24 declares, line 25 what?
[QUOTE=Pantho;47703284]Another one that's confusing me... [IMG]http://share.bybservers.co.uk/2015-05-11_18-41-42.png[/IMG] Line 24 declares, line 25 what?[/QUOTE] You are calling vgui.Create too early so nil is returned as it fails to create the panel. Do it from the Initialize hook or later.
Quick question, does http.Fetch block HTTPS urls?
[QUOTE=Willox;47703304]You are calling vgui.Create too early so nil is returned as it fails to create the panel. Do it from the Initialize hook or later.[/QUOTE] How annoying, but fair enough.
[QUOTE=James xX;47703413]Quick question, does http.Fetch block HTTPS urls?[/QUOTE] No it doesn't. It works like any other http:// url when I tested it.
For some reason on my server, you cant place a law board. There are no errors in console or for clients. Anyone have any ideas? Edit: Great, thanks for the help.
Does anyone know how to correct the player aim-vector/model-aim-vector discrepancy? You know, how when looking straight forward, parallel to the ground, your playermodel is aiming a good 30 degrees downward... quite idiotic Thought there might be some way to override the playermodel's aim direction in some hook, but the wiki yields no clues
[QUOTE=ThrowAwayAcct;47705839]Does anyone know how to correct the player aim-vector/model-aim-vector discrepancy? You know, how when looking straight forward, parallel to the ground, your playermodel is aiming a good 30 degrees downward... quite idiotic Thought there might be some way to override the playermodel's aim direction in some hook, but the wiki yields no clues[/QUOTE] Not sure, but this might help: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/AddCallback]Entity:AddCallback[/url] [url]http://wiki.garrysmod.com/page/Entity_Callbacks[/url] See BuildBonePositions. [editline]e[/editline] Awh man, I was saving my 3k post for something special :rolleyes:
It was special to me. EDIT: I don't think that'll help. The player's aim direction consists of movements and angles of a whole crapload of bones. I wouldn't know how to custom re-build all the player's bones to do this. Thanks though.
Is it possible to have a clientside model(object) have physical attributes? The object would collide successfully with the ground/world and you'd have the ability to change that clientside model's velocity/angle velocity? Is this possible? The reason for this would be smoothing out lag on my gamemode for my car entities. [t]https://dl.dropboxusercontent.com/u/17839069/C_293.png[/t]
[QUOTE=EthanTheGreat;47706279]Is it possible to have a clientside model(object) have physical attributes? The object would collide successfully with the ground/world and you'd have the ability to change that clientside model's velocity/angle velocity? Is this possible? The reason for this would be smoothing out lag on my gamemode for my car entities. [t]https://dl.dropboxusercontent.com/u/17839069/C_293.png[/t][/QUOTE] How is your server FPS 11,111?
Okay so i have a spectate command for my gmod gamemode: --Spectate function chatCommand( ply, text, public ) if (string.sub(text, 1) == "!spectate_game") then ply:Spectate( 6 ) return(false) end end hook.Add( "PlayerSay", "chatCommand", chatCommand ); And im trying to make a join game command here is what i have: --Join game function chatCommand( ply, text, public ) if (string.sub(text, 1) == "!join_game") then ply:Spectate( 6 ) --what do i replace this with to unspectate return(false) end end hook.Add( "PlayerSay", "chatCommand", chatCommand ); thanks any help is appricieted
[QUOTE=EthanTheGreat;47706279]Is it possible to have a clientside model(object) have physical attributes? The object would collide successfully with the ground/world and you'd have the ability to change that clientside model's velocity/angle velocity? Is this possible? The reason for this would be smoothing out lag on my gamemode for my car entities. [t]https://dl.dropboxusercontent.com/u/17839069/C_293.png[/t][/QUOTE] You can use ClientsideModel and then create a physics object for it, but it'll only collide with the world and other clientside physics objects. Anything else, like a regular entity, will just pass through it. Something like this: [code]if SERVER then return end self.csmodel = ClientsideModel(self:GetModel()) if !util.IsValidProp(self:GetModel()) then self.csmodel:PhysicsInitBox(self.csmodel:GetModelBounds()) else self.csmodel:PhysicsInit(SOLID_VPHYSICS) end self.csmodel:GetPhysicsObject():Wake() self.csmodel:SetPos(wherever) self.csmodel:SetAngles(some_angle) //do things with self.csmodel[/code] Entity:DeleteOnRemove() only works serverside, though, so you'll need to set up something else to remove the clientside model once you don't need it. Maybe you can use the OnRemove hook or something, I don't know - the only time I ever used clientside props like these, I just had them expire on a timer.
Is there a way to prevent this problem? Where print(string.len("&#10084;")) = 3? Well, more importantly do any string operation with it without it splitting into 3 characters. --Figured out something that solved my problem--
Any idea what is causing the text above players to not render in front of some entitys? [img]http://puu.sh/hKnzv/dfde4a410d.jpg[/img]
[QUOTE=101kl;47708020]Any idea what is causing the text above players to not render in front of some entitys? [img]http://puu.sh/hKnzv/dfde4a410d.jpg[/img][/QUOTE] Rendering order? Idk this happens with a lot of things
[QUOTE=101kl;47708020]Any idea what is causing the text above players to not render in front of some entitys? [img]http://puu.sh/hKnzv/dfde4a410d.jpg[/img][/QUOTE] Always use PostDrawTranslucentRenderables hook for 3D2D.
Is there a way to test binary modules without restarting completely?
[QUOTE=KillerLUA;47708865]Is there a way to test binary modules without restarting completely?[/QUOTE] change the level
Question, how do I reset an entity's material through my code? I'm trying to make a nextbot that's invisible, but only shows itself(aka changing the material back to normal) when it's about to strike it's target.