Skip to content

Instantly share code, notes, and snippets.

@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 / SMHackin.lua
Last active February 6, 2017 21:07
A bunch of dumb BizHawk hacks I've made for Super Metroid.
autoShineActivated=false
autoFireActivated=false
autoDamageBoostActivated=false
assistantUI = forms.newform(200, 120, "SMAssist")
autoShineActivated = forms.checkbox(assistantUI,'Auto Shinespark Crouch',1,1)
autoFireActivated = nil --not in there yet
autoDamageBoostActivated = forms.checkbox(assistantUI,'Auto Damage Boost',1,23)
homingMissileActivated = forms.checkbox(assistantUI,'Homing Missile',1,45)
@Putnam3145
Putnam3145 / badThoughtNotifier.lua
Created May 15, 2015 07:47
A script that notifies the user of the most common bad thoughts in the fort.
local function getRaceName()
return df.creature_raw.find(df.global.ui.race_id).name[1]
end
local function emotionIsNegative(thought)
return thought.type~=-1 and df.emotion_type.attrs[thought.type].divider>0
end
local function write_gamelog_and_announce(msg,color)
dfhack.gui.showAnnouncement(msg,color)
dfhack.gui.writeToGamelog(msg)
end
@Putnam3145
Putnam3145 / get_generated_raws.lua
Last active September 24, 2015 15:36
Outputs a few files containing generated raws.
local creatures = assert(io.open(dfhack.getDFPath()..'/generated_creatures.txt', 'w'))
local items = assert(io.open(dfhack.getDFPath()..'/generated_items.txt', 'w'))
local materials = assert(io.open(dfhack.getDFPath()..'/generated_materials.txt', 'w'))
local entities = assert(io.open(dfhack.getDFPath()..'/generated_entities.txt', 'w'))
local interactions = assert(io.open(dfhack.getDFPath()..'/generated_interactions.txt', 'w'))
@Putnam3145
Putnam3145 / burial.lua
Created December 14, 2014 08:37
Automatically assigns all unowned coffins for burial. Use argument "-pets" to allow pets as well as citizens.
local utils=require('utils')
validArgs = validArgs or utils.invert({
'pets'
})
local args = utils.processArgs({...}, validArgs)
for k,v in ipairs(df.global.world.buildings.other.COFFIN) do
if v.owner_id==-1 then
@Putnam3145
Putnam3145 / adoption.lua
Created December 8, 2014 20:37
Adoption!
-- lets babies be adopted by couples with no infants.
local function getSpouseOrLover(unit)
local lover_unit=df.unit.find(unit.relations.lover_id) or df.unit.find(unit.relations.spouse_id)
if lover_unit then
return lover_unit.hist_figure_id
else
local hist_fig=df.historical_figure.find(unit.hist_figure_id)
for k,v in ipairs(hist_fig.histfig_links) do
if df.histfig_hf_link_spousest:is_instance(v) or df.histfig_hf_link_loverst:is_instance(v) then
@Putnam3145
Putnam3145 / add-thought.lua
Last active August 29, 2015 14:08
Allows the user to add emotions to a unit. Use the -gui argument to open a GUI for your editing needs.
-- Adds emotions to creatures.
local utils=require('utils')
local function addEmotionToUnit(emotions,thought,emotion,subthought,severity)
if not (type(emotion)=='number') then emotion=df.emotion_type[emotion] end
if not (type(thought)=='number') then thought=df.unit_thought_type[thought] end
emotions:insert('#',{new=df.unit_personality.T_emotions,
type=emotion,
unk2=1,
@Putnam3145
Putnam3145 / gaydar.lua
Last active August 29, 2015 14:04
Determines the orientation of a citizen, your citizens, everyone on the map or all named units.
local utils = require('utils')
validArgs = utils.invert({
'all',
'citizens',
'named',
'notStraight',
'gayOnly',
'biOnly',
'straightOnly',
@Putnam3145
Putnam3145 / badThoughtCheck.lua
Created April 10, 2014 01:22
Looks through all negative thoughts, gives you the most common one.
do
local function thoughtIsNegative(thought)
return df.unit_thought_type.attrs[thought.type].value:sub(1,1)=='-' and df.unit_thought_type[thought.type]~='LackChairs'
end
local function write_gamelog_and_announce(msg,color)
dfhack.gui.showAnnouncement(msg,color)
local log = io.open('gamelog.txt', 'a')
log:write(msg.."\n")
log:close()
end
@Putnam3145
Putnam3145 / skillChange.lua
Created March 8, 2014 23:18
Allows skills to be changed with DFHack.
-- Allows skills to be changed with DFHack.
--[[
Args are arranged like this:
unitID SKILL level ADD/SUBTRACT/SET
SKILL being anything such as DETAILSTONE, level being a number that it will be set to (15 is legendary, 0 is dabbling).
Add will add skill levels, subtract will subtract, set will place it at exactly the level you put in.
]]