Skip to content

Instantly share code, notes, and snippets.

View noidexe's full-sized avatar
👾
Making games. Being happy.

Lisandro Lorea noidexe

👾
Making games. Being happy.
View GitHub Profile
@noidexe
noidexe / post_import_mesh_deduplicator.gd
Created September 2, 2024 13:59
Post Import script with mesh deduplication
@tool
extends EditorScenePostImport
func _post_import(scene: Node) -> Object:
_deduplicate_meshes(scene, true)
return scene
# Finds duplicate meshes and deduplicates them, using a content hash for comparison
func _deduplicate_meshes(scene : Node, verbose := false) -> void:
var start_time := Time.get_ticks_msec()
@noidexe
noidexe / stable_sort_by_prop.gd
Last active May 24, 2024 00:13
Stable Sort by Property Value
# Implements a stable sort as requested in https://www.reddit.com/r/godot/comments/1cyyaxo/are_there_any_plans_to_implement_a_stable_sorting/
# in the worst possible way
extends Node
class TestObject extends RefCounted:
const SUITES = ['♠️','♣️','♥️','♦️']
var an_int : int
var a_float : float
var a_string : String
@noidexe
noidexe / YeOldeGDScriptFunctionStateTest.gd
Created February 15, 2024 14:42
Godot 3-style coroutines in Godot 4
extends Node3D
##################################################################
## your scientists were so preoccupied with whether or not they ##
## could that they didn't stop to think if they should. ##
##################################################################
class YeOldeGDScriptFunctionState extends RefCounted:
#region Private
var _suspended := false # state of the coroutine
var _resume_arg : Variant # argument passed to resume()
@noidexe
noidexe / MultiAwait.gd
Created February 14, 2024 21:42
Godot 4 await parallel calls
extends RefCounted
class_name MultiAwaiter
## Can await till multiple method calls are done
##
## You use it like:
## [codeblock]
## var awaiter = MultipleAwait.new()
## awaiter.push_method( my_func.bind(arg_a, arg_b, ...) )
## await awaiter.run() # You can also connect stuff to it's completed signal
## [/codeblock]
@noidexe
noidexe / audio_stream_player_with_counter.gd
Created September 9, 2022 03:35 — forked from hiulit/audio_stream_player_with_counter.gd
AudioStreamPlayer with a counter, which counts the seconds elapsed and emits a signal each second
extends AudioStreamPlayer
class_name AudioStreamPlayerWithCounter
signal playback_position_reached(number)
var counter: int = 0
var trigger_map = {}
class Trigger extends Reference:
@noidexe
noidexe / FixNetFolder.cmd
Last active May 15, 2021 01:34
Fix Windows 10 being unable to access network shares or networked computers
@echo off
echo.===== RESTARTING LanmanWorkstation and dependencies =====
powershell -command "Restart-Service LanmanWorkstation -Force" && echo.===== DONE ===== || echo.### ERROR ### Did you remember to right click-^>Run as Administrator? If you still get an error after that then there is some other problem.
PAUSE
@noidexe
noidexe / IconPNGAsAudio.gd
Last active April 13, 2021 23:07
User icon.png as Audio
tool
extends AudioStreamPlayer
# "We were so preoccupied with whether or not we could, we didn’t stop to think if we should."
var sample_hz = 8000.0 # Adjust and enjoy the sound of nightmares
var playback: AudioStreamPlayback = null # Actual playback stream, assigned in _init().
var _stream = PoolRealArray()
var stream_pos = 0
@noidexe
noidexe / Godot_unstable.svg
Last active February 28, 2020 23:06
Godot icon with alternative palette to differentiate from stable in desktop shortcuts
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@noidexe
noidexe / RoundRobinPlayer.gd
Created September 9, 2019 07:00
RoundRobinPlayer node for Godot Engine with sequence, random, and shuffle modes extending AudioStreamPlayer
tool
extends AudioStreamPlayer #exactly the same code should work for extending 2D and 3D versions
class_name RoundRobinPlayer
export(int, "sequence", "random", "shuffle") var queue_mode = 0
export(Array, AudioStream) var playlist = [] setget _set_playlist, _get_playlist
export(bool) var round_robin_playing = false setget _set_playing, _is_playing # can't override properties so use this for animations
var playlist_index = -1 # current position in the playlist
var shuffled_indices = [] # Array<int> of shuffled playlist indices
@noidexe
noidexe / some_singleton.gd
Created December 28, 2017 14:08
ShuffleBag implementation in gdscript
#You can add this to any singleton where you have helper classes and functions
class ShuffleBag:
var _shuffled_list
var _current_pos = -1
func _init(array_from):
var _unshuffled = array_from.duplicate()
var _shuffled = []
var _current_pos
# Pick a random element from the unshuffled list