you could have another variable that is set to 1 when the entity is doing something then when its done it is set to 0.

Code:
Var Busy
var random

//code that gives the variable "random" a value

Function random1
{
busy = 1
//code for random actions
busy = 0
}
if busy == 1 && random = 1
{
random1()
}




Wait, there isn't a "Make My Game Now" button?