Thank you very much for your answer! In fact, the algorithm for calculating the lunar phases depending on the year and day of the calendar day is quite simple ... and I was surprised at first by your answer. I thought that this was implemented in the game. Here is the code JavaScript for HTML ... It's pretty simple to adapt to lua for Zomboid ...
var currentDate = new Date();
currentDate.setTime(currentDate.getTime());
var FullMoonDate = new Date(90, 1, 11, 1, 0, 0); // Full Moon (Toronto, Canada) in 1990 - January 11 at 1:00 am
//You can calculate from an earlier year - you need to specify the exact time of the full moon in the past ... and it is calculated on the current date ...
//This is the simplest formula, without calculating distances, an elliptical orbit, and much more.
var lunarPeriod = 29*(24*3600*1000) + 12*(3600*1000) + 44.05*(60*1000);
var moonPhaseTime = (currentDate.getTime() - FullMoonDate.getTime()) % lunarPeriod;
var percentRaw = (moonPhaseTime / lunarPeriod);
var time = Math.round((lunarPeriod-moonPhaseTime)/(24*3600*1000));
document.write("The next full moon through ",time," ");
if (time == 1) document.write("Day");
if (time == 2) document.write("Day");
if (time == 3) document.write("Day");
if (time == 4) document.write("Day");
if (time == 5) document.write("Day");
if (time == 6) document.write("Days");
if (time == 7) document.write("Days");
if (time == 8) document.write("Days");
if (time == 9) document.write("Days");
if (time == 10) document.write("Days");
if (time == 11) document.write("Days");
if (time == 12) document.write("Days");
if (time == 13) document.write("Days");
if (time == 14) document.write("Days");
if (time == 15) document.write("Days");
if (time == 16) document.write("Days");
if (time == 17) document.write("Days");
if (time == 18) document.write("Days");
if (time == 19) document.write("Days");
if (time == 20) document.write("Days");
if (time == 21) document.write("Days");
if (time == 22) document.write("Days");
if (time == 23) document.write("Days");
if (time == 24) document.write("Days");
if (time == 25) document.write("Days");
if (time == 26) document.write("Days");
if (time == 27) document.write("Days");
if (time == 28) document.write("Days");
if (time == 29) document.write("Days");
if (time == 30) document.write("Days");
if (time == 31) document.write("Days");
It was possible to give the character a chance to see the moon and its phases under the condition of good weather - lack of cloudiness, And also if we take into account the time of sunrise and sunset, then also the presence of the moon in the sky ... Myopia and punctured eyes)))) ...etc. also change the illumination depending on the current phase of the moon.
In fact, in reality, the Moon and its phases have quite a strong influence on plant growth, animal behavior, the general state of man ... and very great influence and importance in various sacred actions and rituals ... This can be treated differently .. To believe, or not to believe, but it's all real ... very real. - It's much more real than Zombies
I want to continue to use this in my add-on to the game. Unfortunately, I just started to get acquainted with Java and so far it's only in the plans for the future. So far I'm learning to do very simple things and try to understand the code implemented by others - more experienced people and apply the knowledge gained. I have a lot of syntax questions, and there is a lot of misunderstanding of the Zomboid API - I'm not a programmer at all ... I do not want to annoy my stupid questions, so I rarely ask, the code does not work at all on my own ... - but there is progress ... more ... Thanks for the answer ...