Skip to content

Instantly share code, notes, and snippets.

@tinkerer-red
tinkerer-red / generate_type_safe_wrappers.py
Last active May 23, 2026 13:40
GameMaker type-safety wrapper generator for built-in handle/reference arguments
#!/usr/bin/env python3
import argparse
import random
import re
import xml.etree.ElementTree as ElementTree
from pathlib import Path
_NUMERIC_TYPE_EXACT = {
"Any",
"Bool",
@tinkerer-red
tinkerer-red / GmlRefs.txt
Created May 21, 2026 09:37
TypeRefs in GML
Array
Asset
Asset.GMAnimCurve
Asset.GMAudioGroup
Asset.GMFont
Asset.GMObject
Asset.GMParticleSystem
Asset.GMPath
Asset.GMRoom
Asset.GMScript
// idk
function is_sprite(_value) {
if !is_handle(_value) return false;
return sprite_exists(_value);
}
function is_instance(_value) {
if !is_handle(_value) return false;
return !object_exists(_value) && instance_exists(_value);
@tinkerer-red
tinkerer-red / Script1.gml
Created February 22, 2026 07:00
Sketchy.gml example output.
// ============================
// MACRO TESTS (parameterized, nested, multi-line, single-line output)
// ============================
#macro ADD(A, B) ((A) + (B))
#macro MUL(A, B) ((A) * (B))
#macro ADD_MUL(A, B, C) ADD(MUL((A), (B)), (C))
#macro HELLO_MSG(NAME) show_debug_message("Hello " + \
string(NAME) + \
@tinkerer-red
tinkerer-red / print_progress.gml
Last active April 19, 2026 22:11
progress bar printing similar to python and cpp solutions
#region jsDoc
/// @func print_progress()
/// @desc Throttled progress logger with cached state, milestone printing,
/// stable average ops/s, ETA estimation, and TTL cleanup.
/// @param {Real} _current_value Current progress index (monotonic).
/// @param {Real} _total_value Total expected count for completion.
/// @param {String} [_prefix] Optional prefix text (part of cache key).
/// @param {String} [_suffix] Optional suffix text (display only).
/// @returns {Undefined}
#endregion
@tinkerer-red
tinkerer-red / convert_to_tries_array.gml
Created January 25, 2026 03:16
`string_replace_all`
function convert_to_tries_array(_map) {
static __buff = buffer_create(0, buffer_grow, 1);
var root = array_create(256, undefined); // Root node
var _names = struct_get_names(_map);
var _length = array_length(_names);
for (var _i = 0; _i < _length; _i++) {
var _find = _names[_i];
@tinkerer-red
tinkerer-red / benchmark.gml
Last active January 23, 2026 06:09
buffer_write_ext
new Benchmark("buffer_write_ext", [
new TestCase("closures", function(iterations) {
var _buff = buffer_create(0, buffer_grow, 1);
buffer_write_ext(_buff, buffer_u32, arr)
buffer_delete(_buff);
},
function(iterations) {
arr = array_create(iterations, 12345)
}),
new TestCase("loop", function(iterations) {
@tinkerer-red
tinkerer-red / Settings.gml
Created December 19, 2025 18:45
Auto Resize Settings
#macro __SETTINGS_AUTO_SCALE true
//these settings will require Window's window resize setting to be set to true
#macro __SETTINGS_ALLOW_WINDOW_RESIZE_HORZ true
#macro __SETTINGS_ALLOW_WINDOW_RESIZE_VERT true
@tinkerer-red
tinkerer-red / ReplacementFunctions.gml
Last active November 30, 2025 05:17
GM Functions which use handles
//This file was generated by code, I hope this helps modding tools expose more helpful functions to keep the global scope hidden from users.
function __ads_set_reward_callback(_callback){
//_callback : {Asset.Script}
if (!is_handle(_callback) && is_numeric(_callback)) throw "This project doesnt support arbitrary handle access, please provide a handle instead of a number."
return ads_set_reward_callback(_callback);
}
function __animcurve_exists(_curve_struct_or_id){
//_curve_struct_or_id : {Asset.GMAnimCurve,Struct.AnimCurve}
if (!is_handle(_curve_struct_or_id) && is_numeric(_curve_struct_or_id)) throw "This project doesnt support arbitrary handle access, please provide a handle instead of a number."
@tinkerer-red
tinkerer-red / tokens_1gram.txt
Created October 9, 2025 01:05
GML Function Grams List
"layer" || 196
"ds" || 132
"draw" || 130
"audio" || 116
"physics" || 100
"gpu" || 100
"sprite" || 94
"ext" || 89
"create" || 80
"part" || 78