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

Review bool comparisons (variables in Signals, empty lists etc) #320

Open
miskatonicstudio opened this issue Sep 4, 2023 · 1 comment
Open
Labels
godot4 Aftermath of the Godot 4 migration refactoring Code structure has to be improved

Comments

@miskatonicstudio
Copy link
Owner

Godot v4 seems to no longer allow for using empty lists or empty variables (e.g. empty strings) as boolean (e.g. with the != operator). As a result, some changes has been made, mostly by adding is_empty to different checks in the framework:

addons/goat/settings/SettingsSlider.gd:	if not settings_section.is_empty() and not settings_key.is_empty():
addons/goat/settings/SettingsSlider.gd:	if not settings_section.is_empty() and not settings_key.is_empty():
addons/goat/settings/SettingsCheckButton.gd:	if not settings_section.is_empty() and not settings_key.is_empty():
addons/goat/settings/SettingsCheckButton.gd:	if not settings_section.is_empty() and not settings_key.is_empty():
addons/goat/globals/goat_inventory.gd:		if not _items.is_empty():
addons/goat/globals/goat_settings.gd:	if loaded_locales.is_empty():
addons/goat/main_scenes/Player.gd:			if overlapping_bodies.is_empty():
addons/goat/main_scenes/DetailedInteraction.gd:	if interactive_item.unique_name.is_empty():
addons/goat/helper_scenes/InventoryItems.gd:		not goat_inventory.get_items().is_empty()
addons/goat/helper_scenes/InventoryItems.gd:	var inventory_empty = new_items.is_empty()

All similar checks should be reviewed and corrected as well, unless future versions of Godot v4 bring back the "cast to boolean" feature. In that case, the check can be changed to != again (which is more concise).

@miskatonicstudio miskatonicstudio added refactoring Code structure has to be improved godot4 Aftermath of the Godot 4 migration labels Sep 4, 2023
@miskatonicstudio
Copy link
Owner Author

It turned out this was a bug in Godot 4.0.3. GOAT now uses Godot 4.1.1, and therefore this is fixed. All the changes can now be reverted ;)

@miskatonicstudio miskatonicstudio pinned this issue Apr 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
godot4 Aftermath of the Godot 4 migration refactoring Code structure has to be improved
Projects
None yet
Development

No branches or pull requests

1 participant