0 votes

enter image description here

(Sorry for my bad english)

I have this problem when im tring to create or delate a child item node, the entire frame seems to flicker for an instance before returning to normal, im using Node2D for items and slots, i notice is only when adding and fleeling , anyone know why?

Here is some of the script

func add_to_inventory(item_id:String,amount:int):
var on_inventory=false
for child in get_child_count():
    if(!get_child(child).is_empty):
        var item_amount=get_child(child).get_child(get_child(child).get_child_count()-1).amount
        var item_max_amount=get_child(child).get_child(get_child(child).get_child_count()-1).max_stack
        if(item_id==get_child(child).item_id&&item_amount<item_max_amount):
            if(item_amount+amount>item_max_amount):
                var overload=item_amount+amount
                overload-=item_max_amount
                var to_add=amount-overload
                amount=to_add
                fix_overload=overload
                add_overload=true
                overload_id=item_id
            on_inventory=true
            get_child(child).get_child(get_child(child).get_child_count()-1).change_amount(amount)
            break
if(!on_inventory):
    for child in get_child_count():
        if(get_child(child).is_empty):
            var item=item_template.instance()
            item.init(item_id,amount)
            item.position=get_child(child).get_child(get_child(child).get_child_count()-1).position
            get_child(child).is_empty=false
            get_child(child).item_id=item_id
            get_child(child).add_child(item)
            break
if(add_overload):
    add_overload=false
    add_to_inventory(overload_id,fix_overload)
asked May 20 in Projects by CerditoAsesino (12 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.