Skip to content

Instantly share code, notes, and snippets.

@tinkerer-red
tinkerer-red / MaterialCarrierMesh
Last active November 5, 2024 05:10
A collection of blender scripts
# Purpose is to bind all materials to a single object to allow for importing into unity, as unity will not import a material if it's not actively used on a model, despite being in the files.
import bpy
def create_carrier_mesh():
# Name for the carrier mesh
carrier_mesh_name = "Material_Carrier_Mesh"
# Create a new mesh and object for the carrier
mesh_data = bpy.data.meshes.new(carrier_mesh_name)
@tinkerer-red
tinkerer-red / Everything else.gml
Created November 4, 2024 22:39
string_to_constant for gml
function __DeprocatedFunctions() {
static __struct = {
"achievement_available": achievement_available,
"achievement_get_challenges": achievement_get_challenges,
"achievement_get_pic": achievement_get_pic,
"achievement_increment": achievement_increment,
"achievement_load_friends": achievement_load_friends,
"achievement_load_leaderboard": achievement_load_leaderboard,
"achievement_load_progress": achievement_load_progress,
"achievement_login": achievement_login,
@tinkerer-red
tinkerer-red / createToggleShapekeys.py
Created November 14, 2024 22:58
createToggleShapekeys.py
### CreateToggleShapekeys - By: Red#8479
# To use this script simply select the object
# you would like to add a shapekey to to toggle
# it in games. This will automatically create a
# shapekey for you named `Toggle_`+[ObjectName]
import bpy
import bmesh
from mathutils import Vector
import numpy as np
@tinkerer-red
tinkerer-red / gist:9ed172f0db46df862f0b667b9d27da72
Last active January 28, 2025 02:00
constructor_call() / constructor_call_ext()
function constructor_call(ind) {
static __arr = [];
var _i=1; repeat(argument_count-1) {
__arr = argument[_i];
_i++}
var _struct = constructor_call_ext(ind, __arr);
array_resize(__arr, 0)
@tinkerer-red
tinkerer-red / benchmark.gml
Last active February 16, 2025 10:09
`array_contains_other` Attempt to search array for non default values
new Benchmark("array_contains_not", [
new TestCase("manually checked for()", function(iterations) {
repeat (iterations) {
var result = func(testArray, default_value);
}
},
function(){
//initiallizer (is not accounted for in the benchmark test)
default_value = undefined;
@tinkerer-red
tinkerer-red / Benchmarks.gml
Last active February 18, 2025 18:25
Custom Matrix Benchmarks
Benchmarks = [
new Benchmark("2D Data foreach (full)", [
new TestCase("Array", function(iterations) {
var _i=0; repeat(iterations){
arr.foreach(function(_cell, _x, _y){}, false)
_i++}
},
function(){
width = 32;
@tinkerer-red
tinkerer-red / buffer_surface.gml
Last active March 2, 2025 03:54
`buffer_create_from_surface` and `surface_create_from_buffer`
#region jsDoc
/// @func buffer_create_from_surface
/// @desc Creates a fixed-size buffer containing the pixel data from the given surface. The buffer size is determined
/// by the surface's dimensions and format. The buffer is populated with the surface's pixel data starting at byte offset 0.
/// @param {Id.Surface} _surf - The source surface from which to read pixel data.
/// @returns {Id.Buffer} A buffer containing the surface's pixel data.
#endregion
function buffer_create_from_surface(_surf) {
// Get surface properties
var _width = surface_get_width(_surf);
@tinkerer-red
tinkerer-red / Emoji_Names_on_Discord.json
Last active March 6, 2025 12:35
Collection of names and synonyms for Emojis of Discord
{
"people":[
{"names":["grinning","grinning_face"],"surrogates":"\uD83D\uDE00","unicodeVersion":6.1},
{"names":["smiley"],"surrogates":"\uD83D\uDE03","unicodeVersion":6},
{"names":["smile"],"surrogates":"\uD83D\uDE04","unicodeVersion":6},
{"names":["grin"],"surrogates":"\uD83D\uDE01","unicodeVersion":6},
{"names":["laughing","satisfied"],"surrogates":"\uD83D\uDE06","unicodeVersion":6},
{"names":["face_holding_back_tears"],"surrogates":"\uD83E\uDD79","unicodeVersion":14},
{"names":["sweat_smile"],"surrogates":"\uD83D\uDE05","unicodeVersion":6},
{"names":["joy"],"surrogates":"\uD83D\uDE02","unicodeVersion":6},
function string_format_human_readable(_num) {
if (_num == 0) return "zero";
static __ones = [
"", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine",
"ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen",
"seventeen", "eighteen", "nineteen"
];
static __tens = ["", "", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"];
@tinkerer-red
tinkerer-red / CacheSystem.gml
Created March 17, 2025 23:52
A Simply Cache System for internal use in functions
function CacheSystem() constructor {
data = {};
static __string_hash = {} //explicetly used to improve the speed at which we hash strings
static save = function(_value) {
var _data = data;
var _cache_ref_key_count = argument_count;
var _last_index = _cache_ref_key_count-1;
for(var _i=1; _i<_cache_ref_key_count; _i++) {