"Invalid call. Nonexistent function" in a tool script but the function exists

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lasthy

I have a script to create physical items using a resource as a base. The code to generate the item so the player can pick up is:

class_name WorldItem
extends Spatial

export (Resource) var item setget set_item
export (int) var quantity = 1
export (Enums.interaction_type) var interactionType

onready var interactionSprite = $InteractionSprite

func set_item(resource):
	if resource != item and resource != null:
		generate(resource, quantity)
		item = null
		$Sprite3D.texture = null

func generate(i, q):
	item = i
	quantity = q

The generate method that the item call would be used to generate random stats like attack, critical hit rate, etc, and the script looks like:

extends Weapon
class_name MeeleeWeapon

export(Vector3) var hitbox_size: Vector3
export(Vector3) var hitbox_offset: Vector3

func generate():

But, when I drag the resource of the item, it just says that it is a non existent function, in base Resource (the heritance is like: Resource <= Item <= Equipment <= Weapon <= MeeleeWeapon)

Anyone have any idea of what it could be?

:bust_in_silhouette: Reply From: spaceyjase
extends Weapon
class_name MeeleeWeapon

Needs tool to run in the editor. Likely you need to add this to each step of your hierarchy, e.g.:

extends Resource
class_name Item

godot only treats these as a Resource (in editor) otherwise. It likely runs fine in game.