How do I check the value of a Scene/Global Variable in an Extension/Prefab? (Thats all I can think of to say)
method 1
the easiest is to put the value as parameter of the function. so when you use the function, you just put the value.
if you want to put the value back into a variable, the easiest is to have the function be an expression (this will return a value). and you do in main event sheet: scene_variable set to → the_custom_expression
method 2
if the variable is an array/structure, it must be passed as the variable itself instead of the value of it. (it doesnt pass it straight like that, it must be copied in the function and then copied back to the parameter)
to copy:
i may be wrong in what i say, but this is as far as i know
Im not sure I follow on method 1
at the right panel of the extension there is a section to define new parameters. (triple dots to add a parameter)
in main event sheet, where you use your custom function, you see all the parameters to put. simply put the variable in the parameter. in this case, the param (number_to_pass) type is number. this means a number shall be passed. i could put a number literal like this:
but you want to pass a variable. so i just put a variable named scene_var (you can put any expression in fact, that returns a number):
if you got more questions feel free to ask
This is the right part of the doc:
What if I want to use a Boolean?
This would almost be the solution its just that it doesnt tell how to do it with a Scene or Global Variable
you are right. you can’t pass a boolean variable to a boolean parameter as GD it does not support boolean expressions (only boolean literal).
method 2 works though.
but you could also do a condition that checks the variable in main event sheet:
scene_var = true → call function with boolean param true
scene_var = false → call function with boolean param false
You can use such comparisons (they are fully functional).
x == false // x = 0
y == true // y = 1
m == true // m = "true"
n == false // n = "false"
And if variable X is true or false and variable Y is false or true, then they can be compared as strings.
is that JS?
you want @The4Lexanator to use JS?
is it like using a number to represent a boolean?
1 = true
0 = false
and like… never using a boolean in the first place?
Yes, in this regard, gdevelop is similar to JavaScript.
but you know what i mean?
if OP only uses a number to represent a boolean, it would be the easiest workaround IMO. (unless he wants to use a toggle)
So uhhh how do I do it?
Use the condition Compare two numbers
I’ll try both, thanks so much guys ![]()






