• Problems That Don't Need Their Own Thread v5
    4,111 replies, posted
[QUOTE=code_gs;52743627]I don't think you can make traces work like that. Best solution would be if the trace hits a nodraw/skybox, retrace from the hit point of the previous trace and continue going.[/QUOTE] Okay ! Thanks it works But ... another issue ^^ [video]https://youtu.be/qnnZPX8hSvs[/video] Like you see the comportment works pretty well in some parts of the map but in others the comportments gets weird ... Maybe a error at my FOV calcul ? [CODE] local function MyLittleGreatViewWOW() /* Set an orthogonal vision* here .../ render.RenderView(ren) return true end hook.Add("RenderScene", "pm_gamemasterview", MyLittleGreatViewWOW) local function CursorLight() local H = ren.orthoright-ren.ortholeft local D = ren.origin.z local fov= math.deg( math.atan(0.5 * H / D) ) if vgui.CursorVisible() then local direction = util.AimVector( ren.angles, 2* fov, gui.MouseX(), gui.MouseY(), SCRW, SCRH ) local function traceWhileNoNoDraw(table,max) result = util.TraceLine(table) if result.HitTexture == "TOOLS/TOOLSNODRAW" or result.HitTexture == "TOOLS/TOOLSSKYBOX" or result.HitTexture == "TOOLS/TOOLSINVISIBLE" or result.HitTexture == "**studio**" then table.start = result.HitPos + direction * 100 table.endpos = result.HitPos + direction * 10000 print(result.HitTexture .. " SKIPPED") return traceWhileNoNoDraw(table) end return result end local test = traceWhileNoNoDraw({ start = ren.origin, endpos = ren.origin + direction * 10000, filter = function( ent ) if ( ent:GetClass() == "prop_physics") then return true end end, }) local curlight = DynamicLight( LocalPlayer():EntIndex() ) if ( curlight ) then curlight.pos = test.HitPos curlight.style = 6 curlight.r = 255 curlight.g = 255 curlight.b = 255 curlight.brightness = 2 curlight.Decay = 1000 curlight.Size = 256 curlight.DieTime = CurTime() + 1 end end end hook.Add("Think","LittleLight",CursorLight) [/CODE] [url]http://prntscr.com/gt35cm[/url] [url]http://prntscr.com/gt35hf[/url] I don't know if we can do something about that but when the light does something weird, the hitpos.z is not to 0 ... I don't know if we can make something out that fact
Can someone explain the difference between the 'do' keyword and the 'then' keyword in Lua? My friends and I were discussing this and we don't really understand the difference other than one is used for loops and the other if statements. Is that all that really matters or does 'do' do something special?
[QUOTE=Kidd;52746223]Can someone explain the difference between the 'do' keyword and the 'then' keyword in Lua? My friends and I were discussing this and we don't really understand the difference other than one is used for loops and the other if statements. Is that all that really matters or does 'do' do something special?[/QUOTE] [url]https://stackoverflow.com/questions/23895406/why-use-a-do-end-block-in-lua[/url] AFAIK, then doesn't have a use outside of if statements.
I never realized the do-end was separate from loops. But if then also controls scope then why not while(true) then blah end?
[QUOTE=Kidd;52746223]Can someone explain the difference between the 'do' keyword and the 'then' keyword in Lua? My friends and I were discussing this and we don't really understand the difference other than one is used for loops and the other if statements. Is that all that really matters or does 'do' do something special?[/QUOTE] [QUOTE=Kidd;52746252]I never realized the do-end was separate from loops. But if then also controls scope then why not while(true) then blah end?[/QUOTE] There's nothing magical about "do". It doesn't control variable scope, it's just a word that the Lua compiler expects to see in certain places to explicitly separate one section of code from another. If-statements are structured like "if <condition> then <block> end", while-loops are structured like "while <condition> do <block> end". That's all it is. e: all those structures are explicitly defined in the Lua syntax -- take a look at 'stat', where the keywords are in [b]bold[/b]: [url]https://www.lua.org/manual/5.1/manual.html#8[/url] [QUOTE=sannys;52747647]It does control scope. The link melonshooter posted has some examples. Here's a PIL link too. [url]https://www.lua.org/pil/4.2.html[/url][/QUOTE] I was talking about "do" [i]in the context of "while ... do ... end"[/i]. I'm well aware of "do ... end" and my point was that the conceptual block of a while-loop body is what defines the block scope, not the word "do" in "while <condition> do <block> end", which is what he was apparently confused about
[QUOTE=Kidd;52746252]I never realized the do-end was separate from loops. But if then also controls scope then why not while(true) then blah end?[/QUOTE] Because from a grammatically view it makes sense, and I'd guess that's the reason for separating the two. while x then would be incorrect compared to while x do. then-end doesn't make any sense compared to do-end.
[QUOTE=Kevlon;52744036]There's actually a 'full string' arg to the concommand function so this would be faster: [CODE] concommand.Add("svr_cmd", function(objPl, strCmd, tblArgs, strArgs) if(IsValid(objPl) and not objPl:IsSuperAdmin()) then return end game.ConsoleCommand(strArgs.."\n") end) [/CODE] Also I think \n is added internally now, since it doesn't crash anymore[/QUOTE] Oh neat, didn't realize that variable was there, thanks. [editline]4th October 2017[/editline] [QUOTE=MPan1;52744139][QUOTE=Gabs;52744115]But if I replace game.ConsoleCommand with RunConsoleCommand, will it still run on the server?[/QUOTE] Good point, sorry, nevermind[/QUOTE] It will because that script would need to be added to the serverside, not the clientside. RunConsoleCommand will run on whatever realm it's called. The reason I chose game.ConsoleCommand is that RunConsoleCommand takes each argument as a parameter instead of a full string. It simplifies the code for something like this.
[QUOTE=Luni;52746258]There's nothing magical about "do". It doesn't control variable scope, it's just a word that the Lua compiler expects to see in certain places to explicitly separate one section of code from another. If-statements are structured like "if <condition> then <block> end", while-loops are structured like "while <condition> do <block> end". That's all it is. e: all those structures are explicitly defined in the Lua syntax -- take a look at 'stat', where the keywords are in [b]bold[/b]: [url]https://www.lua.org/manual/5.1/manual.html#8[/url][/QUOTE] It does control scope. The link melonshooter posted has some examples. Here's a PIL link too. [url]https://www.lua.org/pil/4.2.html[/url]
Hi guys ! This might be kind of a dumb question but here goes : I'm using host_workshop_collection to download addons but I have no idea where they are going. There's nothing in my addon folder and I can't seem to find them anywhere, yet the server does. Any ideas ?
[QUOTE=Gakuun;52747865]Hi guys ! This might be kind of a dumb question but here goes : I'm using host_workshop_collection to download addons but I have no idea where they are going. There's nothing in my addon folder and I can't seem to find them anywhere, yet the server does. Any ideas ?[/QUOTE] Check ~/garrysmod/downloads/
Nothing in there either, only an empty "server" folder. :/
How would I go for making a freezecam thing? I already figured the move from dead body to killer part, but not how to freeze the view. RenderScene does what I want it to, but it actually freezes EVERYTHING including the HUD. I've cooked this snippet up but it doesn't seem to do the job very well as 3D2D seems to have some weird issues with it and antialias is garbage: [code] local rt = GetRenderTarget("freezecam" .. SysTime(), ScrW(), ScrH(), false) local init = false hook.Add("HUDPaint", "test", function() if not init then render.PushRenderTarget(rt) render.RenderView() render.PopRenderTarget() init = true end render.DrawTextureToScreen(rt) end) [/code]
[QUOTE=Tenrys;52748520]How would I go for making a freezecam thing?[/QUOTE] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/SetObserverMode]Player:SetObserverMode[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Enums/OBS_MODE]OBS_MODE[/url] [CODE]OBS_MODE_FREEZECAM[/CODE]
[QUOTE=sannys;52747647]It does control scope. The link melonshooter posted has some examples. Here's a PIL link too. [url]https://www.lua.org/pil/4.2.html[/url][/QUOTE] I was talking about "do" [i]in the context of "while ... do ... end"[/i]. I'm well aware of "do ... end" and my point was that the conceptual block of a while-loop body is what defines the block scope, not the keyword "do" in "while foo do", which is what he was apparently confused about
[QUOTE=Luni;52748617]I was talking about "do" [i]in the context of "while ... do ... end"[/i]. I'm well aware of "do ... end" and my point was that the conceptual block of a while-loop body is what defines the block scope, not the keyword "do" in "while foo do", which is what he was apparently confused about[/QUOTE] while/if by themselves don't define the block scope, it is the combination of while-do and if-then: the tokeniser doesn't do anything until that entire statement is found and evaluated.
[QUOTE=code_gs;52747868]Check ~/garrysmod/downloads/[/QUOTE] seems like they're in srcds/steam_cache/content/4000/<addon-id>/*.bin when downloading, and srcds/garrysmod/cache/*.gma when unpacked [editline]5th October 2017[/editline] [QUOTE=code_gs;52748625]while/if by themselves don't define the block scope, it is the combination of while-do and if-then: the tokeniser doesn't do anything until that entire statement is found and evaluated.[/QUOTE] I mean if you wanna get unnecessarily technical the block() in whilestat() is what defines the block scope, but in my posts to Kidd I'm talking about grammar and not compiler implementation -- it's not the word "do" itself (in "while ... do", pretend that "do ... end" doesn't exist) that magically defines a block (implying a misconception that the "while <cond>" is somehow separate from the following "do ... end", when instead they're part of a single statement and Lua is very rigid about that), and it's bad and/or confusing for a newbie to try to think of it that way
[QUOTE=Luni;52748627]seems like they're in srcds/steam_cache/content/4000/<addon-id>/*.bin when downloading, and srcds/garrysmod/cache/*.gma when unpacked [editline]5th October 2017[/editline] I mean if you wanna get unnecessarily technical the block() in whilestat() is what defines the block scope, but in my posts to Kidd I'm talking about grammar and not compiler implementation -- it's not the [b]word 'do' itself[/b] (in "while ... do", pretend that "do...end" doesn't exist) that magically defines a block, and it's bad and/or confusing for a newbie to try to think of it that way[/QUOTE] It's not the initial keyword either -- it's the entire statement. His question more pertained to how the then/do keywords actually functioned, and they end the statement.
Is there any way for entity to block/deflect bullets? I made custom armor plate model but the bullets seem to go through. Even double layered physics model is not blocking the bullet.
[QUOTE=cRUSHpl;52748668]Is there any way for entity to block/deflect bullets? I made custom armor plate model but the bullets seem to go through. Even double layered physics model is not blocking the bullet.[/QUOTE] Not by model, but you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityFireBullets]GM:EntityFireBullets[/url] to add in a FireBullets callback to check if your custom entity was hit. If so, you can do your bullet deflections there manually.
[QUOTE=code_gs;52748674]Not by model, but you can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/EntityFireBullets]GM:EntityFireBullets[/url] to add in a FireBullets callback to check if your custom entity was hit. If so, you can do your bullet deflections there manually.[/QUOTE] Ok thanks i will give it a try. Also i will investigate standard gmod construction plates. They seem to block the bullets though they are just models.
[QUOTE=cRUSHpl;52748682]Ok thanks i will give it a try. Also i will investigate standard gmod construction plates. They seem to block the bullets though they are just models.[/QUOTE] Bullets from what? HL2 guns only penetrate glass, all other weapons are completely up to the author's implementation, which can be based on material, prop thickness, or model.
[QUOTE=code_gs;52748710]Bullets from what? HL2 guns only penetrate glass, all other weapons are completely up to the author's implementation, which can be based on material, prop thickness, or model.[/QUOTE] Now i see it. I tested bullet block with standard HL2 weapons and they work as you said. Armor blocks them. As soon as i use other weapon for testing (i now use M9K) my armor model doesn't block them. But still bullets from M9K are blocked by standard gmod plate. I made short video to show this. [URL="https://drive.google.com/uc?id=0BztKOwOGWVOLTDlob2o5QVl2SFU"]https://drive.google.com/uc?id=0BztKOwOGWVOLTDlob2o5QVl2SFU[/URL]
[QUOTE=cRUSHpl;52748742]Now i see it. I tested bullet block with standard HL2 weapons and they work as you said. Armor blocks them. As soon as i use other weapon for testing (i now use M9K) my armor model doesn't block them. But still bullets from M9K are blocked by standard gmod plate. I made short video to show this. [URL="https://drive.google.com/uc?id=0BztKOwOGWVOLTDlob2o5QVl2SFU"]https://drive.google.com/uc?id=0BztKOwOGWVOLTDlob2o5QVl2SFU[/URL][/QUOTE] You're going to have to see how M9K handles bullet penetration and adjust your code or model, accordingly.
[QUOTE=code_gs;52748768]You're going to have to see how M9K handles bullet penetration and adjust your code or model, accordingly.[/QUOTE] Well the only proper way would be to adjust the model. But i still don't know why the gmod plate deflects bullet and my model won't.
[QUOTE=cRUSHpl;52748770]Well the only proper way would be to adjust the model. But i still don't know why the gmod plate deflects bullet and my model won't.[/QUOTE] You can probably find out by looking at the source code M9K and seeing what factor triggers penetration.
Anyone know how I can make a ragdoll sit in a chair entity? I tried to make the chair into a vehicle chair and test with a player but the sit in it backwards and no matter how many times i've recompiled it it stays the same so I want to see a different solution
[QUOTE=blackwidowman;52749098]Anyone know how I can make a ragdoll sit in a chair entity? I tried to make the chair into a vehicle chair and test with a player but the sit in it backwards and no matter how many times i've recompiled it it stays the same so I want to see a different solution[/QUOTE] [URL="http://www.facepunch.com/threads/865528-How-can-I-make-a-ragdoll-quot-sit-quot-on-a-chair"]Same way as back in 2009[/URL]
I'm making my first serverhopper addon, and would like to know how I'd paint text with the amount of players in the servers on the serverhopper? Sorry if this sounds confusing :alien:
[QUOTE=MPan1;52749141][URL="http://www.facepunch.com/threads/865528-How-can-I-make-a-ragdoll-quot-sit-quot-on-a-chair"]Same way as back in 2009[/URL][/QUOTE] I hope you're joking? Why would I pose a ragdoll using the weapon
[QUOTE=blackwidowman;52750030]I hope you're joking? Why would I pose a ragdoll using the weapon[/QUOTE] You cannot make a ragdoll sit in a chair -- ragdolls don't work with activities.
Sorry, you need to Log In to post a reply to this thread.