Skip to content

Instantly share code, notes, and snippets.

View caligari87's full-sized avatar

Sterling Parker caligari87

View GitHub Profile
This was generated by ChatGPT, given a list of 100 commit messages and a prompt
@caligari87
caligari87 / cvarinfo.txt
Last active May 11, 2023 16:34
A simple implementation of a debug logging system, which can filter messages based on the a bitfield cvar
server int MyMod_DebugFilter = 0;
@caligari87
caligari87 / keycheck.zsc
Last active July 23, 2022 22:17
Small GZDoom zscript function for checking input buttons
// ----------------------------------------
// the default pointer is "self" for use in a custom player class.
// For an inventory item it would be owner, etc.
// if (KeyCheck(BT_ATTACK, KPT_JUSTPRESSED)) { console.printf("just pressed Attack!"); }
// ----------------------------------------
bool KeyCheck(int toCheck, int checkType = KPT_PRESSING, PlayerPawn pointer = null) {
if (pointer == null) { pointer = PlayerPawn(self); } // default fallback
if (!pointer) { return; } // nullcheck just to be safe
int b = pointer.player.cmd.buttons; int ob = pointer.player.oldbuttons;
switch (checkType) {
@caligari87
caligari87 / string-builder.cs
Last active April 29, 2022 13:41
A simple string variation builder (GZDoom / ZScript)
// Make a string from a variable template
static string BuildVariableString(string msg){
// some input example strings:
// "an empty {beer|soda|wine|champagne} bottle. {It is {cracked|broken|unlabeled}.}"
// "a {small|large|||} plush {emoji|cacodemon|teddy bear|furbie} toy."
// Collapse substrings, repeat until no more { }
while(true){
int LeftBrace = msg.RightIndexOf("{"); // find the rightmost left-brace {
int RightBrace = msg.IndexOf("}",LeftBrace+1); // find the nearest matching right-brace }
@caligari87
caligari87 / paintdrops.bas
Last active November 8, 2021 06:35
Paint droplet splatter generator for QB64 (qb64.org)
Type DropDef
Active As Integer
XPos As Single
YPos As Single
ZPos As Single
XVel As Single
YVel As Single
ZVel As Single
Radius As Single
Color As Long
@caligari87
caligari87 / yt-duration-hover.css
Last active September 10, 2021 05:14
Hide the YouTube video duration overlay unless hovering the thumbnail. For a user-style addon, like Stylus. Demo video: https://streamable.com/ykhtls
ytd-thumbnail-overlay-time-status-renderer {
opacity: 0.0!important;
transition: opacity 0.1s!important;
}
.ytd-thumbnail:hover ytd-thumbnail-overlay-time-status-renderer {
opacity: 1.0!important;
transition: opacity 0.5s!important;
z-index: 2!important;
}
@caligari87
caligari87 / simplerogue.bas
Created May 13, 2021 17:36
A QB64 roguelike in 50 lines
NewGame: SCREEN 0: RANDOMIZE TIMER: WIDTH 80, 60: HP = 100: XP = 0: Level = 1: _FULLSCREEN
NewLevel:
CLS: NewCave = 0: Col = 40: Row = 30: TYPE MonDef: X AS INTEGER: Y AS INTEGER: END TYPE: DIM Monsters(15) AS MonDef: DIM SHARED K$
FOR X = 2 TO 79: FOR Y = 2 TO 59: COLOR 8: LOCATE Y, X: PRINT "#";: NEXT: NEXT
FOR X = 5 TO 76: FOR Y = 5 TO 56: COLOR 8: LOCATE Y, X: PRINT ".";: NEXT: NEXT
FOR i = 0 TO (80 * 60 / 8): COLOR 8: LOCATE INT(52 * RND + 5), INT(72 * RND + 5): PRINT "#";: NEXT: LOCATE 1, 40: PRINT "Step 1+"; i; " ": KEYDELAY 1
FOR i = 1 TO 5: FOR X = 5 TO 75: FOR Y = 5 TO 55
IF RND < .15 AND (SCREEN(Y - 1, X) = 35 OR SCREEN(Y + 1, X) = 35 OR SCREEN(Y, X + 1) = 35 OR SCREEN(Y, X - 1) = 35) THEN COLOR 8: LOCATE Y, X: PRINT "#";
IF SCREEN(Y, X) = 35 AND (SCREEN(Y - 1, X) = 46 AND SCREEN(Y + 1, X) = 46 AND SCREEN(Y, X + 1) = 46 AND SCREEN(Y, X - 1) = 46) THEN COLOR 8: LOCATE Y, X: PRINT ".";
IF RND < .005 AND SCREEN(Y, X) = 46 THEN COLOR 14: LOCATE Y, X: PRINT "*";
@caligari87
caligari87 / zscript.txt
Last active November 30, 2020 15:51
Example Ugly as Sin food addon. Place in a .pk3 file and load after Ugly as Sin.
version "4.5"
// Food items that can be directly eaten
class ExampleMod_RedApple : UaS_Consumable {
default {
UaS_Consumable.Calories 95; // Calories
UaS_Consumable.Fluid 85; // Millilitres (remember most non-dehydrated foods have a lot of water in them)
UaS_Consumable.Bulk 10; // influences number of "bites" it takes to consume foods.
UaS_Consumable.Description "A medium-sized red apple.";
// UaS_Consumable.OpenMessage1 ""; // Random messages on opening packaged items
@caligari87
caligari87 / menudef.txt
Created November 16, 2020 15:32
This is a modified MENUDEF for Ugly as Sin, which should work with GZDoom v4.4 (or the equivalent LZDoom version)
OptionValue "UaS_Nice_Timescales" {
1, "1x Realtime"
2, "2x Realtime"
5, "5x Realtime"
10, "10x Realtime"
20, "20x Realtime"
30, "30x Realtime"
40, "40x Realtime"
50, "50x Realtime"
60, "60x Realtime"
@caligari87
caligari87 / zscript.zsc
Last active July 4, 2020 03:00
slightly more controllable and performant particle fire
version "4.3"
const maxparticles = 200;
const rad = 12;
class TestFireSpawner2 : actor {
vector3 firepos[maxparticles];
vector3 firevel[maxparticles];
double fireheat[maxparticles];
color firecolor;