From 53981c55f9e082133b19b575cb9d95ec95c2ceb1 Mon Sep 17 00:00:00 2001 From: JeremyStarTM Date: Thu, 25 Apr 2024 17:30:20 +0200 Subject: [PATCH] Fix typo and writing --- docs/docs/guides/custom-modules.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/docs/guides/custom-modules.md b/docs/docs/guides/custom-modules.md index 7c27ef6..e0d26eb 100644 --- a/docs/docs/guides/custom-modules.md +++ b/docs/docs/guides/custom-modules.md @@ -10,13 +10,13 @@ Custom modules in CORE are special scripts that run inside and interact with the Before you write any code, you should decide wheneter to write your code as a module or as a simple script. Generally you **not** write everything used between two classes as a module. Use custom modules for stuff you may want to use across multiple objects or need to use frequently in your codebase. One example of this is a transition script. You'll probably want to transition from one scene to another in a game quite often, writing it as a custom module makes much more sense as it can be accessed globally much easier and can be shared across codebases. ## Bad practise -Before we finally come to some code, never write a custom module if you intend to do the following: +Before we finally come to some code, never avoid these things while writing a custom module: - Access hardcoded classes, scripts, assets, etc. from your project. Use arrays and dictionaries aswell as get(), set() and other functions for that. - Depend on your project code. Modules are intended to be project independent and work in every environment where CORE runs. - Never crash the entire framework on invalid user input, only crash when an internal error occurred. \ Let's say that you have two functions: An internal `_display_scene` method and a `transition_between_scenes` method. \ When the developer calls `transition_between_scenes` and supplies an invalid object to the method, you should call `logger.error` (and return the error) as the error comes from the developer and should be handled by the developer's code. \ - If however your `transition_between_scenes` calls `_display_scene` and supplies an invalid transition type, you should call `logger.crash` instead as your module code as an inconsistency and may not account for that. This ensures your code does not do stupid things *plus* you get a bug report or pull request from an annoyed developer :) + If however your `transition_between_scenes` calls `_display_scene` and supplies an invalid transition type, you should call `logger.crash` instead as your module code has an inconsistency and may not account for that. This ensures your code does not do stupid things *plus* you get a bug report or pull request from an annoyed developer :) - Never create, instantiate or duplicate objects without removing them from the SceneTree and freeing them first. This ensures no memory leaks occur and makes your codebase a bit better. \ If you wonder how to do this, look at CORE's logger. It frees unused `CoreLoggerInstance`s every time CORE's scheduler (`_schedule`) is executed and frees *all* `CoreLoggerInstance`s on framework cleanup (`_cleanup`). - Not defining variable and method return types. Forcing a variable to match a `String` or a method to always return an `int` ensures your code always runs without flaws and invalid user input, saving you a few bugs while improving code quality. If a variable may contain or a method may return multiple types, use `Variant` for everything but objects and `Object` for everything that is an object.