Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View IndigoFenix's full-sized avatar

Daniel Nadel IndigoFenix

View GitHub Profile
-- Uses a reaction to spawn a living creature that uses the materials of the reagents as body components. Reactions must begin with LUA_HOOK_CONSTRUCTCREATURE
--[[
You can have as many reagents as you like.
Reagents starting with USE will replace materials used in the creature, in the order that they are defined.
Make sure that each USE reagent consists of one item only. Otherwise, the second item taken will be counted as the second material.
Using tools as intermediary reagents is probably your best option for expensive creatures.
The product field determines the creature produced, where the material is CREATURE_MAT:(your creature):NONE. The probability should be set at 0 to avoid actually creating a boulder.
If you want to select a specific caste, the product field should have a PRODUCT_DIMENSION for the caste.
However, to make the creature's color show up based on its material, the creature must have 16 castes, one for each color.
@IndigoFenix
IndigoFenix / timestream.lua
Last active September 4, 2020 15:27
Multiplies the speed of calendar time by the specified value.
-- Multiplies the speed of calendar time by the specified value. The parameter can be any positive number, though going over 10 is likely to cause bugs. 1 is normal speed.
args={...}
local rate=tonumber(args[1])
local prev_tick = 0
if rate == nil then
rate = 1
elseif rate < 0 then
rate = 0
end
@IndigoFenix
IndigoFenix / exile.lua
Last active May 1, 2019 23:34
Sends units away into the wild. Options include fort members, pets, wild animals, invaders, merchants, and diplomats. Can select one or all units. Exiled units will attempt to leave the map.
-- Sends units away into the wild
args={...}
local targetUnit=dfhack.gui.getSelectedUnit()
if targetUnit == nil and args[2] ~= 'all' then
local targetUnit = df.unit.find(tonumber(args[2]))
end
group = args[1]
@IndigoFenix
IndigoFenix / slam.lua
Last active January 4, 2016 00:39
Slam a unit into the ground.
-- Slam a unit into the ground
args={...}
local unit=dfhack.gui.getSelectedUnit()
if unit == nil then
local unit = df.unit.find(tonumber(args[2]))
end
local strength=args[1]
if unit == nil then
@IndigoFenix
IndigoFenix / creature_sscc_examples
Last active September 22, 2015 14:43
Enables soul manipulation and constructing creatures in reactions.
creature_sscc_examples
[OBJECT:CREATURE]
Special classes for use with the SoulShuffle and ConstructCreature scripts:
DFHACK_CONSTRUCTCREATURE_CASTECOLORS - Uses the caste color system to make creatures show up with the color of their construction material. See below.
DFHACK_CONSTRUCTCREATURE_ITEMCORPSE - Causes the creature's itemcorpse to take on the same material as its first defined material.
DFHACK_SOULSHUFFLE_SCUTTLE_ON_REMOVAL - The creature will die when its soul is removed.
DFHACK_SOULSHUFFLE_VANISH_ON_REMOVAL - The creature will vanish into smoke when its soul is removed.
@IndigoFenix
IndigoFenix / druidism.lua
Last active August 29, 2015 14:14
Enables druidic reactions, which allow the taming and manipulation of animals.
-- Enables nature merit system and reactions that utilize nature merit.
--[[
--New system:
effectiveskill(for taming) = skill
respectvalue = ((skill*5)^2)
interestvalue = merit/10
floor((1-((petvalue/2)/respectvalue))*100) = prob of success in a respect conflict
same thing with interestvalue to determine likelihood of taming
@IndigoFenix
IndigoFenix / ghostly.lua
Last active August 29, 2015 14:13
Turns a selected unit into a ghost and back again. Works in adventure mode too!
--Turn ghost on or off
local unit=dfhack.gui.getSelectedUnit()
if unit == nil then
unit = df.unit.find(df.global.ui_advmode.player_id)
end
if unit then
if unit.flags1.dead then
@IndigoFenix
IndigoFenix / add-exp.lua
Last active August 29, 2015 14:01
Adds a set amount of experience in a particular skill to a unit.
--Gives a unit a certain amount of experience in a certain skill, leveling them up as appropriate. Intended for autosyndrome. Params: Unit id, skill name, exp. amount, max level (20 by default).
local args = {...}
local ok = true
--local unit=dfhack.gui.getSelectedUnit()
local unit = df.unit.find(tonumber(args[1]))
local skillname = args[2]
local amount = args[3]
local maxlevel = args[4]
if maxlevel == nil then maxlevel = 20 end
@IndigoFenix
IndigoFenix / hfspit.lua
Last active August 29, 2015 13:55
Creates a pit under the target leading straight to the Underworld.
---Creates a pit under the target leading straight to the Underworld. Type '?' for help.
args={...}
if args[1] == '?' then
print("First parameter is target unit id, or 0 to select a location with the cursor.\n Second parameter is size of the pit in all directions.\n Third parameter is 1 to wall off the sides of the pit on all layers except the underworld, or anything else to leave them open. (Leaving them open may allow flying cave-dwellers to path to your fortress if you have normal access to the caverns)\n Fourth parameter is 1 to add stairs. Note that stairs are a bit buggy, as they will not reveal the bottom until you dig somewhere, but will still allow underworld creatures to path to your fortress.")
return
end
if args[1] ~= nil then