Garry's Mod Logo
schedule 06 December 2012
Devblog

Garry's Mod - Update 153

I sent the update to Valve. It’s time to go into that drawer and find that old kinect that you haven’t thought about for 2 years - we’re gonna have some fun.

Kinect Support

You can use the kinect to control ragdolls in-game. This works in multiplayer, so you should be able to dance with your friends. Best of all - it’s soo easy! There’s no installing custom drivers or manually placing dll’s in specific folders.. There’s just two steps.. go here to find out how to get started. You can overlay the kinect camera by adjusting the settings that should appear on the menu screen, on the bottom right.

Added Fog Edit

To edit the fog open the entities tab, choose Editors and spawn the Fog Editor entity. A grey box will appear in front of you. Hold down C, right click on it and go to “Edit Properties”. Now you can have fun changing those settings. If you remove the entity it will reset the fog to normal. If you save your game with the fog entity still around - it will be applied for anyone that loads it.

Added Sky Edit

The Sky Editor entity works pretty much the same as the Fog Editor entity.. but it will only work on maps with the shader based sky, like gm_construct and flatgrass. If there’s enough demand for it I’ll make it work with other maps in the future.

Added Sun Edit

This works similar to the two above entities - except you need to point it in the direction you want the sun to be. For this to work the map needs to already contain an env_sun entity.

Steam Screenshots

Any screenshots you take are now integrated into the Steam Screenshots. They will still be saved in your screenshots folder - but will also be available in the Screenshot Manager for easy sharing/uploading/viewing.

Fixed rope stretch on load

This has been quite a long standing bug with rope constraints. Over the years it has had a number of workarounds around the real problem - and never really been fixed. I do not understand why it was never fixed properly. But now it is - so we should all be happy :)

Fixed errors on changelevel

Some dedicated server owners were reporting an error when calling changelevel. The error manifested itself in NULL entities not actually being NULL. The engine would push a NULL entity to Lua - and it would be a function, or a string, or something else random. I found the cause and it should now be fixed.

Fixed Linux Dedicated Server

Oh man. It seems like over the last couple of weeks I’ve fixed one thing and broken another - constantly. Well linux is fixed again. In the code changes recently a lot of the libraries had _srv added to the file name - so they were different from the client linux versions. I followed this standard and lua_shared_srv.so was created.. but the code was still referencing lua_shared.so.

More Colorable Player Models

The Barney and Metropolice player models are now colourable.

Snapping

GMod 12 had a feature that let people adjust their snap degrees. You enable angle snapping while holding shift when you rotate an object with the physgun. You can now adjust the angles they snap to using gm_snapangles, which is a clientside var - so you can use your customised value in multiplayer too. I also added gm_snapgrid - which snaps your props to a grid. It defaults to 0 - because we don’t wanna snap anything to a grid.

Fixed shader library error on dedicated server

There was an issue where the windows dedicated server would try to load the osx shader library. Yeah, I know, don’t ask me how or why. This popped up a modal dialog alerting the server owner of this - and needed someone to click ok.

Fixed crash when loading particles

If a script tried to load an uncache’d particle clientside it would result in a crash. This is now fixed.

Duplicator hides spawn effects

You may have noticed that when using the duplicator to spawn a large item, you’d get a second of really low fps. This was because the spawn effects, and freeze effects were drawing for each prop. This is now undone and we have silky smooth duping again!

Added Player:GetPlayerInfo()

This clientside function returns a table of data about the player. It is pretty much returns the same data as the engine call engine->GetPlayerInfo. This was added as a way for Lua coders to get access to the file that contains the player’s spray paint decal.

Added engine.LightStyle( int, string )

This is a direct binding to the function “engine->LightStyle”. This was requested. It allows you to change the default light style - so you can make lighting lighter or darker. You’ll need to call render.RedownloadAllLightmaps() clientside to refresh the lightmaps to this new colour.

Added render.RedownloadAllLightmaps()

This is a direct binding to the engine function R_RedownloadAllLightmaps. This refreshes all of the lightmaps - which will implement any of the light changes done by engine.LightStyle. Note that this might be tricky because LightStyle is serverside, and this function is clientside.

DHTML:AddFunction can return

Previously functions that you added to a HTML control with AddFunction couldn’t return values - so you’d have to fire something back into the panel. I hated that - now you can return a simple type (number, bool, string). With great power comes great responsibility - it’s technically possible for you to create an infinite loop. So be careful.

Added hooks SetupWorldFog, SetupSkyboxFog

These hooks allow you to alter the fog in realtime. You need to use the render.Fog commands to setup the fog you want - then return true - to tell the engine that you’ve set it up. The SkyBox hook passes a float describing the skybox scale.

