Implementing duplicate() for Custom Classes

Godot Version

v3.3.2.stable.mono.official

Question

Hello! I’m using GDScript for object-oriented programming and I would like to know how to implement the duplicate()method. This is my script so far. Thank you!

extends Node
class_name Item

var item: String
var quantity: int #null: -1
var variant: String

var texture: Object

func _ready():
	pass # Replace with function body.

func _init(i: String = "", q: int = 0, v: String = "", t: Object = null):
	item = i
	quantity = q
	variant = v
	texture = t

func duplicate(flags: int = 15):
	pass

duplicate is not virtual so it is not overridable

1 Like