You'll want something to keep track of the "state" of an object, in this case how many times an object has been clicked. This is usually done in an instance variable. Every time it is clicked or activated, increment the variable.
On object clicked, set object.clickedcount to object.clickedcount+1
If object.clicked count > lastoption, set object.clickedcount to 0
You'll then refer to this variable when deciding what action to take, or you can pass it to a function as a parameter as lionz suggested.
An advanced trick is to use a conditional expression to loop a counter and reset it to 0, which results in the same as above but within a single event.
On object clicked, set object.clickedcount to object.clickedcount+1>lastoption?0:object.clickedcount+1