mirror of
https://github.com/godotengine/godot-vscode-plugin.git
synced 2025-12-31 13:48:24 +03:00
Add some useful GDScript snippets for Godot 4 (#794)
This commit is contained in:
@@ -6,14 +6,12 @@
|
||||
"\t$3"
|
||||
]
|
||||
},
|
||||
|
||||
"Print messages to console": {
|
||||
"prefix": "pr",
|
||||
"body": [
|
||||
"print($1)"
|
||||
]
|
||||
},
|
||||
|
||||
"_ready method of Node": {
|
||||
"prefix": "ready",
|
||||
"body": [
|
||||
@@ -21,7 +19,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_init method of Object": {
|
||||
"prefix": "init",
|
||||
"body": [
|
||||
@@ -29,7 +26,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_process method of Node": {
|
||||
"prefix": "process",
|
||||
"body": [
|
||||
@@ -37,7 +33,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_physics_process method of Node": {
|
||||
"prefix": "physics",
|
||||
"body": [
|
||||
@@ -45,7 +40,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_input method of Node": {
|
||||
"prefix": "input",
|
||||
"body": [
|
||||
@@ -53,7 +47,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_input_event method of Node": {
|
||||
"prefix": "inpute",
|
||||
"body": [
|
||||
@@ -61,7 +54,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_unhandled_input method of Node": {
|
||||
"prefix": "uinput",
|
||||
"body": [
|
||||
@@ -69,7 +61,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_draw method of Node": {
|
||||
"prefix": "draw",
|
||||
"body": [
|
||||
@@ -77,7 +68,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"_gui_input method of Node": {
|
||||
"prefix": "guii",
|
||||
"body": [
|
||||
@@ -85,7 +75,6 @@
|
||||
"\t${1:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"for loop": {
|
||||
"prefix": "for",
|
||||
"body": [
|
||||
@@ -93,7 +82,6 @@
|
||||
"\t${3:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"for range loop": {
|
||||
"prefix": "for",
|
||||
"body": [
|
||||
@@ -101,7 +89,6 @@
|
||||
"\t${4:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"if elif else": {
|
||||
"prefix": "if",
|
||||
"body": [
|
||||
@@ -113,7 +100,6 @@
|
||||
"\t${5:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"if else": {
|
||||
"prefix": "if",
|
||||
"body": [
|
||||
@@ -123,7 +109,6 @@
|
||||
"\t${3:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"if": {
|
||||
"prefix": "if",
|
||||
"body": [
|
||||
@@ -131,7 +116,6 @@
|
||||
"\t${2:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"while": {
|
||||
"prefix": "while",
|
||||
"body": [
|
||||
@@ -139,7 +123,6 @@
|
||||
"\t${2:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"function define": {
|
||||
"prefix": "func",
|
||||
"body": [
|
||||
@@ -147,56 +130,48 @@
|
||||
"\t${3:pass}"
|
||||
]
|
||||
},
|
||||
|
||||
"match": {
|
||||
"prefix": "match",
|
||||
"body": [
|
||||
"match ${1:expression}:\n\t${2:pattern}:\n\t\t${3}\n\t_:\n\t\t${0:default}"
|
||||
]
|
||||
},
|
||||
|
||||
"signal declaration": {
|
||||
"prefix": "signal",
|
||||
"body": [
|
||||
"signal ${1:signalname}(${2:args})"
|
||||
]
|
||||
},
|
||||
|
||||
"export variables": {
|
||||
"prefix": "export",
|
||||
"body": [
|
||||
"export(${1:type}${2:,other_configs}) var ${3:name}${4: = default}${5: setget }"
|
||||
"@export(${1:type}${2:,other_configs}) var ${3:name}${4: = default}${5: setget }"
|
||||
]
|
||||
},
|
||||
|
||||
"define variables": {
|
||||
"prefix": "var",
|
||||
"body": [
|
||||
"var ${1:name}${2: = default}${3: setget }"
|
||||
]
|
||||
},
|
||||
|
||||
"define onready variables": {
|
||||
"prefix": "onready",
|
||||
"body": [
|
||||
"onready var ${1:name} = get_node($2)"
|
||||
]
|
||||
},
|
||||
|
||||
"Is instance of a class or script": {
|
||||
"prefix": "is",
|
||||
"body": [
|
||||
"${1:instance} is ${2:class}"
|
||||
]
|
||||
},
|
||||
|
||||
"element in array": {
|
||||
"prefix": "in",
|
||||
"body": [
|
||||
"${1:element} in ${$2:array}"
|
||||
]
|
||||
},
|
||||
|
||||
"GDScript template": {
|
||||
"prefix": "gdscript",
|
||||
"body": [
|
||||
@@ -213,11 +188,98 @@
|
||||
""
|
||||
]
|
||||
},
|
||||
|
||||
"pass statement": {
|
||||
"prefix": "pass",
|
||||
"body": [
|
||||
"pass"
|
||||
]
|
||||
},
|
||||
"GDScript Void": {
|
||||
"prefix": [
|
||||
"void"
|
||||
],
|
||||
"body": [
|
||||
"func ${1:function_name}($2) -> void:",
|
||||
"\t${3:pass}"
|
||||
],
|
||||
"description": "Void function"
|
||||
},
|
||||
"GDScript Load Resource": {
|
||||
"prefix": [
|
||||
"loadres",
|
||||
"ld"
|
||||
],
|
||||
"body": [
|
||||
"load(\"res://${1:resource_path}\")$0"
|
||||
],
|
||||
"description": "Quickly load a resource with the 'res://' prefix"
|
||||
},
|
||||
"GDScript Preload Resource": {
|
||||
"prefix": [
|
||||
"preloadres",
|
||||
"pl"
|
||||
],
|
||||
"body": [
|
||||
"preload(\"res://${1:resource_path}\")$0"
|
||||
],
|
||||
"description": "Quickly preload a resource with the 'res://' prefix"
|
||||
},
|
||||
"GDScript Variable with Getter and Setter": {
|
||||
"prefix": [
|
||||
"gs",
|
||||
"vargetset"
|
||||
],
|
||||
"body": [
|
||||
"var ${1:variable_name}:",
|
||||
"\tget:",
|
||||
"\t\treturn ${1:variable_name}",
|
||||
"\tset(value):",
|
||||
"\t\t${1:variable_name} = value"
|
||||
],
|
||||
"description": "Creates a variable with getter and setter functions in GDScript"
|
||||
},
|
||||
"GDScript Variable with Getter and Setter (typed)": {
|
||||
"prefix": [
|
||||
"gst",
|
||||
"vargetsettyped"
|
||||
],
|
||||
"body": [
|
||||
"var ${1:variable_name}: ${2:String}:",
|
||||
"\tget:",
|
||||
"\t\treturn ${1:variable_name}",
|
||||
"\tset(value):",
|
||||
"\t\t${1:variable_name} = value"
|
||||
],
|
||||
"description": "Creates a typed variable with getter and setter functions in GDScript"
|
||||
},
|
||||
"GDScript export var": {
|
||||
"prefix": [
|
||||
"exportvar",
|
||||
"xp"
|
||||
],
|
||||
"body": [
|
||||
"export var ${1:variable_name}: ${2:String} = ${3:default_value}"
|
||||
],
|
||||
"description": "Creates an exported (typed) variable in GDScript"
|
||||
},
|
||||
"GDScript tween": {
|
||||
"prefix": [
|
||||
"tween",
|
||||
"tw"
|
||||
],
|
||||
"body": [
|
||||
"var tween := create_tween()"
|
||||
],
|
||||
"description": "Creates a tween object"
|
||||
},
|
||||
"GDScript wait": {
|
||||
"prefix": [
|
||||
"wait",
|
||||
"timer"
|
||||
],
|
||||
"body": [
|
||||
"await get_tree().create_timer($1).timeout"
|
||||
],
|
||||
"description": "Waits for a given amount of seconds"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user