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 / 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 / joycon-mappings.txt
Created July 31, 2017 00:25
Nintendo Switch Joycons as html5 bluetooth controller
Nintendo Switch Joycons use standard bluetooth technology and can be paired with a PC or phone by holding the power button between SL and SR while the console is off.
If your Switch can't find em after that just reattach them to the console and they'll pair up immediately.
Button scheme info obtained using http://html5gamepad.com and http://gamepadviewer.com
Joycon R: Wireless Gamepad (Vendor: 057e Product: 2007)
Switch, Generic, XBOX
SL, B4, LB
SR, B5, RB
@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 / 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 / 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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
@noidexe
noidexe / draggableObject.gd
Last active October 20, 2017 19:52
Drag n Drop example in Godot
extends Node2D
signal picked
signal dropped
enum DRAGSTATES { PICKED, DROPPED }
var drag_state = DRAGSTATES.DROPPED
var prev_mouse_pos = Vector2(0,0)
var absolute_z = IntArray([0])
var last_event