Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | crablord |
I am going through this tutorial for decorator pattern
and i came up to the point where i want to instance a decorator scene and “wrap” my scene in it. Here`s a script from which i inherit my decorator:
extends Node
class_name Attribute
signal amount_changed(new_amount)
export(float) var amount = 0 setget set_amount, get_amount
func set_amount(new_amount):
amount = new_amount
emit_signal("amount_changed", new_amount)
func get_amount():
return amount
func _ready():
pass
When i`m going throught debugger it breaks on line with setget variable, returns null to main code and gives this error:
editor/script_editor_debugger.cpp:1400 - Condition “cmd.get_type() != Variant::STRING” is true.
Script of the decorator, which instance i create:
extends Attribute
var decoratee
func get_amount():
var decorated_amount = decoratee.amount
decorated_amount *= amount
decorated_amount = max(decorated_amount, 0)
return decorated_amount
Script where i create an instance of decorator scene:
extends Node
export (PackedScene) var decorator = preload("res://scenes/AttributeDecorator.tscn")
...
func _buff(target, attribute):
var attribute_decorator = decorator.instance()
attribute_decorator.decoratee = target.get(attribute)
...
How to fix this error?