Skip to content

Yarn Spinner seems to be assuming all auto-discovered commands are instance commands. #7

Description

@Orangestar12

The docs state

prefix any method with _yarn_command_ and the runner finds it automatically.

In addition, the code sample also states

# On any node in your scene tree:

Instanced commands seem to be differentiated by the fact that you have to register them.

To that end, in the root Node2D of a scene, I placed the following function

func _yarn_command_setstate(stateName: String) -> void:
	# <<setstate map>>
	# Sets the current game state immediately.
	match stateName:
		"map":
			Game.State = Game.STATE.MAP
		"yarn":
			Game.State = Game.STATE.YARN
	pass

And called it in my Yarn script like this:

-> Tell Luke you have to go iron your cat.
	<<setstate map>>
	<<stop>>

However, this results in this error in the debugger

E 0:00:06:431   dialogue_runner.gd:912 @ _on_command(): yarn spinner: no handler for command 'setstate map'. Did you forget to register it? Dialogue will continue.

I also tried <<setstate "map">> only to get the same error.

When I checked the Yarn Spinner window in the Godot editor, I noticed my command had two parameters, not just one - as though the autodiscovery system counted the unspoken self parameter on the function as a parameter for the script.

Image

This seems like a bug since I haven't explicitly tried to register the command as an instance command.

EDIT: <<setstate Node2D map>> does work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions