Office Progress

Our toilets got finished this week. This makes me happy because the toilet we were using downstairs was totally horrible to use. And now we can get rid of it!

Weirdly, the upstairs toilets were the first thing we designed, back in September 2012. Here’s the sketchup.

Bathroom

Bathroom-3D

Bathroom-3D2

We’ve made a few changes since then. We added a urinal.. (which is probably wrong for unisex toilets – but it’s done now!). And we added a bunch of lockers on the right to fill out that space. And lime green is our favourite colour.

2013-04-12 20.54.35

Our kitchen is almost finished too. We just need skirting board and carpet.. and some tables.. and chairs.. and a TV.

2013-04-12 20.57.32

There’s seven of us in the office now – and there’s two more people starting soon!

It’s getting exciting!

Learning Unity

Our new project is going to be coded in Unity. Why? Well, as game developers we should be making games, not engines. This engine is done. It works. It works better than anything we could code. It works on more platforms than we could ever hope to support. It has more third party addons/plugins that you could ever hope for. That’s why.

There was only one problem. I was a Unity virgin. I have never coded in it. Ever.

So on Sunday I printed a bunch of crap out. Pretty much anything that was a PDF I could find – that mentioned coding using c# in unity.

http://download.unity3d.com/support/…Essentials.pdf
http://docs.unity3d.com/Documentatio…ngTutorial.pdf
http://www.rebelplanetcreations.com/…eInUnity3D.pdf
http://www.csit.carleton.ca/~arya/ds…y_Toturial.pdf

Now, I’m a good enough coder to know that some of the stuff they do in the last two tutorials is dubious. But they explain the basics of the update loop, collisions, entity queries etc. So now I know how to code in Unity.

It all clicked into place.. and now I’m pretty sure I could make anything in it. It surprised me how easy it was.. like – that’s it? And the more I thought about it the more I realised yes, that’s all we need.

So between all the other junk that’s happening I’ve been plugging away at it and come up with stuff for the new project. Here’s what I made yesterday.

image

I am having lots of fun!

New Project

So we started working on the new project in the office. It’s very much planning right now.. which I am enjoying a lot more than I thought I would. I’m enjoying coming up with back stories and characters – which I previously thought of as a distraction from the actual game creation process.

It’s one of those things where we’re talking about it – then looking at each other confused.. like.. “why hasn’t anyone every done this before? Are we crazy? Has it been done?”. That makes me think we’re on the right track.

I hate to get all Peter Molydeux about it.. but this game is more of a strategy than a game. If it works out perfectly you won’t ever play it.

Nextbot & Coroutines

I’ve made a bit of progress binding the Nextbot stuff.. despite not talking about it.

When I was designing how it should interface with Lua I started off mimicing how it worked in the engine. After a few good sleeps I decided that it wasn’t the way to go. It’s coded like that in the engine because of the limitations of C++. We don’t have these limitations in Lua – so lets try to use that to our advantage.

So I decided to use coroutines. First of all let me get this out of the way. Coroutines aren’t threads. They don’t really offer any speed benefits. A more accurate way to imagine them is as a function that you can pause and resume at any time. So imagine you’re writing a script that prints text.. you could do something like this.

image

So where before you would use timers or whatever to achieve this.. your code is instantly a lot simpler to follow.

This is good for a lot of stuff in AI because a lot of the actions happen in a timed order. You do one thing, then you do another, then another.

Here’s one I made earlier. This guy is very simple. He tries to walk somewhere. Then he sits down. Then he gets up and tries to run to a good hiding place. The code is just as simple.

image

Obviously I don’t expect people will code their AI in one function, but this gives you an idea of the simplicity of this. I imagine in reality you’ll have functions like TryToFindPlayer(), AttackPlayer() and Flee(). Or more realistically a single function called ThrowMonitorAtPlayer().

Airplay To Room

When I go in the shower I like to listen to music. All my music is on my phone. So I tend to listen to it via the phone speaker – which is shit. I bought a dock that charged via USB – and it was pretty good – but you have to charge it so fuck that.

So ideally I’d have speakers in the wall or ceiling and be able to airplay to that room from my phone. That shouldn’t be too hard – right?

So for about £150 the room (give or take because you gotta buy a couple of cables) the shower room should play music for me. That’s probably about what you’d pay for a half decent dock – but it’s more awesome because you’re building it yourself!

2013-03-27 17.12.52

I set up a test to make sure it all worked. It couldn’t be much simpler. First set the airplay up to get on the wifi network and give it a name (I named it “Upstairs Shower”. Then plug it into the amp using a 3.5mm jack. Then wire the speaker to the amp. I’m using big grey mains electric cables just because it’s what I have lying around – and cable is cable.

2013-03-27 17.47.33

Then send some music to it via the iPhone/iPad/Mac/PC!

2013-03-27 17.47.47

And bam! Music!

The speakers are decent. I’ve only tried it with a single speaker so far, and the volume is great – but there’s not much bass. Turning the bass up too much on the amp gives some popping. But I’m having a shower – I’m not opening a nightclub in there.

I haven’t totally decided yet – but I think I want a volume control on the wall. You can adjust the volume with the phone but I don’t want to have to do that every time (I haven’t tested it – each airplay device might remember its own volume so you might not have to).

So wiring the volume control up is easy. It doesn’t need any power – you just put it between the speakers and the amp.

2013-03-27 17.56.03

The intention is to hide the amp and the airplay in the loft and never have to mess with it every again, then have the volume control on the wall.

2013-03-27 18.01.51

This amp is probably overkill for what I’m using it for – but it does what I need it to do, the price is right and it’s a nice size too.

So now all I have to do is actually cut our holes and put it where I want it!

Resellers

There’s something I don’t understand about the sale of software. Why do companies have resellers? Why do they want you to buy through their resellers?

It’s usually the case with expensive software aimed at businesses. Like 3D Studio Max, Photoshop, Unity3D or XProtect.

Why would we want to buy it via a reseller? Why would we go to their website to buy the software – then decide that we want to buy it through another company who is probably going to charge us more for the same thing?

Is it some out-dated thing that hasn’t properly died yet but will quite soon?

Steampipe Looming

So Valve are converting all their games over to Steampipe. The word on the street is that DoD:S is going to be converted for proper on Monday. I am not sure whether this is just DoD:S or CS:S etc too.

So for GMod players this means that the content will become unmountable. You won’t be able to play with DoD:S maps or models in GMod.. until I release an update that makes it compatible. I have got that patch ready but I don’t really want to push it out until it all goes live on Valve’s end so I can make sure it works before I flush it.

As for GMod’s move to Steampipe.. I think it’s a bit of a sore-point a Valve. The licensee code server hasn’t been updated for a few months. But they’re working on that. Once that’s updated I’m sure I will have a lot of merging to do to move to the new gcf free system – then I will try to get converted to Steampipe asap.

On a related note I had emailed Mike Durand about a month ago about the code not being updated (I think licensee’s were mainly his responsibility). It turns out that he was fired (or quit) in the Q1 cull. Like everyone else, I don’t know why all these people got fired from Valve – it’s none of my business, but I’d like to say that I was sad to hear that Mike had been fired – he had helped me out a lot over the years with Source engine and licensee server problems. His absence isn’t going unnoticed :(

Coroutines

This week I have managed to get coroutines working properly in Garry’s Mod. I am almost positive that no-one cares about coroutines but maybe that’s because they’ve never worked properly?

The problem was that coroutines create a new lua_State. But my main Lua class stores the main Lua state and almost all of the bound engine functions use that state. So when you call them from a coroutine it uses the wrong state and the world explodes.

So I made it so that each bound function creates a LuaStateBlock class, which sets the state when its constructed but then sets it back when it’s destructed. This worked great except for one huge thing. If you error out in a coroutine the world explodes.

This is because when you error in Lua it jumps to another point in code – and doesn’t call the constructors! You can get around this by compiling it as c++ instead of c apparently. But I’m using LuaJIT and I didn’t want to fuck shit up that much.

So my solution is to just never set the state back. Then any call to lua_call/lua_pcall I store the state before and restore it afterwards. Job done, coroutines work fine!

tl;dr; fixed something no-one cares about

Recruiters

We signed on with a couple of recruiters to try to find decent programmers.

It feels a lot like a dating service. They send us an email with the candidates vital statistics and try to explain why they think it will work between us. If we tell them it won’t – they try to convince us that it will.

It’s working out alright so far. We’ve had a couple of good leads.. It helps that the recruiter doesn’t get paid unless we hire someone I guess.

All that said – we don’t have to pay the recruiters at all if they don’t introduce us. So if you’re a decent programmer, live in or want to move to the West Midlands (England) and want to work for us then shoot me an email to [email protected]

Writing a Wiki Bot

As part of the wiki re-fuckulation process a month back I had to move and reformat a bunch of pages. So I went about writing a wiki bot.

If you already have good knowledge of PHP this is about a billion times easier than it sounds due to a useful little library called wikimate. Its github page speaks for itself, it’s incredibly painless to read page text, set page text, delete pages etc.

So as an example.. one of the fucked up things about the old wiki is that it didn’t use categories. All of the functions were painstakingly listed on a page. So if you removed or added a function you had to edit this index page too. That’s not how a wiki is meant to be indexed. So I went about getting all the listings on those pages and converting them to a new template, so they would be categorised properly and also be editable via a form.

When I’m posting this code I’m now showing you great coding – I’m showing you code that got shit done.

image

So this function looks on the Libraries page and splits it by newlines – so that $lines is an array of lines. Then if a line contains “{{Lib” it trims shit off, splits it by | and calls ConvertLib.

image

ConvertLib does pretty much the same thing. It gets the library’s index page, goes line by line looking for LibraryFunc. Then it splits by | and calls Process.

image

Process is kind of a big boring function, so I’m splitting it into sections here. This part gets the target page. If it already exists then we already did our work, so it bails. If not it get the source page. This is the page we’re gonna be reading and converting to the target page.

image

It reads the page contents into $text

image

Then it tries to find the information we need for the new page. This looks more complicated than it is. It’s basically trying to find text between two other pieces of text. There’s a bit of fucking about to get this to work properly.. This is probably where regex works well – but who wants to learn how to use regex – right?

image

Once we have the info we can build $out – in the format that we want.

image

The arguments were stored in a really shitty way under a single template (Arg1Name, Arg2Name, Arg1Type, Arg2Type blah blah). In the new system we store the arguments unnumbered under the Arg template – and fuck about adding numbers in javascript after the page is rendered.

image

The final thing is to set the text of the new page, and delete the old one. We set the delete reason on the old page so future generations can figure out why we did what we did.

image

How was I running this? Well you just install PHP and then you can open a command line and run “php.exe convert_libraries.php”. You don’t need to go through the trouble of uploading to a host and running it in the browser.

I had lots of fun playing with this stuff and I think it has made the wiki much friendlier to edit! So everyone wins!