Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Jamoxploder |
I have a base item class which stores universal item information.
The intention is to extend this class for different item types.
extends Node
class_name Item, "res://Scripts/Item.gd"
var id
var item_name
var type
func _ready():
pass
func _init(var _id, var _item_name, var _type):
id = _id
item_name = _item_name
type = _type
and I’m trying to extend this class to create a Health Item class:
extends "res://Scripts/Item.gd"
class_name Health, "res://Scripts/Health.gd"
var hp
var heal_time
func _ready():
pass
func _init(var _hp, var _heal_time, var _id, var _item_name, var _type):
id = _id
item_name = _item_name
type = _type
hp = _hp
heal_time = _heal_time
This is how I would assume inheritance to work.
Is there some variation of a super keyword that I’m not aware of. Extending scripts is never made clear in the documentation (unless I missed something).
Can someone tell me what I’m doing wrong or what concept/s I don’t understand.
Is there a better way to achieve the same result?