What I aim to have is something similar to the pcall function from lua where it'll return false as well as the error code if it errors. I'm not sure if there's something other than a simple if statement. The main reason for this is that I want to check if an exported bool variable exists without it halting the execution of my game and breaking things if it's not there. I already have something that does this for other variable types using an if statement, but it'll get the actual value and use that instead of checking if it exists. Here's a link describing in detail what pcall is/does.

  • As far as I know, it doesn't exist in GDScript. The closest thing would be exception handling, but that is only available in C# (and in general, you are better off with GDScript). What you could do is maybe use an Enum with 3 values, True, False, and a default of Undefined, or something like that. Though this would make checking the value more code than a boolean, it would achieve the safety you want.

As far as I know, it doesn't exist in GDScript. The closest thing would be exception handling, but that is only available in C# (and in general, you are better off with GDScript). What you could do is maybe use an Enum with 3 values, True, False, and a default of Undefined, or something like that. Though this would make checking the value more code than a boolean, it would achieve the safety you want.