I created a day/night cycle and I have this for doing something whenever the state var is changed, however I tested it and the TIME_DAY or any stuff in the set_state doesn't work. I am very new to Godot so I donno what to do, also tell me if my code is messy.
enum {
DAY,
DUSK,
NIGHT,
DAWN
}
var state = DAY setget set_state
and
func set_state(value):
state = value
match state:
DAY:
daylight.enabled = true
moonlight.enabled = false
DUSK:
pass
NIGHT:
daylight.enabled = false
moonlight.enabled = true
DAWN:
TIME_DAY += 1
emit_signal("day_changed", 1)
if TIME_DAY >= 30:
TIME_DAY = 0
TIME_MONTH += 1
emit_signal("month_changed", 1)
if TIME_MONTH >= 12:
TIME_MONTH = 0
TIME_YEAR += 1
emit_signal("year_changed", 1)
if timeUI != null:
timeUI.text = str(TIME_DAY) + " " + str(TIME_MONTH) + " " + str(TIME_YEAR)