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 / octaedit.cpp
Last active June 28, 2019 12:17
src/engine/octaedit.cpp
VARP(editinview, 0, 1, 1);
bool noedit(bool view, bool msg)
{
if(!editmode) { if(msg) conoutf(CON_ERROR, "operation only allowed in edit mode"); return true; }
if(view || haveselent()) return false;
float r = 1.0f;
vec o = sel.o.tovec(), s = sel.s.tovec();
s.mul(float(sel.grid) / 2.0f);
o.add(s);
r = float(max(s.x, max(s.y, s.z)));
@SalatielSauer
SalatielSauer / 3dgui.cpp
Last active January 21, 2020 03:08
Sauerbraten: Guiskin, Guisliderskin & Guialpha
//MOD: Guiskin, Guisliderskin, Guialpha
char* cguiskin = "data/guiskin.png";
FVARP(guiskin, "", {cguiskin = guiskin;});
char* cguisliderskin = "data/guislider.png";
FVARP(guisliderskin, "", {cguisliderskin = guisliderskin;});
FVARP(guialpha, 0, 0.5, 1);
//END
void line_(int size, float percent = 1.0f)
{
@SalatielSauer
SalatielSauer / stdlib.cfg
Created March 26, 2020 12:36
List of useful CubeScript functions
// generates a string of tabs
// i.e. echo (concatword (gentabs 2) "hello" (gentabs 5) "world")
gentabs = [
_gtabs = ""
loop t $arg1 [_gtabs = (concatword $_gtabs "^t")]
result $_gtabs
]
// moves a gui item to any position
// i.e. guiitemmove 0 -5 -15 [guititle "Hi"]
@SalatielSauer
SalatielSauer / discord-country.cfg
Last active April 25, 2020 15:25
Country name list for discord emoticons (Remod Sauerbraten)
//by Salatiel (salatielsauer.github.io)
getflag = [
pcountry = (getcountry (getip $arg1)) ;
countries = ["undefined" "United Arab Emirates" "Afghanistan" "Armenia" "Angola" "Antarctica" "Argentina" "American Samoa" "Austria" "Australia" "Barbados" "Belgium" "Bangladesh" "Bulgaria" "Bermuda" "Bolivia" "Brazil" "Bahamas" "Canada" "Switzerland" "Chile" "Cameroon" "Colombia" "Costa Rica" "Cuba" "Cape Verde" "Christmas Island" "Germany" "Dominican Republic" "Algeria" "Ecuador" "Estonia" "Egypt" "Spain" "Ethiopia" "Finland" "France" "Georgia" "Guinea" "Greece" "Guatemala" "Hong Kong" "Haiti" "Hungary" "Indonesia" "Israel" "India" "Iraq" "Italy" "Jamaica" "Japan" "Cayman Islands" "Lithuania" "Madagascar" "Mexico" "Nigeria" "Netherlands" "Nepal" "Peru" "Poland" "Puerto Rico" "Portugal" "Paraguay" "Romania" "Serbia" "Russian Federation" "Sudan" "Slovenia" "Turkey" "Ukraine" "Venezuela" "South Africa" "United States" "Norway" "United Kingdom" "Moldova, Republic of" "Kenya" "Iraq" "Liberia" "Pakistan" "Palestine" "
@SalatielSauer
SalatielSauer / A_smc_guide.md
Last active August 27, 2020 19:08
Sauerbraten/Blender SMC Guide (octaedit.cpp / io_export_smc.py)
@SalatielSauer
SalatielSauer / console.cpp
Created December 16, 2020 14:06
Sauerbraten top console background (src/engine/console.cpp)
int renderconsole(int w, int h, int abovehud) // render buffer taking into account time & scrolling
{
int conpad = fullconsole ? 0 : FONTH/4,
conoff = fullconsole ? FONTH : FONTH/3,
conheight = min(fullconsole ? ((h*fullconsize/100)/FONTH)*FONTH : FONTH*consize, h - 2*(conpad + conoff)),
conwidth = w - 2*(conpad + conoff) - (fullconsole ? 0 : game::clipconsole(w, h));
// console background
extern void bgquad(float x, float y, float w, float h, float tx, float ty, float tw, float th);
if(!fullconsole)
@SalatielSauer
SalatielSauer / rendergl.cpp
Last active December 16, 2020 14:53
Sauerbraten vignette effect (src/engine/rendergl.cpp)
void gl_drawhud()
{
// (...)
// Line 2229
if(!mainmenu)
{
drawdamagescreen(w, h);
drawdamagecompass(w, h);
hudshader->set();
@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])
}
@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 / 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]