Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cyclic dependency error with custom data types creating more of themselves #49181

Closed
TimCoraxAudio opened this issue May 29, 2021 · 2 comments
Closed

Comments

@TimCoraxAudio
Copy link

TimCoraxAudio commented May 29, 2021

Godot version: 3.3.2
OS/device including version: Xubuntu 20.10

Issue description: If using a custom class and that class needs to create more of itself, a cyclic dependency error ensues

Steps to reproduce:

extends Node
class_name Item

var count: int
var item_id: int

func split_item(amount: int) -> Item:
    var item = Item.new(item_id, amount)
    count -= amount
    return item

I know this can be prevented by doing:

func split_stack(amount: int) -> Item:
	var item = self.duplicate()
	item.count = amount
	count -= amount
	return item

But this is doing essentially the same thing. It also took me a long time to find this problem because the error came up in other classes at the end of the file

@nonunknown
Copy link
Contributor

Duplicate of #43529 & #21461

@Calinou
Copy link
Member

Calinou commented May 29, 2021

Closing per @nonunknown's comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants