Skip to content
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

Deriving custom class names for script generation broken #74

Open
jgrenda opened this issue Jul 2, 2023 · 6 comments
Open

Deriving custom class names for script generation broken #74

jgrenda opened this issue Jul 2, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@jgrenda
Copy link
Collaborator

jgrenda commented Jul 2, 2023

Steps to replicate:

  1. Create a scene with 2 state behaviors
  2. Create a "exited -> enter()" connection between state and state2
  3. Launch the scene

Error: "Parser Error: Could not find type 'State2' in the current scope."
image
Tree:
image

What is causing the from/to types to be incorrectly replaced by the behavior's name?

Proposed solution:

  • Use class_name "State" instead of name
@jgrenda jgrenda added the bug Something isn't working label Jul 2, 2023
@jgrenda
Copy link
Collaborator Author

jgrenda commented Jul 2, 2023

Tested two other types of connections (Always -> Placeholder, Controls to State) and this issue does not occur there. This seems to be directly related to connections outgoing from State (maybe?).

@jgrenda
Copy link
Collaborator Author

jgrenda commented Jul 2, 2023

Does this maybe relate to %ReceiverPath.text = "${0} ({1})".format([from.get_path_to(receiver), receiver.name]) from node_to_node_configurator.gd ?

@tom95
Copy link
Contributor

tom95 commented Jul 2, 2023

Potentially fixed by: afec720

If you can confirm, we can rename the issue to "Deriving custom class names for script generation broken"

@jgrenda jgrenda changed the title State connection from/to type resolution by name instead of class Deriving custom class names for script generation broken Jul 2, 2023
@jgrenda
Copy link
Collaborator Author

jgrenda commented Jul 2, 2023

Looks good, that seems to solve the issue for now

@tom95
Copy link
Contributor

tom95 commented Jul 2, 2023

@LinqLover what was the assumption about Node.to_string() producing? Some labels may differ between a saved and an unsaved scene.

@LinqLover
Copy link
Contributor

node.get_class() only returns built-in classes, so we only see Node2D for every node, see godotengine/godot#21789. There are two workarounds:

  1. implement a custom get_class_name() method on every node class (i.e., behavior)
  2. parse the class name from the built-in to_string() method

The first option seemed more laborious so I tried the second. Unfortunately, the string parsing approach seems not to work well enough, I don't know what Godot is putting else into the string. Either we can reverse-engineer the exact to_string() behavior (maybe start here, but according to your example, it might be impossible to reconstruct the class name unambiguously from the string) and fix the matcher; or implement get_class_name() on every behavior and use it.

@tom95 tom95 added this to Pronto Jul 30, 2023
@tom95 tom95 moved this to Long-term in Pronto Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Long-term
Development

No branches or pull requests

3 participants