Skip to content

Instantly share code, notes, and snippets.

View SalatielSauer's full-sized avatar
🇧🇷
Salatiel#5274

Salatiel SalatielSauer

🇧🇷
Salatiel#5274
View GitHub Profile
@SalatielSauer
SalatielSauer / base64.cfg
Created April 21, 2024 20:36
CubeScript base64 encoder/decoder
// base64 encoder/decoder, ported to cubescript by @SalatielSauer
// usage: /echo (base64 1 "Hello") // encode
// /echo (base64 0 "SGVsbG8") // decode
base64 = [
local base64Chars base64CharAt encode decode isNaN
base64Chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
base64CharAt = [substr $base64Chars $arg1 1]
isNaN = [! (codestr $arg1)]
@SalatielSauer
SalatielSauer / sauerbraten_src_comments_dump.txt
Created November 10, 2023 23:50
Cube 2 Sauerbraten Source Code Comments
// FIXME hudgunorigin(), and shorten to maxrange
// projectile, cast on target
// only one in the air at once
//mpdir = vec(yaw*RAD, pitch*RAD);
// cast on self
// FIXME: make fast "give me all rpgobs in range R that are not X" function
// quick reject, for now
// cast on target
// alternative version of update() if this ent is the main player
//lastaction = lastmillis;
@SalatielSauer
SalatielSauer / obrstructure.md
Created June 4, 2023 04:01
Incomplete data structure of Cube 2 Sauerbraten OBR (prefabs) files.

OBR File Format Incomplete Structure

OBR is a file format that holds presets of Sauerbraten map geometries.

This is an incomplete overview and may contain misinterpretations, feel free to correct or add more information. :)

Example of an uncompressed .obr file:

4f45 4252 0000 0000 f001 0000 1002 0000 0002 0000 // header
0100 0000 0100 0000 0100 0000 1000 0000 0000 0000 // selection setup
0000 8083 8043 5050 8080 8080 8080 0100 0100 0200 0300 0400 0500 // first "cube"
@SalatielSauer
SalatielSauer / readme.md
Last active March 12, 2023 20:29
Concatenated JSON data for all Sauerbraten map variables.

Data extracted with a slightly altered version of genserverogz to output the result in a json format.

sauer-mapvars-values.json contains the values in the indexes that correspond to the items in sauer-mapvars-identifiers.json. The index value is null if the map does not use a particular mapvar.

@SalatielSauer
SalatielSauer / dreambooth-sd-cube-2-sauerbraten.ipynb
Last active November 27, 2022 01:43
Dreambooth - SD: Cube 2 Sauerbraten (fork)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@SalatielSauer
SalatielSauer / maptomodel.cfg
Last active March 20, 2023 23:24
A UI for Sauerbraten that generates the files needed to load a map as a mapmodel.
_fs_debug = 0
_fs_appendline = [
if (!=s $arg1 "") [
if $_fs_debug [echo (concat "^f0append ^f2" @arg1)]
append _fs_linesbuff (concatword "[" $arg1 "]")
]
]
_fs_open = [
_fs_linesbuff = []
@SalatielSauer
SalatielSauer / bestdelay.js
Last active May 29, 2022 15:27
A JavaScript function to calculate the best delay between a certain amount of tasks to evenly distribute them within a time range.
// organize tasks at equal intervals within a time range.
// receives two objects (start and end hours) and an integer (tasks)
function spreadTasks(start = {h: 0, m: 0}, end = {h: 23, m: 59}, tasks) {
let totalHour = end.h - start.h;
let totalMinute = end.m - start.m;
let totalTime = (totalHour*60)+totalMinute;
let taskTable = [];
for (let i = 0; i <= totalTime; i+=(totalTime/tasks)) {
let taskTime = ((start.h*60)+start.m)+i;
let taskHour = Math.floor(taskTime/60);
@SalatielSauer
SalatielSauer / cubedeformer.cfg
Last active January 23, 2022 15:24
CubeScript workaround to deform edges of cubes via commands in Sauerbraten's map editor.
// Cube Deformer functions, by @Salatiel#5274
// version: 23/01/2022
// indexes: [+x, -x, +y, -y]
// [[movesel x, movesel y], [movesel dir, movesel dim]], camera yaw
.selfacesheet = [
[[1 1][-1 1] 90]
[[0 0][1 1] -90]
[[1 0][1 0] 180]
[[0 1][-1 0] 0]
@SalatielSauer
SalatielSauer / readme.md
Last active January 11, 2022 18:30
JavaScript functions to get the position or index of a cube following the Sauerbraten octree structure

https://github.com/SalatielSauer/OGZ-Editor

@SalatielSauer
SalatielSauer / pixelsintorectangle.js
Created January 3, 2022 14:29
JavaScript function to get the most rectangular image dimension that fits a certain number of pixels with the least (or no) addition of extra pixels.
function pixelsIntoRect(n, k){
var max = ~~Math.sqrt(n);
return Array.from({length: max}, (_, i, a) => [n%(max-i), max-i])
.sort((a, b) => a[0] - b[0])
.slice(0, k)
.map(t => [Math.ceil(n/t[1]), t[1], (Math.ceil(n/t[1])*t[1])-n])
.filter(a => Math.round(a[1]/a[0]) == 1)
.sort((a, b) => a[2] - b[2])
}