A man who shoplifted and broke into an abandonedbuilding blamed a recent ban on legal highs for his actions.
Liam McGowan had spent half of his annual £6,000 income on medication to treat an undiagnosed condition.
He purchased the drugs online but was stopped from doing so when the Psychoactive Substances Bill came into force last month.
This affected his health and led to the 31-year-old committing offences for the first time, Kirklees magistrates heard.
McGowan addressed the Huddersfield court directly on his condition - after his solicitor was forced to withdraw his representation when he accused him of not explaining it properly.
He had pleaded guilty to criminal damage and three charges of shoplifting.
The court heard that McGowan, of no fixed address, broke into Crown House in Southgate yesterday.
A security officer attended at the disused office block following the activation of an alarm.
McGowan was inside, having broken a window to get in.
He told him: “It was me, I’ve been here all night sheltering.”
McGowan also admitted stealing sandwiches and other food from Sainsbury’s in Market Street between May 21 and June 11.
In his brief mitigation before he was forced to excuse himself, Arshad Khan explained that McGowan’s mother injected herself with amphetamines throughout her pregnancy.
As a result McGowan’s brain is ‘miscalibrated’ and he suffers from symptoms including an increased appetite and low moods.
These are controlled by medication not available on the NHS because it is not clinically recognised.
He told magistrates that McGowan was stopped from buying this legally online when the bill was introduced.
Mr Khan said: “He was unable to purchase these items, this has affected his health and as a result he’s committed these offences.”
McGowan, who appeared in custody, told magistrates that he was at a disadvantage from day to day.
He claimed he stole when he was left with little cash and feeling twice as hungry due to being unable to control his symptoms.
McGowan said he broke into the building after his own flat in Springwood burnt down.
Magistrates asked for a full probation report prior to his sentencing.