Files
godot-docs-l10n/sphinx/templates/getting_started/step_by_step/scripting.pot
2020-08-11 14:46:10 +02:00

315 lines
16 KiB
Plaintext

# SOME DESCRIPTIVE TITLE.
# Copyright (C) 2014-2020, Juan Linietsky, Ariel Manzur and the Godot community (CC-BY 3.0)
# This file is distributed under the same license as the Godot Engine package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: Godot Engine latest\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-08-11 13:45+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: ../../docs/getting_started/step_by_step/scripting.rst:4
msgid "Scripting"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:7
msgid "Introduction"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:9
msgid "Before Godot 3.0, the only choice for scripting a game was to use :ref:`GDScript<doc_gdscript>`. Nowadays, Godot has four (yes, four!) official languages and the ability to add extra scripting languages dynamically!"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:13
msgid "This is great, mostly due to the large amount of flexibility provided, but it also makes our work supporting languages more difficult."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:16
msgid "The \"main\" languages in Godot, though, are GDScript and VisualScript. The main reason to choose them is their level of integration with Godot, as this makes the experience smoother; both have slick editor integration, while C# and C++ need to be edited in a separate IDE. If you are a big fan of statically typed languages, go with C# and C++ instead."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:22
msgid "GDScript"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:24
msgid ":ref:`GDScript<doc_gdscript>` is, as mentioned above, the main language used in Godot. Using it has some positive points compared to other languages due to its high integration with Godot:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:28
msgid "It's simple, elegant, and designed to be familiar for users of other languages such as Lua, Python, Squirrel, etc."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:29
msgid "Loads and compiles blazingly fast."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:30
msgid "The editor integration is a pleasure to work with, with code completion for nodes, signals, and many other items pertaining to the scene being edited."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:31
msgid "Has vector types built-in (such as Vectors, transforms, etc.), making it efficient for heavy use of linear algebra."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:32
msgid "Supports multiple threads as efficiently as statically typed languages - one of the limitations that made us avoid VMs such as Lua, Squirrel, etc."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:33
msgid "Uses no garbage collector, so it trades a small bit of automation (most objects are reference counted anyway), by determinism."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:34
msgid "Its dynamic nature makes it easy to optimize sections of code in C++ (via GDNative) if more performance is required, all without recompiling the engine."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:36
msgid "If you're undecided and have experience with programming, especially dynamically typed languages, go for GDScript!"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:40
msgid "VisualScript"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:42
msgid "Beginning with 3.0, Godot offers :ref:`Visual Scripting<doc_what_is_visual_script>`. This is a typical implementation of a \"blocks and connections\" language, but adapted to how Godot works."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:46
msgid "Visual scripting is a great tool for non-programmers, or even for experienced developers who want to make parts of the code more accessible to others, like game designers or artists."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:50
msgid "It can also be used by programmers to build state machines or custom visual node workflows - for example, a dialogue system."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:55
msgid ".NET / C#"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:57
msgid "As Microsoft's C# is a favorite amongst game developers, we have added official support for it. C# is a mature language with tons of code written for it, and support was added thanks to a generous donation from Microsoft."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:62
msgid "It has an excellent tradeoff between performance and ease of use, although one must be aware of its garbage collector."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:65
msgid "Since Godot uses the `Mono <https://mono-project.com>`_ .NET runtime, in theory any third-party .NET library or framework can be used for scripting in Godot, as well as any Common Language Infrastructure-compliant programming language, such as F#, Boo or ClojureCLR. In practice however, C# is the only officially supported .NET option."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:71
msgid "GDNative / C++"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:73
msgid "Finally, one of our brightest additions for the 3.0 release: GDNative allows scripting in C++ without needing to recompile (or even restart) Godot."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:77
msgid "Any C++ version can be used, and mixing compiler brands and versions for the generated shared libraries works perfectly, thanks to our use of an internal C API Bridge."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:81
msgid "This language is the best choice for performance and does not need to be used throughout an entire game, as other parts can be written in GDScript or Visual Script. However, the API is clear and easy to use as it resembles, mostly, Godot's actual C++ API."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:86
msgid "More languages can be made available through the GDNative interface, but keep in mind we don't have official support for them."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:90
msgid "Scripting a scene"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:92
msgid "For the rest of this tutorial we'll set up a GUI scene consisting of a button and a label, where pressing the button will update the label. This will demonstrate:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:96
msgid "Writing a script and attaching it to a node."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:97
msgid "Hooking up UI elements via signals."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:98
msgid "Writing a script that can access other nodes in the scene."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:100
msgid "Before continuing, make sure to skim and bookmark the :ref:`GDScript<doc_gdscript>` reference. It's a language designed to be simple, and the reference is structured into sections to make it easier to get an overview of the concepts."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:105
msgid "Scene setup"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:107
msgid "Use the \"Add Child Node\" dialogue accessed from the Scene tab (or by pressing :kbd:`Ctrl + A`) to create a hierarchy with the following nodes:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:110
msgid "Panel"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:112
msgid "Label"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:113
msgid "Button"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:115
msgid "The scene tree should look like this:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:119
msgid "Use the 2D editor to position and resize the Button and Label so that they look like the image below. You can set the text from the Inspector tab."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:124
msgid "Finally, save the scene with a name such as ``sayhello.tscn``."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:129
msgid "Adding a script"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:131
msgid "Right click on the Panel node, then select \"Attach Script\" from the context menu:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:136
msgid "The script creation dialog will pop up. This dialog allows you to set the script's language, class name, and other relevant options."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:139
msgid "In GDScript, the file itself represents the class, so the class name field is not editable."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:142
msgid "The node we're attaching the script to is a panel, so the Inherits field will automatically be filled in with \"Panel\". This is what we want, as the script's goal is to extend the functionality of our panel node."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:146
msgid "Finally, enter a path name for the script and select Create:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:150
msgid "The script will then be created and added to the node. You can see this as an \"Open script\" icon next to the node in the Scene tab, as well as in the script property under Inspector:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:156
msgid "To edit the script, select either of these buttons, both of which are highlighted in the above image. This will bring you to the script editor, where a default template will be included:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:161
msgid "There's not much there. The ``_ready()`` function is called when the node, and all its children, enters the active scene. **Note:** ``_ready()`` is not the constructor; the constructor is instead ``_init()``."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:166
msgid "The role of the script"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:168
msgid "A script adds behavior to a node. It is used to control how the node functions as well as how it interacts with other nodes: children, parent, siblings, and so on. The local scope of the script is the node. In other words, the script inherits the functions provided by that node."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:179
msgid "Handling a signal"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:181
msgid "Signals are \"emitted\" when some specific kind of action happens, and they can be connected to any function of any script instance. Signals are used mostly in GUI nodes, although other nodes have them too, and you can even define custom signals in your own scripts."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:186
msgid "In this step, we'll connect the \"pressed\" signal to a custom function. Forming connections is the first part and defining the custom function is the second part. For the first part, Godot provides two ways to create connections: through a visual interface the editor provides or through code."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:191
msgid "While we will use the code method for the remainder of this tutorial series, let's cover how the editor interface works for future reference."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:194
msgid "Select the Button node in the scene tree and then select the \"Node\" tab. Next, make sure that you have \"Signals\" selected."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:199
msgid "If you then select \"pressed()\" under \"BaseButton\" and click the \"Connect...\" button in the bottom right, you'll open up the connection creation dialogue."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:204
msgid "The top of the dialogue displays a list of your scene's nodes with the emitting node's name highlighted in blue. Select the \"Panel\" node here."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:207
msgid "The bottom of the dialogue shows the name of the method that will be created. By default, the method name will contain the emitting node's name (\"Button\" in this case), resulting in ``_on_[EmitterNode]_[signal_name]``."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:211
msgid "And that concludes the guide on how to use the visual interface. However, this is a scripting tutorial, so for the sake of learning, let's dive into the manual process!"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:215
msgid "To accomplish this, we will introduce a function that is probably the most used by Godot programmers: :ref:`Node.get_node() <class_Node_method_get_node>`. This function uses paths to fetch nodes anywhere in the scene, relative to the node that owns the script."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:220
msgid "For the sake of convenience, delete everything underneath ``extends Panel``. You will fill out the rest of the script manually."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:223
msgid "Because the Button and Label are siblings under the Panel where the script is attached, you can fetch the Button by typing the following underneath the ``_ready()`` function:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:240
msgid "Next, write a function which will be called when the button is pressed:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:255
msgid "Finally, connect the button's \"pressed\" signal to ``_on_Button_pressed()`` by using :ref:`Object.connect() <class_Object_method_connect>`."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:271
msgid "The final script should look like this:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:304
msgid "Run the scene and press the button. You should get the following result:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:308
msgid "Why, hello there! Congratulations on scripting your first scene."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:312
msgid "A common misunderstanding regarding this tutorial is how ``get_node(path)`` works. For a given node, ``get_node(path)`` searches its immediate children. In the above code, this means that Button must be a child of Panel. If Button were instead a child of Label, the code to obtain it would be:"
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:330
msgid "Also, remember that nodes are referenced by name, not by type."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:334
msgid "The 'advanced' panel of the connect dialogue is for binding specific values to the connected function's parameters. You can add and remove values of different types."
msgstr ""
#: ../../docs/getting_started/step_by_step/scripting.rst:338
msgid "The code approach also enables this with a 4th ``Array`` parameter that is empty by default. Feel free to read up on the ``Object.connect`` method for more information."
msgstr ""