World Clicking improvements

The world clicking (clicking on the world from the context menu) has been improved, so that if you’re dragging a gui control it doesn’t activate. Also - if you’re dragging on the world and mouse over a gui panel - it will no longer interrupt the dragging until you let go of the mouse button.

Fixed NPC names

NPC names were showing the entity name instead of their actual name. This is fixed.

Fixed SuperDOF click to focus

In previous versions of Super DOF you could click somewhere on the world and it would focus to that distance. Somewhere in the last few updates I managed to break this. It’s fixed now - and I added a spark effect to make it clear that it’s focusing.

Entity:SetKeyValue improvement

Previously when calling SetKeyValue on a serverside entity’s networked value, the new value wouldn’t be marked as changed and sent to the client. This lead to confusing scenarios where the value was changed on the server - but remained the same on the client. This should now be fixed.

Added Entity:AddCallback( name, function )

This adds a callback to a specific event. The only available event right now is “OnAngleChange” - which is called when the entity’s angle changes. This is a new system I’ll be using from now on - so that instead of needlessly calling empty functions from entities all of the time - they’ll only get called when the entity has requested it. This also has the benefit of working on non-lua created entities.

Added render.GetResolvedFullFrameDepth()

Since the TF2 Pyro update the engine has been able to render a full depth buffer. This returns the texture into which the depth buffer was (or was not) rendered. The special depth texture is only rendered if we return true to  the “NeedsDepthPass” hook.

Added NeedsDepthPass hook

Returning true to this hook will cause it to render the above Depth Buffer for this frame.

Added motionsensor library

The motionsensor library consists of functions and utilities to interact with the kinect. You can find some usage information here.

Added Vector.AngleEx( vec )

Vector.Angle returns the angle of the vector, but it always assumes that up is [0, 0, 1]. AngleEx takes a second vector - which it uses as the ‘up’ for the returned angle.

Added Entity:SetRagdollBuildFunction( func )

This was added for the kinect functionality. A function is stored on the ragdoll which is called every time the entity resolves the physics of it. In this function you are able to call SetRagdollPos and SetRagdollAng to modify the angles and positions of the ragdoll bones - totally overriding the physics. This is provided this way because updating in an entity’s Think function doesn’t update the positions fast enough.

Added Entity:SetRagdollPos( boneid, vector )

Sets the position of the ragdoll’s bones. This function is useless outside of the RagdollBuildFunction.

Added Entity:SetRagdollAng( boneid, angle )

Sets the position of the ragdoll’s bones. This function is useless outside of the RagdollBuildFunction.

Added Entity:RagdollStopControlling()

When you call SetRagdollPos or SetRagdollAng internally we create some physics controllers, that gently move the physics objects towards those positions. We use a physics controller instead of setting the position directly so that it reacts nicer to other physics objects (it would just go through them with little interaction without this). This function turns off those controllers - and reverts the ragdoll to its old fall to ground state.

Added Entity:RagdollSolve()

This function is to be called in the RagdollBuildFunction. It normalizes the ragdoll by ignoring the positions you provided - and working out the correct positions of everything using only the angles. This stops the ragdoll appearing stretched in any way.

Added debugoverlay.Axis( pos, ang, size, time, ignorez )

The debugoverlay library provides a bunch of visualization tools that developers can use while developing. This function draws a three way axis at the specified place, for the specified duration.

Added DebugInfo( line, string )

You know how Lua errors used to show up on the top right of the screen? Well that wasn’t meant for showing Lua errors. This function gives you direct access to that - so you don’t have to keep spamming a variable to the console.

Hook library cooperates with entities

You can now pass an entity or panel as the second argument to hook.Add. This will cause the hook to be destroyed when the entity stops being valid. It will also pass the entity/panel as the first argument in the function (so you can use it as self). This works with any object with an IsValid member function. This should prevent awkward hacks like naming the hook as the entity id and adding logic to remove the hook when the entity dies.

Trace Additions

Any returned traces now contain “SurfaceProps” - which contains a number representing the properties of the hit surface. This was a request.

Added util.AimVector( ang, fov, x, y, w, h )

A utility function to work out an aim vector from an angle, fov, and screen coordinates. Unlike other similar functions this isn’t paired to the player or current view or screen size in any way.

Added hook CreateClientsideRagdoll( ent, ragdoll )

This hooks gets called clientside when an NPC becomes a clientside ragdoll. This is usually called when the NPC dies - and the passed ent will likely be removed the next frame. You can get when an NPC becomes a serverside ragdoll using the already existing CreateEntityRagdoll hook.

Servers will need to be restarted before you can join them.