Skip to content

Instantly share code, notes, and snippets.

View WolfgangSenff's full-sized avatar

Kyle Szklenski WolfgangSenff

View GitHub Profile
@WolfgangSenff
WolfgangSenff / gist:54c873a696eaf465a8cb2cc859cff782
Last active December 9, 2025 13:36
Any script with class_name template
# meta-name: ClassNamed
# meta-description: Auto-class_name anything
class_name _CLASS_
extends _BASE_
# To use: in a Godot project, add a script_templates folder, add a sub-folder of it named Object, and copy/paste the above into a file named class_named.gd.
# Then, when creating a new resource, have it inherit Resource in the editor for the new script creation, and tap on the checkbox next to template, and select the new ClassNamed template. When you give it a name for the .gd file, it'll put the name instead of _CLASS_. This works for any type you want to add.
var db_ref
func _ready() -> void:
Firebase.Auth.login_succeeded.connect(_on_FirebaseAuth_login_succeeded)
Firebase.Auth.login_with_email_and_password(email, password)
func _on_FirebaseAuth_login_succeeded(auth):
db_ref = Firebase.Database.get_database_reference("config", {})
db_ref.new_data_update.connect(_on_db_data_update)
db_ref.patch_data_update.connect(_on_db_data_update)
@WolfgangSenff
WolfgangSenff / button_group_container.gd
Last active September 3, 2025 16:34
button_group_container.gd
extends Container # Can make this extend any type you want, and give it an appropriate name accordingly
class_name ButtonGroupContainer
var _group = ButtonGroup.new()
func _ready() -> void:
for child in get_children():
if child is BaseButton:
child.toggle_mode = true
child.button_group = _group
@WolfgangSenff
WolfgangSenff / compile_android_all_mac.sh
Last active July 9, 2025 13:15
Build script for entire Android stack on a Mac for Godot 3.x
#!/bin/bash
# Build engine
scons platform=osx arch=arm64
# Build Android code
scons platform=android target=release android_arch=armv7
scons platform=android target=release_debug android_arch=armv7
scons platform=android target=release android_arch=arm64v8
@WolfgangSenff
WolfgangSenff / firestore_document.gd
Last active July 3, 2025 13:23
Test new Firestore document listeners
## @meta-authors Kyle Szklenski
## @meta-version 2.2
## A reference to a Firestore Document.
## Documentation TODO.
@tool
class_name FirestoreDocument
extends Node
# A FirestoreDocument objects that holds all important values for a Firestore Document,
# @doc_name = name of the Firestore Document, which is the request PATH
var view = {
root = control({
mouse_filter = MOUSE_FILTER_IGNORE
}, [
vbox({ size_flags_horizontal = SIZE_EXPAND, size_flags_vertical = SIZE_SHRINK_CENTER },
[
label({ text = "Player Name:" }),
label({ text = data.player_name.value() })
]
)
@WolfgangSenff
WolfgangSenff / variable_checker.gd
Created April 16, 2025 14:56
Variable checker for Godot
# This useful little class can be created in a node and it'll make it so you can, on a timer, check the value of a specific variable by simply passing in the variable name
class_name VariableChecker
extends Timer
func _init(check_time: float, variable_name: String, check_against: Node) -> void:
wait_time = check_time
autostart = true
timeout.connect(func(): print(check_against[variable_name]))
check_against.add_child(self)
@WolfgangSenff
WolfgangSenff / gist:f0d3f807966b244ee6e3d79db5faf1cc
Last active October 11, 2024 15:47
Godot safe_navigate implementation
# This can be static if you have a nice place to put it. I just have it in one spot, not static.
func safe_navigate(root: Variant, path: String) -> Variant:
var properties = path.split(".")
var current_value = root
for prop in properties:
if current_value == null:
print_debug("Navigation stopped: '", prop, "' is null.")
return null
elif not is_instance_valid(current_value):
@WolfgangSenff
WolfgangSenff / array_resource.gd
Last active November 11, 2024 19:50
MVVM in Godot
class_name ArrayResource
extends Resource
var _values = []:
set(value):
_values = value
emit_changed()
func _init(initial_values: Array = []) -> void:
if not initial_values.is_empty():
class_name DaisyChain
extends RefCounted
# Basic signal with early stop implementation
var _callables = []
func chain(callable: Callable) -> DaisyChain:
_callables.push_back(callable)
return self