Skip to content

Instantly share code, notes, and snippets.

@Putnam3145
Putnam3145 / itemsyndrome.lua
Last active July 25, 2022 23:51
**Obsoleted by DFHack's item-trigger**. Itemsyndrome. Usage is given when "itemsyndrome help" is used. Updated for DFHack 0.34.11 r4. lso updated with Boltgun's changes to the assignment function.
-- Checks for inventory changes and applies or removes syndromes that items or their materials have. Use "disable" (minus quotes) to disable and "help" to get help.
local args = {...}
local function printItemSyndromeHelp()
print("Arguments (non case-sensitive):")
print(' "help": displays this dialogue.')
print(" ")
print(' "disable": disables the script.')
print(" ")
@Putnam3145
Putnam3145 / gaystats.lua
Created April 15, 2022 01:18
Gives statistics regarding relationships in worldgen (how many people had relationships at all, how many are hetero, how many are homo, and so on)
-- Gives statistical info on the prevalence of homosexual relationships
local help = [====[
gaystats
======
Shows the sexual orientation of all historical figures, as well as whether they took lovers of the same or opposite sex.
Options:
:-allowAllRaces: Checks races with modded orientations, too (by default, it only checks races with default orientation)
@Putnam3145
Putnam3145 / maxagecheck.lua
Last active July 28, 2021 01:45
gives you the normalized death-by-max-age times in buckets for every hist fig in the world in DF, to test the distribution thereof (it's linear)
utils = require('utils')
local validArgs = utils.invert({
'printAll',
'bucketSize'
})
local args = utils.processArgs({...}, validArgs)
local bucketSize = args.bucketSize or 0.125
@Putnam3145
Putnam3145 / bedassign.lua
Created July 5, 2018 06:14
Sets all beds with no rooms set to have rooms.
-- Autoassigns all beds which do not have assigned rooms to rooms.
-- Will flood fill up to -size size.
--[====[
bedassign
======
Sets all beds with no rooms set to have rooms.
bedassign -size will set all rooms to press the + key -size times. Setting -size to a negative value will press the - key instead.
]====]
@Putnam3145
Putnam3145 / hackWish.lua
Last active June 17, 2021 11:02
Allows for wishy-type reaction to get any item made of any material. Syntax is "hackWish" followed by x,y,z or a unit. If highlighting a tile, it will place the item there. If highlighting a unit, including with "v", it will put it at the feet of the unit.
-- Allows for script-based wishing.
function getGenderString(gender)
local genderStr
if gender==0 then
genderStr=string.char(12)
elseif gender==1 then
genderStr=string.char(11)
else
return ""
@Putnam3145
Putnam3145 / Dialogue Box.tscn
Created July 28, 2020 05:49
A dialogue box for Godot.
[gd_scene load_steps=2 format=2]
[sub_resource type="GDScript" id=1]
script/source = "extends PopupPanel
\"\"\"
The run function expects an array, containing a series of strings or modifiers.
A string will be displayed one letter at a time, with the current delay,
using the current talk sound.
@Putnam3145
Putnam3145 / sorting.d
Created June 7, 2020 20:39
Some programming junk food. Felt like implementing a parallel quicksort and was baffled at how fast it is.
import std.stdio;
import std.traits : isOrderingComparable;
import std.range;
import std.algorithm.sorting;
import std.algorithm.mutation;
@Putnam3145
Putnam3145 / family.lua
Last active September 27, 2019 00:12
A family tree generator for Dwarf Fortress.
FamilyNode=defclass(FamilyNode)
FamilyNode.ATTRS {
histfig_id = DEFAULT_NIL,
mother = DEFAULT_NIL,
father = DEFAULT_NIL,
spouse = DEFAULT_NIL,
progenitor = false,
children = {}
}
@Putnam3145
Putnam3145 / life.d
Last active March 15, 2019 10:54
Generic programming lifelike cellular automata in D
private struct LifeLikeRule
{
ubyte notZero;
bool zero;
this(ushort initializer)
{
notZero=cast(ubyte)(initializer>>1);
zero=initializer&1;
}
pure ushort fullRule()
@Putnam3145
Putnam3145 / wint.lua
Created December 9, 2018 09:00
i do not apologize for this, nor do i. fully expect it to work to be frank, but i had to get it off my chest
-- https://twitter.com/dril/status/235218148800991233
local eventful=require('plugins.eventful')
eventful.enableEvent(eventful.eventType.INVENTORY_CHANGE,5)
local function unitIsLesbian(unit)
if (unit and unit.status and unit.status.current_soul) then
local soul=unit.status.current_soul
local orientation=soul.personality.orientation_flags