Advanced Peripherals

Advanced Peripherals

29M Downloads

Environmental Sensor getMoon() method inconsistent?

Jason-c-o opened this issue ยท 5 comments

commented

Describe
The output for the getMoon() method is a little strange and inconsistent. (see image)
Some phases output just a name inside a table {" NAME "}, and others output {[NUM] = "NAME"}

Reproduce
Use the getMoon() method during different moon phases and check the output.

Screenshots/Videos
Moon

Versions:

  • Forge version: 35.1.28
  • AdvancedPeripherals version: 0.3.3b
commented

Sweet, i will try to fix the issue with the "Waning gibbous" moon phase.

commented

Except now I've also found out it makes it harder to access the name. You can't simply

print(phase)

You have to include the number. So in order to print the name, you have to revert to a large if once more:

if phase[8] then
   print(phase[8])
elseif phase[1] then
   print(phase[1])
elseif ... -- All other conditions
end

It would definitely be much easier if the output was {NUM, "STRING"} rather than { [NUM] = "STRING" }. Rigth now it's the same as if it were {NUM} because you already have to know which phase it is to print the name of the phase. Workable, but awkward.

commented

image

I see, only "Waning gibbous" returns no number.

commented

Nevermind. I deleted my previous comment because I figured out you can simply do

local phase = getMoon()

if phase[0] then
 do.Stuff()
elseif phase[1] then
 do.SomethingElse()
end

So that's how you access it directly. Cool!

commented

You can now use "getMoonName()" for the name and "getMoonId()". If you have any suggestions, just tell me.