For writer/director Peter Farrelly, it was love at first laugh when he read the screenplay for "Ricky Stanicky," his new R-rated comedy.

But it took more than a decade to get it made.

"I'm used to it," says Farrelly, who won Academy Awards for best picture and best original screenplay with "Green Book" in 2019. "Like, 'Dumb and Dumber' took five years. 'Something About Mary' took 10 years. 'Kingpin' was an old script."

In "Ricky Stanicky," which arrives Thursday on Prime Video, the title character doesn't actually exist. Since boyhood, three close friends played by Zac Efron, Andrew Santino and Jermaine Fowler have blamed the imaginary Ricky Stanicky for whatever scrapes they got into. As adults, Ricky's been their excuse to skip out on wives, partners, friends and colleagues.

But when the boys leave town for a few days to visit Atlantic City and Santino's pregnant wife goes into labor weeks early, suspicions arise. The guys hire Rock Hard Rod, a failed actor played by John Cena, to show up as Ricky. And he's great. The only problem? Rod doesn't want to stop being Ricky, and now the lads have an entirely different problem on their hands.

In an interview edited for length and clarity, Farrelly talked about casting Cena and Efron as his leads and the 30th anniversary of his debut movie, "Dumb and Dumber."

Q: What was it about this screenplay that made you go, 'Oh, yeah, that's a movie for me'?

A: I guess it came to me like 15 years ago, maybe more. I felt like it was completely original, this concept of making up a character that you blame things on.

Q: John Cena is great in this. How'd you pick him to be your Ricky?

A: Someone said, "Have you seen 'Peacemaker'? You're not going to believe how good he is." I thought I'd watch an episode. I ended up watching a bunch of them. And I was just astounded at his courage as an actor, and how funny he was, and how committed. As soon as I saw it, I was like, "That's Stanicky." He's world-class funny in this.

Q: You worked with Zac Efron on "The Greatest Beer Run Ever," but what made you pick him for your straight man here?

A: I would call it the leading man. He's the guy in the middle. He's, to me, like Tony Curtis in "Some Like It Hot." He's the guy who, if you don't have that guy, it all falls apart. You need him.

Q: This movie has sort of been billed as a return to the kind of raunchy R-rated comedies you and your brother Bobby got your start with. Do you see it that way?

A: There are certain similarities, definitely. It's an R-rated comedy, and we did go for it. But it wasn't an attempt to be like, "Oh, let's go back to that." None of my movies have been an attempt. It's just the one that comes to me at that moment.

Q: This year is the 30th anniversary of "Dumb and Dumber." What did you think you had with that film before audiences embraced it?

A: I thought it was hysterical, honestly, for years and it wasn't getting made. I just remember thinking, "They're wrong, I'm right." I felt that and my brother, too, and Bennett Yellin, who we wrote it with.

I had a roommate back then, like 33 years ago, who would come home at night, at like 2 in the morning. He'd bring home five, six people, and he'd say, "Hey, read your script." I would read them the entire movie from beginning to end. And I'd have them on the ground, like howling. They would be laughing their butts off. And that's hard to do with a script.