Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way to pass a built-in variable by reference in GDScript?

I'm working on a developer console system for my game, and I'm currently working out how implementing variables will work. At first, I thought I'd just use variable pointers to change variables that belong to other objects, but it seems GDScript doesn't support them. Is there any way to do this, and if not, what are my alternatives?

like image 237
mdkael Avatar asked Oct 14 '25 20:10

mdkael


1 Answers

Maybe you can create a dictionary with variable names as keys, and their values as dictionary values. Then, if the player will define a variable a in his code and set it to 10, your dictionary will need to change from

{}

to

{'a': 10},

and when the player will change the variable a to 11, your dictionary should update to

{'a': 11}.

If you have a simple console without objects with their own variables, just create a single dictionary, and you'll be done. Otherwise, if you have objects, create a similar dictionary for each of them. If your console can support variables without names, you should try a different way of solving this problem.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!