ComputerCraft - Calculate Moon Phase?

  • Please make sure you are posting in the correct place. Server ads go here and modpack bugs go here
  • The FTB Forum is now read-only, and is here as an archive. To participate in our community discussions, please join our Discord! https://ftb.team/discord

Baaleos

New Member
Jul 29, 2019
100
0
0
I've deciphered this logic from a bukkit plugin source - I was wondering if anyone else can confirm if it is correct?
I am running it right now - but because the actual appearance of the moon varies depending on resource packs and shaders etc - it is hard to tell if it is accurate or not.
It has produced the desired effects on a few occasions - Just wana make sure it was no fluke.

Code:
local day, phase
day = os.day();
phase = day%8
if phase == 0 then
    print("We have a full moon?")
end

I am trying to build temples and dungeons in my server where redstone doors will only open on the night of a Full Moon.
Does this logic look ok?
The original I got this from was doing
(getFullTime() / 24000)%8
I am assuming that 24000 was to get the current day number.
 

lenscas

Over-Achiever
Jul 31, 2013
2,015
1,801
248
I can't check minecraft/cc specific stuff but if I run

for t=1,16 do
print(t%8)
end
I get:
1
2
3
4
5
6
7
0
and it repeats from here
Thus assuming the full moon is at phase 8 and os.day() gives an int of the current day your code should work.
 

Baaleos

New Member
Jul 29, 2019
100
0
0
Ok - I think I heard somewhere that the full moon is at phase 0
But thanks - its good to know I was on the right track.