Number of posts : 6 Location : totally-not-suspicious cave Humor : If you only like me because I am "funny" then I am going to become "the Joker". Adventure Points : 3 Registration date : 2024-11-10
Subject: How was it done? Implementing in-game clocks Sat Nov 30, 2024 9:15 pm
A while back, a video showcasing a cool capability of TAB was released:
But it doesn't quite show you how this mechanic would be programmed.
I assume that however it's done, it could probably be fiddled with to have actions take hours, days, seconds, or whatever unit of time one found appropriate... The passage of time on a clock in most games makes me nervous, but I also find it really neat. Right now I'm trying to make my own.
I'm not trying to make one that's accurate down to an hour-- I'll figure out how long each turn lasts later. What I'd like to do is make a day/night cycle, but only have the clock advance if the player is either...
taking any actions within a specified area, or
choosing to wait
I have two flags set aside for day number (self-explanatory) and time of day (not literal hour or minute, but rather a representation of how far into a "day" you are since I'm going to decide day length during testing), and these are both going to be checked fairly often to determine important things like NPC location and proximity to good or bad endings. So if the game starts after dawn and days are 20 turns long, then perhaps when the time flag reaches 21 a message saying "It's starting to get dark..." might appear. All of the areas where time will pass no matter what you do are numerically consecutive (maps no. 6-11), so I'm assuming I can use some "greater than" and "less than" in the conditionals. The idea in short is to have some places where the player can relax and think and experiment, and only advance the clock if they choose to, but others where they'll have to be moving fast and acting strategically. Things that can only happen at night or during the day are also interesting-- maybe a shop only unlocks its doors during daytime, maybe friendly NPCs act like monsters after dark, and maybe you turn into a frog if you don't use some medicine before three mornings pass! (to give examples)
I'm not entirely sure how to set this up, but I assume (correct me if I'm wrong) most of it would go in "Script 1"... unless it'd go in "Responses". I'd worry about accidentally making it so using "wait" in the time-passage zone makes the day move twice as fast (not desired), or turns spent performing actions in time-paused zones advancing the day when they're not supposed to. I can't find anything in the help docs for measuring and checking for all this since most of it-- I guess rather reasonably-- just checks for and measures turn number alone, rather than for if a turn is about to be taken, or has just been taken. I can't tell if such information is there and I just missed it or not.
If this isn't possible, I'll have to just make time pass everywhere, which I worry would make the game either too long or too frantic as a result. Any advice on pulling my preferred idea off?
catventure Admin Adventurer
Number of posts : 412 Age : 72 Location : UK Humor : Enjoys a laugh! Adventure Points : 77 Registration date : 2008-06-08
Subject: Re: How was it done? Implementing in-game clocks Sun Dec 01, 2024 9:54 am
Hi Somsnosa, I have to go out today but the Clock database was included with the text only download in the Adventures to play folder. However, I made a link so you can get a zip file of it here: http://tab.thinbasic.com/Clock.zip
Number of posts : 6 Location : totally-not-suspicious cave Humor : If you only like me because I am "funny" then I am going to become "the Joker". Adventure Points : 3 Registration date : 2024-11-10
Subject: Re: How was it done? Implementing in-game clocks Mon Dec 02, 2024 3:43 pm
Oh, now I feel a little silly...! I only downloaded a graphical version of TAB, which wasn't packaged with the clock demo, so I didn't have a copy of that file until now.
The clock demo however is super useful! Really does help to have examples to look at. Here's the current code I've cooked up to make sure it'd work:
Code:
'~~ TIME PASSAGE MASTER CONTROLLER ~~ 'FLAG 2 HOLDS DAY NUMBER 'FLAG 3 TRACKS DAY PROGRESS
'TIME AUTO-ADVANCES ON MAPS 3-12 [start]room>2#room<13[acts]incflag3,1[end]
'DAY NUMBER ADVANCES AT DAWN 'DAY 1 = flag3 at 1-4 'DAY 2 = flag3 at 5-8 'DAY 3 = flag3 at 9+ [start]flag3<5[acts]flag2=1#else#flag3>4#flag3<9[acts]flag2=2#else#flag3>8[acts]flag2=3[end]
`TIME STATUS DISPLAY FOR PLAYTESTING `TODO: REMOVE IN FINAL GAME [start]flag3>0[acts]wintitleCurrent Day: %flag2% | Countdown Progress: %flag3%.[end]
Works like a dream! Days are ridiculously short only for now so I could make sure time was actually passing and days were being counted. Maybe such a schedule would be reasonable in a game set on a fast-spinning planet, though, heheh. Still need to make "wait" pass the clock outside this little area, but things are looking up. I've still got a lot of fleshing out to give this system, like defined dawn/dusk times, warnings, sound effects, and the lengths of the days themselves, but none of that should be too awful hard (I hope). Harder part will be my idea to make areas be visibly lit differently and display unique room pictures depending on time of day and actions taken, but that might be for another thread.
catventure Admin Adventurer
Number of posts : 412 Age : 72 Location : UK Humor : Enjoys a laugh! Adventure Points : 77 Registration date : 2008-06-08
Subject: Re: How was it done? Implementing in-game clocks Mon Dec 02, 2024 4:18 pm
I'm pleased you're having some success!
I'm positive you'll be able to accomplish the day/night cycle you want by using the flags and/or turns conditions. Remember there are actions for increasing/decreasing flags by a certain number:
I came up with this before I read your reply just now... It should work but I didn't test it...
You can set a flag for when day changes to night.
Code:
script 2 entries: [start]flag1=0[acts]flag2=1#flag1=1#cmessIT IS DAY[end] [start]flag2>0[acts]incflag2,1[end] [start]flag2=100[acts]cmessIT IS NIGHT[end] [start]flag2=200[acts]flag1=0#flag2=0#incflag3,1[end]
You'd need a flag to update the DAYS after flag 2 reaches 200. I used flag 3 so after the first day (200 turns) it increases by 1 each cycle.
flag 1 used as a intialiser flag 2 increased by 1 each time Script 2 called. flag 3 holds number of 'days'
Regards, catventure.
Sponsored content
Subject: Re: How was it done? Implementing in-game clocks