Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Variables display in time format?

9 years ago
Hi,
Sorry if this title is bad, couldn't think of anything else. Anyways, is there any way to make a variable display as 05, rather than just 5? I'm making a time system, and when it displays the time, I want it to say something like 06:05 rather than just 6:5

Variables display in time format?

9 years ago
No, there isn't a way.

An alternative is to make a variable for each digit though. So 06:05 would have the variables:
%hoursd1 := 0
%hoursd2 := 6
%minutesd1 := 0
%minutesd2 := 5

That make sense?

Variables display in time format?

9 years ago

It would be a lot of work for little payoff, but you could also do it with On Page Variables. Give me a few minutes for an example...

 

 

Variables display in time format?

9 years ago

Yeah, Killa's works best. Especially with On Page -

Military Time: %%HOUR1%%%%HOUR2%%:%%MIN1%%%%MIN2%%
 

Variables display in time format?

9 years ago
I might just stick to the way I have now, but thanks though. Of course, now I have other bugs to work out. :p

Variables display in time format?

9 years ago
Are you wondering how to implement the clock now that you have to deal with 4 variables rather than two or something?

All you would do is have the extra calculations:

%MIN2 := %MIN2 + 1

IF %MIN2 > 9 THEN
BEGIN
%MIN1 := %MIN1 + 1
%MIN2 : = 0
END

IF %MIN1 > 5 THEN
BEGIN
%HOUR2 := %HOUR2 + 1
%MIN1 : = 0
END

IF %HOUR2 > 9 THEN
BEGIN
%HOUR1 := %HOUR1 + 1
%HOUR2 : = 0
END

IF %HOUR1 = 2 THEN
IF %HOUR2 = 4 THEN
BEGIN
%HOUR2 := 0
%HOUR1 := 0
END

----------------------
Bam, you have a working 24 hour clock script that you could put in the global page script. All you would have to do is Berka's on page script above, or this script (in the global page script after the previous script):

%PAGETEXT := %PAGETEXT + "Current Time: " + %HOUR1 + %HOUR2 +":" + %MIN1 + %MIN2

Berka may wanna give that double take if he can, but I'm pretty sure that's all you'd need. Sorry if that's confusing.

Variables display in time format?

9 years ago

I'd love to use this clock for Chapter 2 of my storygame since an actual game clock would give a much better experience than just using 'Time' and forcing the reader to keep track of what the actual time is themselves. However, how do I set it so the clock only starts from a certain page in the second chapter? And if I want 20 minute intervals, I replace %MIN2 := %MIN2 + 1  with '%MIN2 := %MIN1 + 2' , right?

Also, when I tested the above as a global page script, it said it did not recognise Line 6, Column 7.

Thanks for your help in the other thread earlier by the way,

PS Just a thought, you can set the clock to have a no. of days feature as well, right? I ask because I want the game to end on a 24 hour mark, but of course using a normal 24 hour clock, the player would just die at the start.

Variables display in time format?

9 years ago
"However, how do I set it so the clock only starts from a certain page in the second chapter?"

IF $PAGEID >= X THEN
BEGIN

#PUT CLOCK CODE HERE

END

As long as all the pages that the clock will be on are higher than X, this will work (X being the page you want it to start on). $PAGEID is a system variable, so you don't need to make it. It already exists.

"And if I want 20 minute intervals, I replace %MIN2 := %MIN2 + 1 with '%MIN2 := %MIN1 + 2' , right?"

No, you'd do %MIN1 := %MIN1 + 2, and leave out MIN2 entirely. The clock mentioned before moves ahead by a single minute each page. If you're going by intervals of 20, you don't even need the single minute digit (which is what MIN2 is).

%MIN1 := %MIN1 + 2

IF %MIN1 > 5 THEN
BEGIN
%HOUR2 := %HOUR2 + 1
END

Is all you would need for the minutes (the hours part would stay the same). MIN2 would always be 0.

"PS Just a thought, you can set the clock to have a no. of days feature as well, right?"

Well... Yeah of course you could. Just make another variable called DAYS, and change the last hours segment to:

IF %HOUR1 = 2 THEN
IF %HOUR2 = 4 THEN
BEGIN
%HOUR2 := 0
%HOUR1 := 0
%DAYS := %DAYS + 1
END

"I ask because I want the game to end on a 24 hour mark, but of course using a normal 24 hour clock, the player would just die at the start."

I don't even follow this line of thinking, lol. If the game only lasts a day, how can you count the days? And why would the player die at the start? You can make the time start whenever you want it to.

"Also, when I tested the above as a global page script, it said it did not recognise Line 6, Column 7. Thanks for your help in the other thread earlier by the way,"

No problem. Error would be because I wrote : =, instead of :=

The code doesn't like the space between the colon and equal sign apparently.

Variables display in time format?

9 years ago

OK thanks. I do have one other question (should have thought of it earlier, but oh well): What if I want to set the clock so it only moves forward on certain pages, and not whenever you click something? Basically with my maze part of the game, I want the minutes to add only when a player moves from one 'area' into another area. 

Variables display in time format?

9 years ago
That's a good question for you to think about on your own tbh. Having a complex mechanic in your game is no good if you don't understand how to alter it yourself.

First consider how the clock moves forward now, then think about how you can manipulate it to work differently during those times.

Variables display in time format?

9 years ago

I see what you mean now...

I used the single time variable in the end as it was much easier for me to program, but thanks all the same for the help, I'll definitely try to make the clock work for my next game, whatever it is.