Skip to content

Instantly share code, notes, and snippets.

nonunknown / ColorRangeSwap.shader
Last active September 23, 2021 23:22
Color Range Swap
View ColorRangeSwap.shader
shader_type canvas_item;
uniform float _min;
uniform float _max;
uniform vec4 color : hint_color;
vec3 rgb2hsv(vec3 c)
vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0);
vec4 p = mix(vec4(, K.wz), vec4(, K.xy), step(c.b, c.g));
nonunknown /
Last active September 23, 2021 12:34
Godot & Javascript - How to deal with async results

Godot & Javascript - How to deal with async results

My task: Get a function of godot called by Javascript! The Problem: godot's javascript class, doesnt support functions which doesnt return the value immediately

So, this is a step by step of what I've done, I'm using Node.js with a godot application which needs to get data from that node.js server!

First Step

nonunknown /
Created September 19, 2021 20:49
[Godot 4] Convert AnimatedSprite to AnimationPlayer
extends Control
@export var gen:bool = false :
if !value: return
gen = false
nonunknown /
Created September 18, 2021 19:48
[Godot 4] State machine
extends RefCounted
class_name StateMachine
## This is a state machine implementation, very optimize w/ code organization on your side
var _states_enter:Array[StringName]
var _states_update:Array[StringName]
var _states_exit:Array[StringName]
var _current_state:int = 0
nonunknown /
Last active August 25, 2021 23:37
A statemachine for godot!
extends Reference
class_name StateMachine
var target = null
var machine:Dictionary = {
state = null,
last_state = null,