My <365 check was going to be set before the script was called in the first place, but thinking back on it I suppose it would be easier in the long run to have it in the script, as well. Also, I added the ":date_out" variable because I thought it would be easier to read and understand.
So
that's what the val_mod does! I was wondering. I recognized all the other mathematical operations, but that one had me kinda stumped. And you're right, it's perfect for my needs.
I also took a look at script_game_get_date_text and think it would make a good template for my purposes (also, I note that the programmers did, in fact, include leap years). I think there's a typo in the notes for it, though - they say the input is the number of days that have passed, and yet the very first thing they do is divide the input by 24 into a variable called :num_days. I'm pretty sure that they meant to say that the input variable was in the number of hours that have passed. Just so you can see what I'm talking about:
Code:
# This script is called from the game engine when the date needs to be displayed.
# INPUT: arg1 = number of days passed since the beginning of the game
# OUTPUT: result string = date
("game_get_date_text",
[
(store_script_param_2, ":num_hours"),
(store_div, ":num_days", ":num_hours", 24),
(store_add, ":cur_day", ":num_days", 23),
At any rate, dunde has a very good point: I can simply copy-paste the conditional portion of script_game_get_date_text in order to determine the date for my purposes, and it's a heck of a lot easier than figuring all of it out from scratch. Not that I don't think the method we were discussing would work, but why rebuild something from scratch if there's already a perfectly working frame? It was still a great learning experience, though. The whole thing would seem like overkill for just one time-dependent character, but it just so happens that I've been planning 6 of them all along (two months per character), so I can use a single script to call them all whenever it is his/her time.
One of the things I didn't realize until just now is that the characters in a scene is determined by module_game_menus.py. All this time I was thinking that served an entirely different function. I've hardly looked at that particular file, so now I'm going to have to spend some time studying it and trying to figure out how it works. As far as I can tell, there are two potential ways to do this:
1) Add the hero troop in the game_menus' "tavern" code, with the date-dependent conditionals.
2) Create a new trigger that calls a date-checking script, and add the hero with the trigger.
The first one requires me to learn the most new material, so I'm probably going to go for that one.
On a somewhat related note: if a script can call itself recursively up to 250 times, and we are using my earlier script to determine dates, that means that the script would work up to 250 years! Now obviously nobody's gonna be playing a game that long, but it leads me to another question that I keep wondering about: all the lords in this game have a set age. I've never gone longer than a year myself, and so never really had the chance to find out... but do the characters age as they grow older? I noticed there are 'retirement' scripts in the game, but it seems to be limited to the pc and companions. In that case, can people die of old age? I can't help but think that this game would be made a lot more deep if there were some sort of aging|childbearing|retiring|death-by-age|heir features. After all, some of the lords in the game start off pretty old.