Skip to content

Comments

Update to 4.x, adding 4.x workaround#2

Open
moritz-junge wants to merge 17 commits intonsrosenqvist:mainfrom
moritz-junge:main
Open

Update to 4.x, adding 4.x workaround#2
moritz-junge wants to merge 17 commits intonsrosenqvist:mainfrom
moritz-junge:main

Conversation

@moritz-junge
Copy link

@moritz-junge moritz-junge commented Nov 21, 2023

This updates the extension to Godot 4.x but can no longer be used like this:

const implements = [
	CanTakeDamage,
	CanHeal
]

but instead needs to be used with preload:

const implements = [
	preload("path/to/interface/can_take_damage.gd"),
	preload("path/to/interface/can_heal.gd")
]

This also adds a workaround for that problem allowing the name to be used as a string instead like this:

const implements = [
	"CanTakeDamage",
	"CanHeal"
]

However this interprets the strings in the array as GDScript code which could potentaly lead to some problems and isn't tested in an exported project (where this plugin should probably be removed anyways, as it is not needed at runtime).

The README is updated accordingly and I also made this a fully fledged extension instead of a script you needed to add to the autoload yourself.

I also provided a runnable example in this repo (not the extension in the addons/ folder), therefore adding a project.godot to the project.

I haven't tested this with the new 4.2 RC but it worked with the 4.2beta and 4.1stable and there is no reason it shouldn't work.

@moritz-junge moritz-junge mentioned this pull request Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant