A lil problem about syntax and singleton...

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Syl


Got a singleton var torch = null, and i want it to be checked at the start of my scene, so wrote something like that:

extends Node2D

func ready():
	if GlobalP.torch == "lit":
		$BGD.visible = false

so that my black BGD/background keeps being invisible if the player is coming from a scene with GlobalP.torch == “lit”.
BGD sprite is right under Node2D, GlobalP.torch is changed in a previous scene with that:

func _on_Torch_pressed():
	GlobalP.torch = "lit"

and yet that doesn’t work, and the scene keeps being in sheer darkness…

:bust_in_silhouette: Reply From: Zylann

You should write _ready with an underscore, ready won’t be called.

Arf… So stupid, sry…

Syl | 2020-03-02 18:57