Skip to content

Instantly share code, notes, and snippets.

View Crystalwarrior's full-sized avatar
🎮
Gamer Mode

Crystalwarrior

🎮
Gamer Mode
View GitHub Profile
@jotson
jotson / screenshot.gd
Last active March 15, 2024 14:40
Godot GDScript screenshot function
# This is a function for capturing screenshots with GDScript
func screenshot():
# Capture the screenshot
var size = OS.window_size
var image = get_viewport().get_texture().get_data()
# Setup path and screenshot filename
var date = OS.get_datetime()
var path = "user://screenshots"
var file_name = "screenshot-%d-%02d-%02dT%02d:%02d:%02d" % [date.year, date.month, date.day, date.hour, date.minute, date.second]
@NovemberDev
NovemberDev / godot_async_scene_loader.gd
Last active March 12, 2025 16:00
Asynchronously loads scenes in godot
# Loads a scene in the background using a seperate thread and a queue.
# Foreach new scene there will be an instance of ResourceInteractiveLoader
# that will raise an on_scene_loaded event once the scene has been loaded.
# Hooking the on_progress event will give you the current progress of any
# scene that is being processed in realtime. The loader also uses caching
# to avoid duplicate loading of scenes and it will prevent loading the
# same scene multiple times concurrently.
#
# Sample usage:
#
@ssokolow
ssokolow / image_widget.py
Last active October 25, 2024 22:12
PyQt 5.x code for Just Do What I Mean™ image display in the presence of animated GIFs and containers with no fixed aspect ratio
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Example code for a PyQt image-display widget which Just Works™
TODO: Split this into a loader wrapper and a widget wrapper so it can be used
in designs which maintain a preloaded queue of upcoming images to improve
the perception of quick load times.
"""
from __future__ import (absolute_import, division, print_function,
@mtimkovich
mtimkovich / gif_animatedtexture.py
Created February 28, 2019 23:27
Break a GIF into its PNG frames and create a AnimatedTexture .tres for them.
import argparse
import os
from PIL import Image
parser = argparse.ArgumentParser(
description='Convert GIF into frames and then create '
'AnimatedTexture .tres')
parser.add_argument('gif', help='GIF to process')
args = parser.parse_args()
@Zertuk
Zertuk / text-box-label-container.gd
Last active December 8, 2025 15:16
godot textbox with typewriter effect, shake, wavy, slow, and colored letters
extends Node2D
var timeToShow = 5
var originalPosition
var waveDelay = 0
var isWavy = false
var wavyDirection = 1
var isShakey = false
@Rumrusher
Rumrusher / Mount.lua
Created October 9, 2013 16:17
CHOOSE YOUR MOUNTS To apply this you need to go into the unit's profile in adventure mode, fort mode is just highlight and enter. first pick is Rider, the second is mount, this code is a modify version of Hugelueman's marry revise code... also warmists.
function Mount (rider,horse)
--for k,horse in pairs(unit_list) do
--if unit_rider.pos.x==horse.pos.x and unit_rider.pos.y==horse.pos.y
--and unit_rider.pos.z==horse.pos.z then --check if they are on the same tile
horse.general_refs:insert("#",{new=df.general_ref_unit_riderst,unit_id=rider.id})
rider.relations.rider_mount_id=horse.id
rider.flags1.rider=true
horse.flags1.ridden=true
require("utils").insert_sorted(df.global.world.units.other.ANY_RIDER,rider,"id")
return