Skip to content

Instantly share code, notes, and snippets.

@Putnam3145
Putnam3145 / SpawnUnitR3.lua
Created October 17, 2013 09:21 — forked from warmist/SpawnUnitR3.lua
Just in case I ever feel the need to modify it.
--create unit at pointer or given location. Usage e.g. "spawnunit DWARF 0 Dwarfy"
--Made by warmist, but edited by Putnam for the dragon ball mod to be used in reactions
--note that it's extensible to any autosyndrome reaction to spawn anything due to this; to use in autosyndrome, you want \COMMAND spawnunit CREATURE caste_number name \LOCATION
args={...}
function getCaste(race_id,caste_id)
local cr=df.creature_raw.find(race_id)
return cr.caste[caste_id]
@Putnam3145
Putnam3145 / custom-artifact.lua
Last active December 11, 2017 20:37
Allows the addition of custom artifacts with arbitrary name, mat and type to the world in Dwarf Fortress.
-- Makes it so that the world will always have certain artifacts in certain sites when world loads.
--@ module = true
--Author Putnam
local usage = [===[
modtools/custom-artifact
=====================
This tool, when run, checks if the specific item has an artifact record somewhere in the world
and places the artifact at a valid site (which can be constrained by arguments) if it is not found.
@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)
local df_date={} --lol I really should put this in its own file
df_date.__eq=function(date1,date2)
return date1.year==date2.year and date1.year_tick==date2.year_tick
end
df_date.__lt=function(date1,date2)
if date1.year<date2.year then return true end
if date1.year>date2.year then return false end
if date1.year==date2.year then
@Putnam3145
Putnam3145 / teleport.lua
Created October 31, 2013 02:58
Lets you teleport units; syntax is: number after unit is unit id, number after x,y,z is related position number, showunitid will show unit under cursor's ID, showpos will show position under cursor. Just a unit or just a position can be supplied; if either is the case, the cursor will be used to determine what the remaining variable is.
local function teleport(unit,pos)
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]
unit.pos.x = pos.x
unit.pos.y = pos.y
unit.pos.z = pos.z
if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end
end
local function getArgsTogether(args)
local settings={
@Putnam3145
Putnam3145 / ClickableLabel.lua
Created May 8, 2016 05:56
An intuitive clickable text label for DFHack UI purposes.
local gui=require('gui')
local widgets=require('gui.widgets')
local ClickableLabel=defclass(ClickableLabel,widgets.Label)
ClickableLabel.ATTRS.on_click=DEFAULT_NIL
ClickableLabel.ATTRS.on_rclick=DEFAULT_NIL
@Putnam3145
Putnam3145 / skilroll.lua
Created December 7, 2013 10:16
Allows for skill-based script running. DFHack Lua scripts only, unfortunately; no plugins or ruby scripts.
-- Allows skills to activate lua scripts.
--[[Example usage:
...syndrome stuff...
[SYN_CLASS:\COMMAND][SYN_CLASS:skillroll][SYN_CLASS:\WORKER_ID] For autoSyndrome/syndromeTrigger.
[SYN_CLASS:MELEE_COMBAT] Can use any skill.
[SYN_CLASS:20] Rolls d20. Skill will be weighted to this value.
[SYN_CLASS:DICEROLL_1] If diceroll ends up as one...
[SYN_CLASS:kill][SYN_CLASS:\SKILL_UNIT_ID] Theoretical kill-given-unit-id command; slayrace doesn't do so.
[SYN_CLASS:DICEROLL_10] If diceroll is between 1 and 10 (2-10, inclusive)...
@Putnam3145
Putnam3145 / itemsyndromeR3.lua
Last active December 29, 2015 03:39
Itemsyndrome for DFHack-0.34.11-r3.
-- 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:")
print(' "help": displays this dialogue.')
print(" ")
print(' "disable": disables the script.')
print(" ")
@Putnam3145
Putnam3145 / Spawnunit.lua
Last active December 27, 2015 03:09 — forked from warmist/Spawnunit.lua
forked it so I can make age more proper. Also fixed it for r4's release and moved random numbers to local rng instead of global.
--create unit at pointer or given location. Usage e.g. "spawnunit DWARF 0 Dwarfy"
--Made by warmist, but edited by Putnam for the dragon ball mod to be used in reactions
--note that it's extensible to any autosyndrome reaction to spawn anything due to this; to use in autosyndrome, you want \COMMAND spawnunit CREATURE caste_number name \LOCATION
args={...}
local rando=dfhack.random.new()
@Putnam3145
Putnam3145 / take-slave.lua
Created October 18, 2013 01:43
A variant of Kurik Amudnil's hire-guard.lua that forces the unit to become a civ creature rather than checking.
-- Takes slaves. Hooks reactions that start with LUA_HOOK_TAKE_SLAVE. Copied very much from hire-guard.lua: http://dffd.wimbli.com/file.php?id=7785
--[[
sample reaction
[REACTION:LUA_HOOK_TAKE_SLAVE_DROW]
[NAME:Take someone ]
[BUILDING:TANNER:NONE]
[REAGENT:A:10000:COIN:NONE:INORGANIC:GOLD]
[PRODUCT:10:0:BOULDER:NONE:INORGANIC:CLAY][PRODUCT_DIMENSION:10]
[SKILL:TANNER]