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

Issues with Godot 4.3 #196

Closed
HolonProduction opened this issue Jul 19, 2024 · 9 comments · Fixed by #197
Closed

Issues with Godot 4.3 #196

HolonProduction opened this issue Jul 19, 2024 · 9 comments · Fixed by #197
Labels
🐛 bug Something isn't working

Comments

@HolonProduction
Copy link

Godot version: 4.3-beta3

Describe the bug
Refer to godotengine/godot#94150 for further details

TL;DR:
The type handler code uses Script.has_source_code to test if a script is valid.
This is false for scripts with binary tokenization. Script.can_instantiate should be used.

The MRP from the orginal issue does work with this change, but fails when copying the newest version of pandora in there and making the change.

I found that when running the game, data.pandora gets saved in a corrupted way:
{"type": "undefined", "value": "<CompressedTexture#84384>"} where it should be {"type": "resource", "value": "res://godot.png"}. As stated this does not happen with the pandora version from the MRP, I don't know which version that is though.

To Reproduce

Expected behavior

  • the texture should load when run through the editor and when exported with binary tokenization

Screenshots

Desktop (please complete the following information):

  • OS: Fedora
  • Version 40
@HolonProduction HolonProduction added the 🐛 bug Something isn't working label Jul 19, 2024
@shomykohai
Copy link
Contributor

shomykohai commented Jul 19, 2024

The MRP uses what used to be the latest commit on master, which in this case is 90f4514.

Can you test if applying the changes of #189 on the latest master commit, the issue gets fixed?

Edit: I've just looked upon my data.pandora and I encounter the data corruption problem too.
broken types

@shomykohai
Copy link
Contributor

shomykohai commented Jul 19, 2024

I was able to find where the problem comes from.
In script_util.gd it is possible to change has_source_code to can_instantiate, but on type.gd calling can_instantiate returns false.

Apparently the scripts it tries to load are the one under model/types

@HolonProduction
Copy link
Author

Just a guess, can't test right now: entity has @tool the type handlers not, so maybe can_instantiate returns false only in the Edtior for scripts without @tool. Could be verified by fixing the data file and running the project from the project manager without using the editor.

@shomykohai
Copy link
Contributor

shomykohai commented Jul 19, 2024

Indeed that does work, both on the ProjectManager and on exported builds (without a corrupted data.pandora).
I'd say this is something @bitbrain has to look through to decide on how to handle this.
I'd do something like:

if ScriptType != null:
  if Engine.is_editor_hint() and ScriptType.has_source_code():
			  return ScriptType.new()
  else:
    if ScriptType.can_instantiate():
			return ScriptType.new()

Not the best code for sure, but the workflow is that.

@bitbrain
Copy link
Owner

@shomykohai that code looks good. We should go with that.

@shomykohai
Copy link
Contributor

Perfect, I'll make a PR for it.

shomykohai added a commit to shomykohai/pandora that referenced this issue Jul 19, 2024
Fixes various issue that came from Godot 4.3 changes in GDScript and loading:
bitbrain#196 bitbrain#187
@HolonProduction
Copy link
Author

Why not make the type handlers tools though? If can_instantiate returns false it might just be a mistake or at least undefined behavior that it works correctly, and thus might arbitrary change in the future. (The type handlers are used in the editor, right?)

@shomykohai
Copy link
Contributor

shomykohai commented Jul 19, 2024

The function that gets called is a static function, that the editor uses to fetch the icons of each types.
When creating a property, they look to be wrapped around a PandoraProperty class, so I guess they're not meant to be tool classes.

Not knowing how fully Pandora works (I didn't look up the editor part that much) I can't say it for sure though.

Edit: just wondering, why does can_instantiate return false, assuming the script to be valid, when it does not have the @tool notation?
According to gdscript.cpp, it should only check for valid, right?

@HolonProduction
Copy link
Author

Seems to also check for tool:
image
(No clue what this scripting enabled is 😅 )

I guess code that isn't marked as tool is not meant to run in editor which would include the initializer and constructor. Not sure what the intended behavior is with instantiating non tools from tool scripts. This question might better be asked in the contributors chat.

Back to pandora: I'd guess the editor has to use the non static write_value function when serializing. So IMO it would make sense for them to be tools, but @bitbrain would probably know best.

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
None yet
Development

Successfully merging a pull request may close this issue.

3 participants