This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # how to simulate a class property that can be asigned only the first time, like a 'final' property in java or a 'readonly' property in C# | |
| #class_name ReadOnly | |
| extends Node | |
| # READONLY NON OBJECT WITH SPECIFIC TYPE | |
| var readonly_int:int: | |
| set(p): | |
| if readonly_int != 0:printerr('cannot set readonly property "readonly_int" a second time'); return | |
| readonly_int = p |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node | |
| func pack(p:Node)->PackedScene: var v = PackedScene.new(); v.pack(p); return v | |
| class A extends Node: | |
| @export var m: String = "a" | |
| static func instantiate(p:PackedScene): | |
| var v: A = p.instantiate() | |
| v._post_init() | |
| return v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node | |
| var info: Array = [] | |
| func _ready() -> void: | |
| add_child_test('Node') | |
| for i in ClassDB.get_inheriters_from_class('Node'): | |
| if not ClassDB.can_instantiate(i): continue | |
| add_child_test(i) | |
| info.sort_custom(func(l, r): return l.time < r.time) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| extends Node | |
| func _notification(what: int) -> void: | |
| if what == Object.NOTIFICATION_PREDELETE: | |
| # post_delete is a static method, thus it can be called deferredly even by dying objects. Beware that an object can be "saved" from a queue_free call by calling cancel_free, but a free call (instead of queue_free) should kill it imediatly without chance for survival | |
| post_delete.call_deferred(get_instance_id(), get_path()) | |
| static func post_delete(id: int, path: NodePath) -> void: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [gd_resource type="Theme" load_steps=3 format=3 uid="uid://ddcimt5j11lgc"] | |
| [sub_resource type="Image" id="Image_8ojfe"] | |
| data = { | |
| "data": PackedByteArray(0, 0, 0, 0), | |
| "format": "RGBA8", | |
| "height": 1, | |
| "mipmaps": false, | |
| "width": 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| RESUMINHO SIMPLES SOBRE ESTRUTURAS DE DADOS | |
| - Em programação existem "dados simples": | |
| - numeros inteiros: -1, 0, 1, etc. | |
| - numeros reais: -1.5, 0.1, 9.9, etc | |
| - valores booleanos: verdadeiro ou falso, que no fim das contas eh um inteiro onde 0 significa falso e qualquer outra coisa eh verdadeiro | |
| - strings (texto): apenas uma sequencia de caracteres, os quais por sua vez sao inteiros | |
| - E existem "dados compostos", que sao criados pelo programador para agrupar dados simples de forma a representar coisas mais complexas. Ex.: para representar uma pessoa podemos criar um dado composto com 2 membros (campos): idade (int) e nome (string) | |
| - Tanto dados simples e compostos podem ser agrupados de forma homogenea em arrays (vetores), que são meramente o agrupamento linear contíguo de N dados daquele mesmo tipo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class_name Utils | |
| static func file_exists_(prespath:String, pforceexactmatch:bool=false)->bool: | |
| if prespath.begins_with('res://') and not pforceexactmatch: | |
| return FileAccess.file_exists(prespath) or FileAccess.file_exists(prespath+'.remap') or FileAccess.file_exists(prespath+'.import') | |
| else: | |
| return FileAccess.file_exists(prespath) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # as of godot 4.1 | |
| _static_init | |
| _init | |
| _notification 20 Node.NOTIFICATION_SCENE_INSTANTIATED # only on instantiated scene roots | |
| _notification 18 Node.NOTIFICATION_PARENTED | |
| _enter_tree | |
| tree_entered signal | |
| _notification 27 Node.NOTIFICATION_POST_ENTER_TREE | |
| _ready | |
| ready signal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [gd_resource type="Theme" load_steps=3 format=2] | |
| [sub_resource type="Image" id=3] | |
| data = { | |
| "data": PackedByteArray( 0, 0, 0, 0 ), | |
| "format": "RGBA8", | |
| "height": 1, | |
| "mipmaps": false, | |
| "width": 1 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # ScriptTester.tscn | |
| # ScriptTester.gd | |
| @tool | |
| extends Node | |
| @export var mtool_do_test_scripts:bool: | |
| get: return false | |
| set(p): | |
| mtool_do_test_scripts = false | |
| if p: tool_do_test_scripts() | |
| func _ready(): |
NewerOlder