Nazsgull
what i'd do is test your toggleDoor
function:
func toggleDoor(body):
## test variant type of "open"
if typeof(open) == TYPE_BOOL:
print("the mystery continues..")
else:
print("there's your issue :)")
## your own code continues here
if open:
anim.play("open")
else:
anim.play_backwards("open")
what i'd do if i was really in your place is not worry about it:
func toggle_door(_body) -> void:
if open:
open = false
anim.play_backwards("open")
return
open = true
anim.play("open")
return
i took liberties appropriating your code. i hope that's alright. i think you get the idea.
DaveTheCoder
in my testing, the errors for attempting to invert most variant types are pretty specific in 4.2.1:
res://invert_bool.gd:6 - Invalid operands 'Dictionary' and 'Nil' in operator 'not'.
res://invert_bool.gd:7 - Invalid operands 'Array' and 'Nil' in operator 'not'.
res://invert_bool.gd:7 - Invalid operands 'String' and 'Nil' in operator 'not'.
integers and floats makes sense if you read about constructors in the bool
doc:
func invert_int() -> void:
## invert a 0 integer
var b = 0
b = !b
assert(typeof(b) == TYPE_BOOL && b == true)
## invert a non-zero integer
b = 5
b = !b
assert(typeof(b) == TYPE_BOOL && b == false)
return
func invert_float() -> void:
## invert a non-zero float
var b = 0.05
b = !b
assert(type_of(b) == TYPE_BOOL && b == false)
## invert an 0 float
b = 0.0
b = !b
assert(type_of(b) == TYPE_BOOL && b == true)
go ahead and run these functions. the assert methods won't complain.
try this one too:
func invert_float() -> void:
## invert an approximately 0 float
b = 0.00000000000000000000000005
b = !b
assert(type_of(b) == TYPE_BOOL && b == true)
return
if we're talking Godot 3.5.3: bools can be constructed from seemingly anything:
func invert_everything() -> void:
## this one's in the official docs
var b = "invert this"
b = !b
assert(typeof(b) == TYPE_BOOL)
## but not these
b = ["array", "of" "string"]
b = !b
assert(typeof(b) == TYPE_BOOL)
b = null
b = !b
assert(typeof(b) == TYPE_BOOL)
b = TextureRect.new()
b = !b
assert(typeof(b) == TYPE_BOOL)
return