0 votes

I am going through this tutorial for decorator pattern
https://www.youtube.com/watch?v=BYNLzH0EOH0
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/scripteditordebugger.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?

in Engine by (16 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.