Diego Donamaria/Getty

Elon Musk wants to save humanity.

That is, in part, what his quest to establish bases on the moon and Mars is all about.

"There's likely to be another dark age," he told the crowd Sunday at the South By Southwest festival. Particularly if there's another world war in Earth's future, he said, we need to make sure "there's enough of a seed of human civilization to bring human civilization back."

While Musk was quick to clarify that he's not exactly making a prediction, he does feel we need to get going before World War III rolls around.

This was just some of the ground Musk covered with moderator Jonathan Nolan, co-creator of HBO's "Westworld." Musk,the founder of multiple companies including SpaceX, Tesla and the Boring Company, is tackling some of the biggest challenges and technological advances of the modern age, like space travel and autonomous vehicles.

He made a two-day stop at SXSW in Austin, Texas, to talk about his work. He also appeared Saturday at the end of a panel with the cast and show creators of the HBO series "Westworld."

Now playing: Watch this: Elon Musk's Tesla Roadster: Milestone or space junk?

Musk knows a thing or two about breaking free of Earth's gravity. Along with people like Amazon's Jeff Bezos and Virgin Galactic's Richard Branson, he's leading a drive toward a near future of commercial space travel and the industrialization of outer space.

In recent weeks, his SpaceX has been busy. It thrilled the world with the launch of the Falcon Heavy, the most powerful rocket to lift off from US soil since the Saturn V of NASA's Apollo era. It also sent two prototype satellites into orbit to test a system for beaming broadband internet to Earth, in a plan that could involve more than 11,000 satellites by the middle of the next decade. That's in addition to its regular workload of carrying gear aloft for NASA and for other countries.

Musk also has a vision for a Mars colony, with 1 million humans populating a self-sustaining outpost somewhere between 40 and 100 years down the road.

But despite his musing about dark times ahead, Musk's not just thinking doom and gloom. He's also looking forward to the night life on the Red Planet.

"Mars will need everything from iron foundries to pizza joints to nightclubs," he said. "Mars should really have great bars."

Getting to that point hasn't been easy. Musk said that, early on, SpaceX almost didn't survive. He had to borrow money from friends to keep going.

"For SpaceX, the first three launches failed. If the fourth launch had failed, we would have been dead," he said.

Mars should really have great bars. Elon Musk

The big focus right now is building the spaceship known at the moment as the BFR. (Read into that what you will, he said.) Musk wants to see the rocket take short flights up and down -- SpaceX is big into catching and reusing rockets -- in the first half of next year.

There's also the topic of artificial intelligence. Musk in the past has expressed concerns that AI, the science of getting computers to think for themselves, could bring about humanity's downfall, and Sunday's Q&A was no different.

"AI scares the hell out of me," he said, telling Nolan that while he typically isn't a fan of regulation, he feels AI is more dangerous than nuclear weapons and it's not like we let just anyone build nukes.

It's important to make sure the dawn of AI is one that's symbiotic with humanity.

Whether an AI-induced third world war is what drives us off the planet, he didn't say.

But hey, the salvation of humanity might just come with Martian pizza joints.

Blockchain Decoded: CNET looks at the tech powering bitcoin -- and soon, too, a myriad services that will change your life.

'Alexa, be more human': Inside Amazon's effort to make its voice assistant smarter, chattier and more like you.