Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rubixnoob13 |
Hopefully I can explain this correctly, as I’m still pretty new to Godot. Basically, I want to have a class, for example in res://scripts/class_test.gd
In this class, there will be several methods, and some of them will have a lot of code associated with them. So what I’d like to do is have class_test.gd include this:
class_name MyClass
And then possibly some virtual functions. Then, in separate script files, such as class_test_func1.gd, class_test_func2.gd, etc. have each of these functions actually defined. (again, I anticipate the functions being extremely long and having multiple branching if/else statements, so like probably 200-300 lines of code per function.
I know I have done something similar a long time ago in c++ to make the code easier to read, because I could just open that specific script instead of searching through like 8000 lines of code to find what I was looking for.
Would loading the other scripts with something like:
var thing = load("res://scripts/class_test_func1.gd")
var myThing = thing.new()
Is this even possible? Is it a good idea? As far as what I’m trying to accomplish is working on an FSM and having the states be handled by different files so it’s easier to maintain when I’m working on one specific state. Thanks in advance for any help or advice!