mirror of
https://github.com/drwhut/tabletop-club.git
synced 2025-05-05 23:42:57 +00:00
45 lines
1.6 KiB
ReStructuredText
45 lines
1.6 KiB
ReStructuredText
.. _coding-guidelines:
|
|
|
|
=================
|
|
Coding guidelines
|
|
=================
|
|
|
|
When modifying the game's scenes and scripts, as well as following Godot's
|
|
`GDScript style guide`_, make sure to follow these guidelines for consistency,
|
|
and to make everyone's lives easier:
|
|
|
|
* Only use GDScript for scripting.
|
|
|
|
* When writing code, make sure your editor (whether it's Godot, or another
|
|
external editor) is set to use tabs instead of spaces.
|
|
|
|
* When creating a new script, use the ``Copyright Notice`` template in
|
|
``game/Scripts/Templates/CopyrightNotice.gd``.
|
|
|
|
* Use typed variables, arguments, and return values where possible.
|
|
|
|
* When writing functions in scripts that aren't built in functions (e.g.
|
|
``_ready()``) or functions called by signals (e.g. ``_on_*``), then please
|
|
add a comment above the function describing what the function does, what it's
|
|
return value is (if any), and what the arguments are. For example:
|
|
|
|
.. code-block::
|
|
|
|
# Return the element at the given index.
|
|
# Returns: The element at index i.
|
|
# i: The index of the element to return.
|
|
func get_element(i: int) -> int:
|
|
# ...
|
|
|
|
* Make sure to fix any warnings Godot shows in scripts.
|
|
|
|
* If you are writing strings that will get displayed in the UI, remember to use
|
|
the ``tr()`` function so the text can be translated.
|
|
|
|
* When creating new scenes, fill in the editor description for the root node
|
|
explaining what the scene does. Also fill in the editor description for any
|
|
nodes in the scene where it isn't obvious what they're there for.
|
|
|
|
|
|
.. _GDScript style guide: https://docs.godotengine.org/en/stable/getting_started/scripting/gdscript/gdscript_styleguide.html
|