{"id":63,"date":"2024-05-17T07:01:25","date_gmt":"2024-05-17T07:01:25","guid":{"rendered":"https:\/\/dasnaddy.de\/?page_id=63"},"modified":"2024-05-21T11:04:31","modified_gmt":"2024-05-21T11:04:31","slug":"godot-snippets","status":"publish","type":"page","link":"https:\/\/dasnaddy.de\/index.php\/godot-snippets\/","title":{"rendered":"Godot Snippets"},"content":{"rendered":"\n<p>Just a collection of little things that can make your life in Godot easier.<\/p>\n\n\n<ul class=\"simpletoc-list\">\n<li><a href=\"#tool-notation\">@tool notation<\/a>\n\n<\/li>\n<li><a href=\"#create-your-own-hints-for-export-vars\">Create your own hints for export vars<\/a>\n\n<\/li>\n<li><a href=\"#create-your-own-signals\">Create your own signals<\/a>\n\n<\/li>\n<li><a href=\"#global-classes-for-your-game\">Global Classes for your game<\/a>\n\n<\/li>\n<li><a href=\"#use-enums-for-selections-in-export-vars\">Use enums for selections in export vars<\/a>\n<\/li><\/ul>\n\n<h4 class=\"wp-block-heading\" id=\"tool-notation\">@tool notation<\/h4>\n\n\n<p>With the @tool notation you can make scripts executable in the editor<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"create-your-own-hints-for-export-vars\">Create your own hints for export vars<\/h4>\n\n\n<pre class=\"wp-block-code\"><code>## -1 for all\n@export var my_export_var:String<\/code><\/pre>\n\n\n\n<p>With this the &#8220;-1 for all&#8221; will be shown when the mouse hovers over the variable in the inspector.<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"create-your-own-signals\">Create your own signals<\/h4>\n\n\n<p>You can create your own signals in your scripts to trigger stuff in your game.<\/p>\n\n\n\n<p>These are then also visible in the side men\u00fc (where the others signals are located)<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"global-classes-for-your-game\">Global Classes for your game<\/h4>\n\n\n<p>You can set up classes that are loaded by the game engine and globally accessable in all scripts you use. To do so add the class you want to be autoloaded and global in die Project-Settings-&gt;Autoload. <\/p>\n\n\n\n<p>You than can access the class via the name you have given it in the autload setup<\/p>\n\n\n<h4 class=\"wp-block-heading\" id=\"use-enums-for-selections-in-export-vars\">Use enums for selections in export vars<\/h4>\n\n\n<p>When you use an enum for selection you won&#8217;t have to remember ids or exact strings<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@export_enum&#91;\"first\", \"second\", \"third\"] var test:String<\/code><\/pre>\n\n\n\n<p>to save the string itself, or<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@export_enum&#91;\"first\", \"second\", \"third\"] var test:int<\/code><\/pre>\n\n\n\n<p>to save the integer of the position inside the enum<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Just a collection of little things that can make your life in Godot easier. @tool notation With the @tool notation you can make scripts executable in the editor Create your own hints for export vars With this the &#8220;-1 for all&#8221; will be shown when the mouse hovers over the variable in the inspector. Create [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"class_list":["post-63","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/pages\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":7,"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/pages\/63\/revisions"}],"predecessor-version":[{"id":131,"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/pages\/63\/revisions\/131"}],"wp:attachment":[{"href":"https:\/\/dasnaddy.de\/index.php\/wp-json\/wp\/v2\/media?parent=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}