Skip to content

Runtime Resources: Improve runtime characters ability to have portraits #2589

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

Merged

Conversation

Jowan-Spooner
Copy link
Member

Changes the portrait subsystem to index characters by their identifier instead of the resource path and removes an unnecessary threaded loading loop.

Also adds a helper method character.add_portrait(name, image, _scene) that allows code like this to very easily register a portrait:

        var characterA := DialogicCharacter.new()
	characterA.display_name = "Code Character"
	characterA.set_identifier("CodeCharacter")
	characterA.color = Color.WEB_PURPLE
	characterA.add_portrait("default", "res://characters/npc/portrait1.png")
	characterA.default_portrait = "default"

	var timelineA := DialogicTimeline.new()
	timelineA.from_text(
	"""
		join CodeCharacter center
		CodeCharacter: I have a portrait!
		
	""")
	Dialogic.start(timelineA)

Changes the portrait subsystem to index characters by their identifier instead of the resource path and removes an unnecessary threaded loading loop.
@shazzner
Copy link
Contributor

Hey @Jowan-Spooner thanks for the quick update! I tested your branch and I was able to create characters and link portraits using your helper method.

However, I seem to be having a new issue where when I end a script with a joined character I get an error that looks similar to the previous one:

E 0:00:18:293   subsystem_portraits.gd:617 @ get_joined_characters(): Resource file not found: res://liz (expected type: )
  <C++ Error>   Method/function failed. Returning: Ref<Resource>()
  <C++ Source>  core/io/resource_loader.cpp:344 @ _load()
  <Stack Trace> subsystem_portraits.gd:617 @ get_joined_characters()
                event_character.gd:130 @ _execute()

This results in the character portrait not loading again.
(liz is the name of the character, I believe it's trying to load the resource_path here again?)

In this method inside subsystem_portraits.gd:

## Returns a list of the joined charcters (as resources)
func get_joined_characters() -> Array[DialogicCharacter]:
	var chars: Array[DialogicCharacter] = []

	for char_path: String in dialogic.current_state_info.get('portraits', {}).keys():
		chars.append(load(char_path))

	return chars

@shazzner
Copy link
Contributor

That worked, thank you!

@Jowan-Spooner Jowan-Spooner merged commit 33b7706 into dialogic-godot:main May 16, 2025
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants