From left: Martin Freeman, Paddy Considine, Simon Pegg, Nick Frost and Eddie Marsan go on the bar crawl to end all bar crawls in “The World’s End.”

Edgar Wright is a sneaky guy. In “The World’s End,” which opens Friday, the British writer-director takes a sci-fi story about killer robots and slips in commentary on the temptations and dangers of nostalgia, the McWalmart corporatization of our world, and the possibly-too-integral role of technology to modern life. And it comes out funny.

Slyly serving up commentary on top of story is exactly what Wright did in the two other films he made with actors Simon Pegg and Nick Frost — 2004’s “Shaun of the Dead” and 2007’s “Hot Fuzz.” Though it didn’t start out that way.

“When we first started thinking about ‘Shaun of the Dead,’ we just wanted to make a zombie movie because we were passionate about that genre,” Wright says. “But then we did it through the framework of the romantic comedy. And I think, having done that, you realize that the best sci-fi films, the best horror films, the best fantasy films are metaphors for something else.”

So “Shaun,” affectionately known as a “zom-rom-com,” took on the often emotionally dead state of modern life; “Hot Fuzz” was a cop film that contrasted the hyperbolic violence of action flicks with real-life brutality in a small town.

“The World’s End” is a darker film (but still funny; don’t worry) that takes on progress itself — both what happens personally as we age and, on a more macro level, the commercial homogenization of pretty much everything.

A group of now-grown high school friends, led by man-boy Gary King (Pegg), take a break from their adult lives to go back to their little village to complete a drinking quest that involves downing a pint in each of 12 pubs, the last of which is The World’s End. The fun is interrupted when the group has to fight off an evil force out to make humanity perfect (which is to say, not human at all).

“One of my favorite movies is ‘American Graffiti,’ ” Wright says. “It perfectly captures that summer that’s all, ‘We’re gonna be friends forever!’  And then, no, cut to 20 years later, two are dead, one is an insurance guy, and one has fled to Canada. We wanted to take that ‘where are they now?’ thing and make it into a movie.”

With the exception of Gary, the members of the group are settled, responsible adults. Until the beer kicks in, which is when the story really starts careening around.

“We wanted to mirror a night of drinking, which is quiet at first, then silly, then boisterous,” Wright says. “Then angry, then a bit maudlin, then stupid again. And then blackout.”