Well, let's see. You start out by calling MakeUNIXTime with 30, 0. That function calculates (minute - 30), so that will be 30 - 30, which is 0. So the function will return 0. So in state_entry(), you're effectively saying "expires = 0".
Then you start a timer. The timer fires, and you do seconds = expires - llGetUnixTime(). expires is 0, because that's what it was set to, so seconds will be 0 - something, which is a negative number. That will kick you straight into state expired.
Is that what's happening? The script starts and expires immediately?
There are several ways to fix this. First would be to fix MakeUNIXTime... I think what you want that function to do is to return the UNIX time for the minute/second value passed in. Right now, it doesn't do that, because if you pass in (30, 0), it returns 0. If you want to get the Unix time for 30 minutes later, that function needs to do something like:
integer MakeUNIXTime(integer minute, integer second)
{
integer nowInUnixTime = llGetUnixTime();
integer laterInUnixTime = nowInUnixTime + (minute * 60) + second;
return laterInUnixTime;
}
That ought to fix it. But even this is overkill. If all you want to do is count down, you don't really need the unix time, all you need to do is count down. So...
integer timeLeft;
integer convertToSeconds(integer minutes, integer seconds)
{
return ( (minutes * 60) + seconds );
}
default
{
state_entry()
{
// Calculate how many seconds there are in 30 minutes
timeLeft = convertToSeconds(30, 0);
// You could also do this, since 30 minutes equals 1800 seconds...
timeLeft = 1800;
llSetTimerEvent(1.0);
}
timer()
{
// One second has passed, so the time left is one second less than it was before
timeLeft --;
if (timeLeft == 0)
{
state expired;
}
else
{
// ... Then do all the printing stuff
}
}
// state expired, etc.