Former bus driver Shaun Borrett, 42, targeted children as young as five in sex crimes that spanned 24 years.
During the abuse some child victims were punched and kicked on the genitals, shown pornography and made to take part in sex acts with other youngsters.
Four children were raped by him.
Borrett spent cash on games and consoles to attract victims and sweets and treats to induce them to stay.
A judge told him: “You used alcohol and cigarettes as inducements and to dull the senses of the children you were abusing.”
Lord Beckett said: “I consider it to be significant that your serious sexual offending against young children began when you were a young man and endured into middle age.”
The judge told him he was “highly manipulative” of victims and had exploited children who were vulnerable in many ways and inflicted lasting damage.
He said: “You continue to deny your guilt but I proceed on the emphatic verdicts of a jury who listened to the evidence. You have shown no insight and no remorse for your actions.”
“You have shown yourself to be a risk-taker, a manipulator, a psychological coercer and a serious and persistent abuser of children over a period of 24 years,” said Lord Beckett.
The judge imposed an Order for Lifelong Restriction (OLR) on Borrett and ordered he serve a minimum term, known as a punishment part, of seven and a half years before he becomes eligible to apply for release.
Lord Beckett told him it did not follow that he would be released at the end of that period. He would only ever be freed if parole authorities considered it was no longer necessary for the protection of the public that he be held in prison.
Borrett, formerly of Steading View, Tranent, had earlier denied a string of offences committed in the East Lothian town during a trial at the High Court in Edinburgh but was found guilty of 12 charges of indecent behaviour, sexual assault and rape.
The high risk predator told his trial that in April this year he started drinking and took pills in a bid to commit suicide following an argument about allegations one man had made about him abusing the victim as a child.
He said the tablets were not working and he set off in his car as he did not want to be found. He drove over the Lammermuir Hills to England but a man went to his aid at a layby and took him to a medical practice before he was transferred to hospital and returned to Scotland.
Borrett claimed that his life was over because of the allegations made against him and said: “I am not lying. They are.”
He maintained: “I wouldn’t touch any child. I have never, ever threatened any child in my life.”
Advocate depute Margaret Barron pointed out to Borrett that someone might run away in a bid to escape the consequences of their actions. Borrett replied: “I know why I did it.”
But one of his victims told an eight-day trial that his mother informed him that Borrett had “run away”. The teenager said: “I knew exactly why he was missing.”
The 18-year-old said: “That’s when I realised I needed to come forward.” He spoke to police within days of Borrett’s return to Scotland.
He said he had remained quiet about the abuse he suffered and only spoke to a girlfriend last year. He told the court: “I didn’t want anybody to know. I didn’t want to be embarrassed. I didn’t want to be bullied.”
He said he had wanted to avoid being picked on and added: “I didn’t want to be slagged for being molested.”
The teenager was raped and abused by Borrett when he was aged 10 and saw him carry out sex acts with another boy who was still in primary school at the time.
Borrett was a teenager when he targeted his first victim, who was aged from five to seven, and got the boy to perform sex acts on him and indecently touched the child between 1994 and 1997.
The following year he molested a 14-year-old at a pub in Tranent in an opportunistic crime and later went on to abuse and repeatedly rape a second girl in the town between 2001 and 2006 when she was aged between seven and 11.
He also abused a boy from the age of eight beginning in 2007 and later went on to rape him.
He raped another boy and punched him on the privates when he was aged between eight and nine at a house in Tranent between 2015 and last year.
Another boy was molested, punched and kicked on the genitals and induced to take part in sex acts with other children when he was aged between nine and 11.
An eighth victim, who was aged 10, was threatened that he would be tied naked to a lamppost and another boy was sexually assaulted when he was aged between seven and eight and was touched and kicked on the genitals.
Borrett’s defence counsel Ian Duguid QC told the court: “He is very much considered an outcast in the community.”
He said that Borrett, a first offender, continued to deny his involvement in the offending.
The defence counsel urged the judge to deal with Borrett, who was assessed as posing a medium risk, without imposing an an indeterminate sentence of an OLR.
Borrett was placed on the sex offenders’ register indefinitely.
Sign up to our newsletter: enter your email in the box at the top of this article to get daily updates straight to your inbox.