I'm trying to make my trees change frames based upon what month it is, but am struggling to get the Tree script to read from my Calendar script. I've tried it like in the screenshots and with get_node() but I couldn't get either to work.

Running it now, like it is in the screenshots, I get the error 'Invalid get index 'month' (on base: 'null instance').'

Any and all help would be greatly appreciated!

Add this at the beginning of Tree.gd's _ready() function:

print_debug("calendar=", calendar)
print_debug("scene tree:")
print_tree()

If that doesn't explain the problem, post the output here.

    DaveTheCoder

    I think I understand that Tree.gd can't get access to my Calendar because it isn't a Node in the same scene, right? However, I don't understand how I can make the whole game run on the exact same time and date system if I plop the Calendar into every scene that will use it. Wouldn't the date and time inevitably run out of sync if every object calculates it for themself?

    Or, would instancing the Calendar node as a child scene into my Tree scene make it run the calculations once, then apply them all the same to every object that has it instanced?

    Not sure if I said it on this thread but I'm super new to programming and (noticeably) don't have intimate knowledge yet of what exactly goes on.

    For anyone curious, here was the output:

    calendar=[Object:null]
       At: res://Tree.gd:8:_ready()
    scene tree:
       At: res://Tree.gd:9:_ready()
    .
    ShadowSprite
    SeasonalTreeSpritesStumps
    SeasonalTreeSprites
    CollisionShape2D

    When you use get_node() it is relative to the script you are calling it on. So it will only get children of that node. You can either use get_parent() (maybe multiple times, a bad idea) or use root paths. For example:

    onready var calendar = get_node("/root/MainFarm/Calendar")

      cybereality
      In my specific case, if I were to make more maps than just the current MainFarm, then I would probably have to rewrite the root path for every map, right?

      I've since instanced my Calendar as a child node in the Tree scene. Is there a possibility this child Node becomes out of sync with the Calendar node in MainFarm?

      Yes, they will be two separate scripts with the same code (but can act independently). You could make the calendar and autoload, this would be a good use for it. They are basically globals. But you should only do that for stuff that is actually global (which the calendar is). Otherwise you should learn how the node paths work, because it is essential to working with Godot.

      https://docs.godotengine.org/en/stable/tutorials/scripting/singletons_autoload.html

        cybereality
        Sounds like this is exactly what I need, thank you!
        (And I'll make sure to read more about node paths!)