Jump to content

Moon phases? Question to the developers ...


Nebula

Recommended Posts

On 19-2-2018 at 7:32 PM, Nebula said:

There are phases of the moon in the game, if so, how to get the value of the phase or the number of the lunar day?

 

Eya, for current builds the files in lua/server/Seasons/ should be of interest, its also stored in gametime moddata if im not mistaken.

Small note: some of the weather related stuff is being reworked tho, so in a near update the value(s) might need to be gotten in a different way.

Link to comment
Share on other sites

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 ...

Edited by Nebula
Link to comment
Share on other sites

On 22.02.2018 at 2:12 AM, turbotutone said:

Eya, for current builds the files in lua/server/Seasons/ should be of interest, its also stored in gametime moddata if im not mistaken.

Small note: some of the weather related stuff is being reworked tho, so in a near update the value(s) might need to be gotten in a different way.

Yes, I looked. Thank you!
I correctly understood - that the phases of the moon in the weather script do not have a real binding to the calendar and work like an imitation?

 

Is there a way to get MoonPhase from this script into its variable? Or is it better to use a self phase calculation script? It will be something - GameTime: getMoon ()?
Sorry if my question is stupid ...

Edited by Nebula
Link to comment
Share on other sites

GameTime() doesn't seem to have a :getMoon() method, only :setMoon() which is a float value (i'm assuming is for light?)

its probably better to just use the season.moonPhase variable

it looks like the season.moonPhase values are:

0 = New Moon

1 = Waxing cresent

2 = First quarter

3 = Waxing gibbous

4 = Full Moon

5 = Waning gibbous

6 = Third quarter (last quarter)

7 = Waning crescent

Link to comment
Share on other sites

Does not fit : (

I tried to just see the meaning ...

getPlayer():Say("MoonPhase " .. tostring(season.moonPhase()));
 

Gives this error.

java.lang.RuntimeException: Object 0 did not have __call metatable set

Edited by Nebula
Link to comment
Share on other sites

43 minutes ago, Nebula said:

Does not fit : (

I tried to just see the meaning ...

getPlayer():Say("MoonPhase " .. tostring(season.moonPhase()));
 

Gives this error.

java.lang.RuntimeException: Object 0 did not have __call metatable set

You tried to call it like a function.

getPlayer():Say("MoonPhase "..tostring(season.moonPhase))

 

Don't include the ( ) after moonPhase

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...