// Use this script on a guiText object to have status messages
// Just call messageDisplayerObject.DisplayMessage("hello") and you'll
// get a line of self disappearing messages.
 
private var messages = new Array();

function Start(){
    
    
}

function DisplayMessage(message) {
        
        messages.Add(message);
        UpdateDisplay();
        Invoke("DeleteOldestMessage", 3);

}
    
function DeleteOldestMessage() {
        // The following "if statement" protects from this function
        // getting called by SendMessage from another script and
        // crashing.
        if (messages.length > 0)
        {
            messages.Shift();
            UpdateDisplay();
        }
    }
    
function UpdateDisplay() {

        formattedMessages = "";
        
        for(l=0;l<messages.length;l++) 
        {
            formattedMessages += messages[l] + "\n";
        }
        
        guiText.text = formattedMessages;

}
