Skip to content

Instantly share code, notes, and snippets.

View hiulit's full-sized avatar
💻
Working

hiulit

💻
Working
View GitHub Profile
@securas
securas / block_tileset.gd
Created August 6, 2020 15:02
A custom godot autotiler for blocks
tool
extends TileSet
const EMPTY_AUTOTILE = Vector2( 4, 0 )
var block_tiles = [ "blocks" ]
func _forward_subtile_selection(autotile_id : int, _bitmask : int, tilemap : Object, tile_location : Vector2 ):
if block_tiles.find( tile_get_name( autotile_id ) ) < 0:
@cenullum
cenullum / circle.shader
Created October 18, 2020 16:30
Godot Engine Circle with Outline Color Shader
shader_type canvas_item;
uniform vec4 outline_color:hint_color = vec4(1.0,1.0,0.0,1.0);
uniform float inner_circle=0.45;
uniform float outer_circle=0.5;
const vec4 alpha_color= vec4(0,0,0,0);
uniform float smoothness=0.01;
shader_type canvas_item;
render_mode blend_mix;
uniform float noiseSize : hint_range(0, 50) = 15.0;
uniform float speed : hint_range(-10.0, 10.0);
uniform float albedo : hint_range(0.0, 1.0) = 0.7;
float rand(vec2 coord) {
return fract(sin(dot(coord, vec2(35, 62)) * 1000.0) * 1000.0);
}
@jordanlis
jordanlis / godot_2d_wind_shader.txt
Last active January 21, 2021 01:52
godot 2D wind shader
// original wind shader from https://github.com/Maujoe/godot-simple-wind-shader-2d/tree/master/assets/maujoe.simple_wind_shader_2d
// original script modified by HungryProton so that the assets are moving differently : https://pastebin.com/VL3AfV8D
//
// speed - The speed of the wind movement.
// minStrength - The minimal strength of the wind movement.
// maxStrength - The maximal strength of the wind movement.
// strengthScale - Scalefactor for the wind strength.
// interval - The time between minimal and maximal strength changes.
// detail - The detail (number of waves) of the wind movement.
// distortion - The strength of geometry distortion.
@Sephirothphoenix
Sephirothphoenix / Crystal.shader
Created February 25, 2021 05:58
Robe Shaders (Golden Scythe, Godot)
shader_type canvas_item;
void fragment() {
// Color of the current pixel
vec4 oC = texture(TEXTURE, UV);
// Get the difference between the current pixel color and the color to replace, and replace the color
// Exterior Main
if (max(max(max(abs(oC.r - 0.408), abs(oC.g - 0.282)), abs(oC.b - 0.471)), abs(oC.a - 1.0)) <= 0.01){oC = vec4(
@AnidemDex
AnidemDex / flow_container.gd
Last active April 24, 2022 16:27
Node Container that wraps its childs nodes in its rect
tool
extends Container
#class_name FlowContainer
## Modified version of
## https://github.com/godotengine/godot/pull/56104 to be used in versions previous 3.5
## by AnidemDex
## Use it as you want
@WolfgangSenff
WolfgangSenff / gist:168cb0cbd486c8c9cd507f232165b976
Last active February 15, 2025 13:44
Godot 4.0 Migration/Upgrade guide
## For a beginner-friendly version of the following (more advanced users likely will get better use of the below,
## if you're just starting out...), see this new gist:
## https://gist.github.com/WolfgangSenff/0a9c1d800db42a9a9441b2d0288ed0fd
This document represents the beginning of an upgrade or migration document for GDScript 2.0 and Godot 4.0. I'm focusing on 2D
at the moment as I'm upgrading a 2D game, but will hopefully have more to add for 3D afterward.
## If you want more content like this, please help fund my cat's medical bills at https://ko-fi.com/kyleszklenski - thank you very much! On to the migration guide.
@fenix-hub
fenix-hub / dateToUnixTimestamp.gd
Last active February 11, 2022 19:21
Converts an ISO 8601 Date String to UNIX Timestamp int
# The best option is always to confront dates based on their UNIX value
# With these scripts, you'll get something like "16778909182". Put it in the Array and sort it with the others.
var timestamp: String = "2021-08-04T16:45:35.603Z"
# Using String, Arrays and Dictionary
var datetime: PoolStringArray = timestamp.split("T")
var date: PoolStringArray = datetime[0].split("-")
var time: PoolStrngArray = datetime[1].split(":")
var unix_timestamp: int = OS.get_unix_time_from_datetime({year=date[0],month=date[1],day=date[2],hour=time[0],minute=time[1],second=time[2].substr(0,2)}
@Xrayez
Xrayez / gcd_lcm.lua
Last active April 16, 2023 12:53
Greatest Common Divisor (GCD) and Least Common Multiple (LCM) implemented in Lua
-- Greatest Common Divisor (Euclidean algorithm).
function math.gcd(a, b)
local t
while b ~= 0 do
t = b
b = math.fmod(a, b)
a = t
end
return a
end
@fenix-hub
fenix-hub / #description.md
Last active May 6, 2025 16:37
GDScript JSON <> Class Serializer/Deserializer

You can find usages in the GDScript Unirest plugin

This is a fast serializer/deserializer written in GDScript to convert a JSON (Dictionary) to a class, using something similar to the Reflection concecpt. json_to_class can be used to convert a Dictionary to a Class. All keys in the Dictionary will be treated as variables and their types will be guessed in the best way possible. A class (defined by the class_name keyword) must extend Reference or Object or be an inner class, or else Godot will not able to see its properties. It is also possible to deserialize a JSON key to a class property with a different name using the export hint as a variable name.

example usage: