Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Kanor |
I am trying to create a reference script that can be placed on a class and define extra parameters.
And it works! EXCEPT for when the reference script is edited. Then I get this error:
EnemyController.gd:100 - Invalid call. Nonexistent function 'get_script_export_list' in base 'Reference (paraenemy.gd)'.
Here’s the code:
tool
var controller_script = null
var controller : Reference
func get_controller_script():
if controller_script == null:
controller_script = controller.new(base_direction, controller_variables)
return controller_script
func _set(property, value):
# Changing controller
if property == "movement/controller":
controller = value
if controller != null:
reset_controller_script()
property_list_changed_notify() # update inspect
return true
# Controller variables
if controller_script != null:
for prop in get_controller_script().get_script_export_list():
if prop.name == property:
controller_variables[prop.name] = value
get_controller_script().update_exports(controller_variables)
property_list_changed_notify() # update inspect
return true
return false
When a controller (which is a script with its own class) is edited, the whole thing falls apart, but I have no idea why. Does the reference from controller_script become invalid? Is there a way to check that? Even has_method says the method on the controller_script exists only for the program to immediately claim it doesn’t.
I’ve also tried both weakref.get_ref and is_instance_valid. They turn up the same value before and after the editing.