His solicitor, Dave Smith, mitigating, said: “Something which may prove helpful to the court is the motivation behind the offence.

“It is clear that his primary motivation is not sexual gratification.

“My client has long had substance difficulties, this beginning with cannabis earlier in his life.

“The use of that was replaced by use of so-called synthetic cannabis, which is a legal substance, but which is substantially stronger than its organic counterpart.

“In relation to the use of the substance my client has become quite paranoid in the way he views the world and he’s become involved with conspiracy theories, particularly on the internet.

“This offence relates to that, in that it was set against a background of conspiracy theory he found himself occupied with.

“Once he had obtained the items, he accepts that there became a secondary motive as alleged. That wasn’t the primary motive. The Probation Service do have concerns and he will work with them.”

Chairman of the bench Doreen Goode sentenced Wallace to a Sexual Offences Prevention Order which bans him from having contact with any female child under the age of 16 unless given consent, and prohibits him from entering any communal changing rooms unless granted permission by the Sex Offender Management Unit.

He was sentenced to a two-year community order with a requirement to comply with a sex offender treatment programme, and ordered to pay £85 costs, a £180 criminal court charge and £2 compensation for the pants.