0 votes

I keep getting this error message.
This is my code.

extends TextureRect

func _ready():

var Day = load('res://Assets/Background.png')
var Night = load('res://Assets/Background_Night.png')

var time = OS.get_time()
var hour = time.hour

if 6 < hour < 20:
Godot version 3.3.2
in Engine by (15 points)

Thank you, @dancaer69 and @timothybrentwood! You both gave quick, useful responses!

2 Answers

+1 vote
Best answer

if 6 < hour < 20:
needs to be
if (6 < hour) and (hour < 20):

No complex inequalities without an and or or statement. What was happening is it evaluated 6 < hour which resolved to either true or false then it tried to evaluate true < 20 which just doesn't make sense.

by (3,707 points)
selected by
+2 votes

I don't think that you can do that in gdscript. Do it like this:

if hour > 6 and hour < 20:
by (221 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.