Skip to content

Instantly share code, notes, and snippets.

View nkrapivin's full-sized avatar
🐱
exactly.

Nikita Krapivin nkrapivin

🐱
exactly.
View GitHub Profile
@nkrapivin
nkrapivin / README.md
Last active August 23, 2023 19:15
Adding LiveSplit support into your GameMaker game.

Adding LiveSplit support into your GameMaker game

This guide is intended for developers who want to assist speedrunners with creating auto-splitters but don't know how to do it.

You don't actually need to use any external DLLs, all you need is one huge buffer that will contain all the information needed for speedrunners.

Why should I bother?

Great question!

@nkrapivin
nkrapivin / README.md
Last active June 26, 2023 15:58
gm82con extension documentation

gm82con

This is the documentation for the gm82con extension.

gm82con allows you to manage your own debug console window for whatever purposes.

Written by nkrapivindev for the GameMaker 8.2 project.

Table of contents

@nkrapivin
nkrapivin / surface_to_string.gml
Created May 15, 2023 11:13
GameMaker surface to&from string helpers.
function niklog(msg) {
show_debug_message(msg);
}
/// @param {Id.Surface} surf input surface
/// @returns {String|Undefined} base64 string or undefined on invalid arguments
function surface_to_string(surf) {
if (is_undefined(surf)) {
niklog("surface_to_string: expected a `surf` argument");
@nkrapivin
nkrapivin / rerand.gml
Created October 4, 2022 14:38
RERand - 100% correct GML runtime RNG implementation.... in pure GML!
function rerand() constructor {
state = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
g_nRandSeed = 0;
g_RndIndex = 0;
s_nRandomPoly = $DA442D24;
RND_MAX = $FFFFFFFF;
s_nStateAndMask = RND_MAX;
InitRandom = function(/*uint*/ _seed) {
var uVar3 = _seed;
@nkrapivin
nkrapivin / BnvibCrap.gml
Created April 17, 2022 10:59
BnvibCrap - a weird bnvib player written in GML
function BnvibCrap() {
// a safe guard to prevent from calling this file as BnvibCrap();
/* example usage:
// create:
var _pl = new BnvibPlayer("test.bnvib");
playerSlot = // get player gamepad slot here somehow;
// step:
if (!is_undefined(_pl)) {
if (!_pl.stepAll(playerSlot)) { // huh? step failed?
var _stopstate = _pl.getstate();
@nkrapivin
nkrapivin / input_switch_invoke.gml
Created April 16, 2022 12:54
Input Switch applet bindings
/// @description A little wrapper around Input and the Switch controllers applet. To be used instead of hot swapping.
/// @param {Real} minPlayersReal Minimum amount of players
/// @param {Real} maxPlayersReal Maximum amount of players
/// @param {Bool} maintainConnectionBool Whether to NOT disconnect controllers during the applet
/// @param {Bool} permitJoyConDualBool Whether to allow dual Joy-Cons in the applet
function input_switch_invoke(minPlayersReal, maxPlayersReal, maintainConnectionBool, permitJoyConDualBool) {
var _spBool = minPlayersReal <= 1 && maxPlayersReal <= 1;
// input_switch_invoke(1, 1, true); // will invoke the singleplayer applet
// input_switch_invoke(1, 2, true); // will invoke the co-op applet
@nkrapivin
nkrapivin / notarize.sh
Created March 12, 2022 13:08
Proper notarization of macOS apps since Xcode 13+
#!/bin/sh
# this script must be ran in the same directory as the .app file!
# change this
APP_NAME="Sonic Time Twisted.app"
# must be a 'Developer ID: ' cert, not Mac Distribution etc...
CERT_NAME="Developer ID: kekeke@lololo.com (AAAABBBB)"
MAC_USER_PASS="1234"
PRODUCT_NAME="myproduct"
# this is the name of a notarytool profile, you have to make it ONCE with this command:
# xcrun notarytool store-credentials "Profile_Name" --apple-id "your apple id email here" --team-id YourTeamIDHere --password PasswordOrAppPassword
@nkrapivin
nkrapivin / nikXfix.c
Last active March 10, 2022 08:44
libnikXfix - a small hack to fix keyboard input in Linux GameMaker games.
/*
Compile me as:
Release version - `gcc -fPIC -ldl -shared nikXfix.c -o libnikXfix.so`
Debug version - `gcc -fPIC -g -O0 -DDEBUG -ldl -shared nikXfix.c -o libnikXfix.so`
Then load with LD_PRELOAD="./assets/libnikXfix.so" (.so is to be placed in Included Files)
Enjoy!
*/
#define _GNU_SOURCE 1
#include <stdlib.h>
#include <stdio.h>
@nkrapivin
nkrapivin / runshi.sh
Last active March 7, 2022 10:01
Runshi (Ранши) - RUN.SH IMproved
#!/bin/bash
# lo and behold, runshi 2, aka the worst piece of bash ever written!
# -- PLEASE CHANGE THIS ONE, IT'S A RELATIVE PATH TO YOUR GAME EXECUTABLE --
NIK_MYCMD="./Mondealy_Full"
# in seconds, if your computer is extremely slow you may want to use higher amounts.
NIK_DELAY=1
# You usually do not need to touch the rest...
NIK_OLDIFS="$IFS"
@nkrapivin
nkrapivin / TGINParse.gml
Last active December 22, 2021 12:26
coded quickly in a few hours
/// @function TGINAssert(assertExpr, assertMsg)
/// @description assert() like function, do not use in your game code.
/// @param {bool} assertExpr boolean-ish exception
/// @param {string} assertMsg string that will be used if an assertion had failed.
/// @returns nothing, throws on error
function TGINAssert(assertExpr, assertMsg) {
if (!assertExpr)
throw string_replace("TGINParse: Assertion Failed: %s", "%s", string(assertMsg));
}