Skip to content

Instantly share code, notes, and snippets.

View egocarib's full-sized avatar
🌴
On vacation

egocarib

🌴
On vacation
View GitHub Profile
@egocarib
egocarib / gist:ea022799cca8a102d14c54a22c45efe0
Created October 22, 2020 01:50
pillow transparent gif creation workaround
# This code adapted from https://github.com/python-pillow/Pillow/issues/4644 to resolve an issue
# described in https://github.com/python-pillow/Pillow/issues/4640
#
# There is a known issue with the Pillow library that messes up GIF transparency by replacing the
# transparent pixels with black pixels (among other issues) when the GIF is saved using PIL.Image.save().
# This code works around the issue and allows us to properly generate transparent GIFs.
from typing import Tuple, List, Union
from collections import defaultdict
from random import randrange
@egocarib
egocarib / Example Qud Transpiler
Created August 20, 2020 04:56
Example Qud Transpiler
using System;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Collections.Generic;
using HarmonyLib;
using XRL.Core;
using XRL.World.Parts;
using UnityEngine;
@egocarib
egocarib / gist:806436f21aacfd7f77740281e061d34d
Created August 11, 2019 19:24
qud character inventory module
character inventory module
==========================
Requirements: allow specifying an item list, quantity for each item, and whether each item is equipped. Then parse those items/details and output the HTML.
For example, the module call might look like this:
{{#invoke:Inventory | FormatInventory | powered exoskeleton~1~yes`overloaded laser pistol~2~yes`plastifier jerkin~1~no }}
Maybe there's a nicer way to format the input string instead of using ~ and ` delimiters, but I'm not sure. Or maybe it could be split into two modules (one for the wrapper HTML, and one for individual items). Feel free to do whatever makes the most sense!
@egocarib
egocarib / characterInfobox.css
Last active December 26, 2019 07:52
CSS for Qud Wiki Character Infobox
/*
* QUD COLORS AND FONTS
* ====================
*/
:root {
--qud-color-y: #ffffff;
--qud-color-y-dark: #b1c9c3;
--qud-color-r: #d74200;
--qud-color-r-dark: #a64a2e;
--qud-color-o: #e99f10;
Qud look: Maximum depth >> 3
=======================================
<div class="qud-box-wrapper {{#ifeq:
{{{bordercolor|}}}| y |white-border|
}}"><div class="qud-box"><span class="qud-box-header">
{{Qud text|&amp;y
{{{title|
ScreenBuffer scrapBuffer = ScreenBuffer.GetScrapBuffer2(true); //copy the scrapbuffer
TileMaker tileMaker = new TileMaker("Great Magma Crab"); //you can pass a GameObject or a blueprint string to the TileMaker
tileMaker.WriteTileToBuffer(scrapBuffer, 10, 20); //enter x,y coordinates where you want to draw the tile on screen
Popup._TextConsole.DrawBuffer(scrapBuffer, null, false); //draw the scrapbuffer
@egocarib
egocarib / Qud Event Names.cs
Created July 11, 2019 23:16
Qud Event Names
"AccomplishmentAdded"
"ActivateFabricateFromSelf"
"ActivateSkyshroud"
"AddedToInventory"
"AddFood"
"AddWater"
"AdjustWeaponScore"
"AfterCriticalHit"
"AfterLookedAt"
"AfterMoved"
@egocarib
egocarib / from_GameObject.cs
Created July 6, 2019 17:15
sValue calculation
string a2 = "NPC";
if (this.Property.ContainsKey("Role"))
{
a2 = this.Property["Role"];
}
if (a2 == "Minion" && (statistic.Name == "Strength" || statistic.Name == "Agility" || statistic.Name == "Toughness" || statistic.Name == "Willpower" || statistic.Name == "Intelligence" || statistic.Name == "Ego"))
{
statistic.Boost--;
}
int num2 = 0;
string a2 = "NPC";
if (this.Property.ContainsKey("Role"))
{
a2 = this.Property["Role"];
}
if (a2 == "Minion" && (statistic.Name == "Strength" || statistic.Name == "Agility" || statistic.Name == "Toughness" || statistic.Name == "Willpower" || statistic.Name == "Intelligence" || statistic.Name == "Ego"))
{
statistic.Boost--;
}
int num2 = 0;
//EnchantmentFrameworkAPI.h (Shared by both dlls)
struct EnchantmentFrameworkInterface
{
enum { kInterfaceVersion = 1 };
UInt32 version;
std::vector<EnchantmentItem*> (* GetAllCraftedEnchantments)(); //get all player-created persistent enchantments
bool (* GetCraftedEnchantmentParents)(EnchantmentItem* customEnchantment, std::vector<EnchantmentItem*> &baseList); //get base enchantments that were originally combined to craft this custom enchantment
};