0 votes
var result : bool = Globals.fight(room_node)
    if  result == true:

It's breaking at the if statement thinking that result is an object instead of a boolean. I don't understand how this error is happening since I made result to be of type boolean. fight function is a boolean function as well

func fight(monster) -> bool:

So the function returns a boolean in every path, (has too or else gdscript yells at you), and a variable of type boolean stores it's result. How is it confusing result as an object? I originally had this as just one line but decided to separate it to see if anything would change. I don't exactly need this to be fixed, I can do a different check, I just find it odd that what seems to be a guaranteed boolean, is being treated as an object

in Engine by (12 points)

Not sure how to solve your problem, but why even check against true?
A boolean can just be checked with the if statement:

if result:

is the same as:

if result == true:

And an Object, if you are just checking if it exists or is null, basically a null check you can do the same:

if object:

is the same as:

if object != null

It's for my readability sake and preference, that's all. The way I think is "if this is true, then do that" not "if this, than that"

Please log in or register to answer this question.

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 Frequently asked questions and 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 [email protected] with your username.