Sometimes replacing gambling habits with a new one doesn't really work out as planned, you can come up with something to distract yourself from gambling but this isn't really a permanent solution to gambling addiction. You can avoid the urge to gamble when you get involved with other things but there are situations where you might end up falling back to it. The permanent solution is to inculcate self-discipline
I believe it's a continuous process. You may not succeed overcoming the temptation for gambling on the first attempt, but even if you fail once, it doesn't mean you should give up. Try again, over and over, and progress will be spotted. It happens slower for some and faster for others, but fact is that everyone can do this with some effort and as you said: discipline.
Discipline is the key when motivation goes away and there isn't much hope left. Discipline keeps you on the track when the situation looks dire. So it's important to develop it in daily basis.