TimeSpan why are you being difficult?

Question updated, 1/17/12 11:30 am EST.

What i am trying to do is to make the pet’s hunger(or food) decrease every 12 hours

so the user/player can feed it every now and then.

any help would be much appreciated.

var monsterCurrentHunger: int = 100;
var monsterMaxHunger: int = 100;
var hungerTimerStarted: boolean = false;
var monsterAlive: boolean = true;
var saveTime: System.DateTime;
var passedTime: System.TimeSpan;
var hungryTime: System.TimeSpan; // need to make this into a constant of 12 hours

function Update () {
	
	// recording the timer or start point
	if (hungerTimerStarted == false){
	saveTime = System.DateTime.Now;
	hungerTimerStarted = true;
	}
	
	// once timer started 
	if (hungerTimerStarted == true){
	passedTime = System.DateTime.Now - saveTime;  
		// every 12 hours hunger lose 10 point.
    /*error: This code here is what i want to do and don't know how to do it.

1, how to create a constant timespan of 12 hours? (the hungryTime var on top)

2, how to do the 3 line below:

*/ //error msg end

      if (passedTime => hungryTime) {

      monsterCurrentHunger -= (10 * (passedTime/hungryTime));

          hungerTimerStarted = false;

      }
	}

}

I answered a very similar question a while ago regarding real time integration with games and affecting “hunger” =P

Dewald117’s solution seems a great one. This would solve the first error. About the second error of yours,

monsterCurrentHunger - (passedTime).Day * 20;

doesn’t seem a legal statement (that’s not an assignment). Would you say

monsterCurrentHunger -= (passedTime).Day * 20;

, maybe?