Formatting a Script

Post » Tue May 17, 2011 4:50 pm

Shot in the dark this,

but has anyone got any vague ideas what the best way to format a getsecondspassed variable is into minutes?

E.g.

1320 seconds (22 minutes), displays as 1320... 1315... 1310... etc. I've tried the following, and it might just be because it's quite late, but...

if questTimer < 1	      set questTimer to questTimer + GetSecondsPassed	   else	     set questTimerTotal to questTimerTotal - questTimer		set questTimer to 0		if timerWorn == 1			showMessage countingTimer, questTimerTotal / 60		endif	   endifend


Adding the / 60 does zilch. It'll be something silly, I'm sure of it.
User avatar
Jonathan Montero
 
Posts: 3487
Joined: Tue Aug 14, 2007 3:22 am

Post » Tue May 17, 2011 12:04 pm

Shot in the dark this,

but has anyone got any vague ideas what the best way to format a getsecondspassed variable is into minutes?

E.g.

1320 seconds (22 minutes), displays as 1320... 1315... 1310... etc. I've tried the following, and it might just be because it's quite late, but...

if questTimer < 1	      set questTimer to questTimer + GetSecondsPassed	   else	     set questTimerTotal to questTimerTotal - questTimer		set questTimer to 0		if timerWorn == 1			showMessage countingTimer, questTimerTotal / 60		endif	   endifend


Adding the / 60 does zilch. It'll be something silly, I'm sure of it.



On the showmessage line, I don't think you can have an expression - just the variable. So you might do it on this line:

set questTimerTotal to (questTimerTotal - questTimer)/60


or use another variable for minutes if you need to leave the questTimerTotal variable in seconds.
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Tue May 17, 2011 2:19 am

That's correct, expressions can't be used as function parameters.

You'll want to use an integer variable to store the number of minutes, truncating any extra seconds via integer division, and if you want seconds as well you'll need to use another variable (probably another integer) to store the extra seconds:
set questTimerTotal to questTimerTotal - questTimerset iMinutes to questTimerTotal / 60set iSeconds to questTimerTotal - (iMinutes * 60)

Cipscis
User avatar
Queen of Spades
 
Posts: 3383
Joined: Fri Dec 08, 2006 12:06 pm

Post » Tue May 17, 2011 4:14 pm

That's correct, expressions can't be used as function parameters.

You'll want to use an integer variable to store the number of minutes, truncating any extra seconds via integer division, and if you want seconds as well you'll need to use another variable (probably another integer) to store the extra seconds:
set questTimerTotal to questTimerTotal - questTimerset iMinutes to questTimerTotal / 60set iSeconds to questTimerTotal - (iMinutes * 60)

Cipscis


That gets the message formagtted indeedy :) Thanks guys. The only thing is however, it displays
22 minutes remaining...
only for the next message to indicate -0. Assuming I need to write some incredibly complicated script here that sets up a timer for the seconds as you've stated Cip?
User avatar
Iain Lamb
 
Posts: 3453
Joined: Sat May 19, 2007 4:47 am


Return to Fallout 3