c0ding

I did some kewl coding over the last few days.

Networked Vars

I had a system in Lua where you could have networked values on specific entities. Meaning you set a value on the entity in serverside Lua and you can retrieve it in clientside Lua. It’s mainly used for display stuff, for example, the hoverballs float at a set altitude. We pass that altitude down to the clientside and draw effects based on how far away from its ideal altitude it is.

This worked well, but internally it was a mess. BaseEntity had 10 ints, floats, vectors and entities on it. Meaning that every entity was carrying a wad of shit around with it even though half of them probably weren’t using it.

So it was eating me up and Helk came up with the solution. Hook the usermessage shit up to Lua and then program a transport system in it. I did it, and it works. I expected it to take a lot more bandwidth, but it’s about the same. There’s no real obvious negative effects anyway.

The entities aren’t limited to x amount of networked variables now, so they can have unlimited networked vars. Plus you can index them by string (previously they were always indexed by int 0-9).

So it’s pretty cool. I hooked some functions to exchange global vars too, so you can be like SetGlobalString( “Title”, “Welcome To The Show!” ) then on the client draw on the HUD, draw.SimpleText( GetGlobalString( “Title” ), … ). Awesome!

Skippy Weapon Prediction

The sent’s were being all skippy. It was calling the weapon’s prediction multiple times with commands in the wrong order. I hacked around it by comparing the time of the command with the last one and returning if it was out of date. This was another thing that had me going “fuck.” – but it’s all good now.

GMDM

All this shit was discovered/fixed while working on GMod Deathmatch. The Lua gamemode I want to put out as a working example of how to make a gamemode (IE making it first and then worrying about weapon models, who is going to do PR and who’s heading up Human Resources). I’m basing it on HLDM, since I love HLDM.

The egon gun. Pretty much exactly the same as the one in hldm. Except with an awful elevator sound.

The tripmines are pretty much the same too, except you throw them instead of placing them. And they’re tea pots.

More videos here, more screenshots here.