Skip to content

Instantly share code, notes, and snippets.

@rambda
rambda / argparse.gd
Created August 13, 2023 17:04
(WIP) an attempt to port Python argparse.py to GDScript 2.0.
# Author: Steven J. Bethard <[email protected]>.
# New maintainer as of 29 August 2019: Raymond Hettinger <[email protected]>
#Command-line parsing library
#
#This module is an optparse-inspired command-line parsing library that:
#
#- handles both optional and positional arguments
#- produces highly informative usage messages
#- supports parsers that dispatch to sub-parsers
@rambda
rambda / locale_name_list.gd
Created February 14, 2021 21:41
A resource that automatically exports loaded locales to assign name in that langauge...
tool
extends Resource
class_name LocaleNameList
var data: Dictionary
func _init() -> void:
for locale in TranslationServer.get_loaded_locales():
if not locale in data:
@rambda
rambda / int2hex.gd
Created February 3, 2021 19:29
GDScript function that converts an integar to a hexadecimal number.
static func int2hex(num: int) -> String:
num &= 0xFFFFFFFF
var s := "0123456789abcdef"
var res := ""
var mask := 0b1111
while num > 0:
res = res.insert(0, s[num & mask])
num >>= 4
return res if res else "0"