Kehom / GodotAddonPack

A collection of pure GDScript addons for Godot
http://kehomsforge.com
MIT License
183 stars 15 forks source link

[Network] WebSockets - No check if available #26

Closed paultech closed 2 years ago

paultech commented 3 years ago

No check is done if WebSockets module has been installed.

SCRIPT ERROR: GDScript::reload: Parse Error: The identifier "WebSocketServer" isn't a valid type (not a script or class), or couldn't be found on base "self". At: res://addons/keh_network/network.gd:403. ERROR: reload: Method failed. Returning: ERR_PARSE_ERROR At: modules/gdscript/gdscript.cpp:599. ERROR: start: Script does not inherit a Node: res://addons/keh_network/network.gd At: main/main.cpp:1763.

I have module_websocket_enabled = "no" in my godot build.

The only way I can think to fix would be checking if ClassDB.can_instance() the WebSocketServer prior to attempting to ref it.

Not a major issue if no clean fix can be found.

Kehom commented 3 years ago

Hi,

Oh, I didn't think about the possibility of this addon running on different Godot builds!

The suggested ClassDB.can_instance() seems to be the way to go.

Thanks for pointing this out!