Skip to content

Instantly share code, notes, and snippets.

View warmist's full-sized avatar
๐Ÿ•น๏ธ

Warmist warmist

๐Ÿ•น๏ธ
View GitHub Profile
--replaces jobs with selected race workers
local trg_race=338
local workers={}
local bad_jobs={}
for k,v in pairs(df.global.world.units.active) do --find possible workers
if v.civ_id==df.global.ui.civ_id and v.race==trg_race and v.job.current_job==nil and not v.flags1.dead then
table.insert(workers,v)
end
end
local last_id,jobs=dfhack.job.listNewlyCreated(0)
--create fake identity and apply to yourself
local adv=df.global.world.units.active[0]
args={...}
function printHelp()
print("Assume different identity")
print("-n <name> - same race/caste different name")
print("-h <hist_id> - by historical figure id")
print("-r - remove identity")
print("-s <id>: select identity from a list")
end
@warmist
warmist / gist:6146095
Last active December 20, 2015 14:19 — forked from thistleknot/gist:6146077
unit = dfhack.gui.getSelectedUnit()
Physical = {STRENGTH=450, TOUGHNESS=950}
P_Attributes = unit.body.physical_attrs
M_Attributes = unit.status.current_sould.mental_attrs
for attrName, attrValue in pairs(Physical) do
P_Attributes[attrName].value = attrValue
unit = dfhack.gui.getSelectedUnit()
PlusPlus = {700, 1200, 1400, 1500, 1600, 1800, 2500}
Plus = {450, 950, 1150, 1250, 1350, 1550, 2250}
Normal = {200, 700, 900, 1000, 1100, 1300, 2000}
Minus = {150, 600, 800, 900, 1000, 1100, 1500}
Mental_Attribute_Names = {
Mental_PlusPlus = {"FOCUS", "SPATIAL_SENSE"},
Mental_Plus = {"ANALYTICAL_ABILITY", "FOCUS", "CREATIVITY", "PATIENCE", "MEMORY"},
@warmist
warmist / temp.lua
Last active December 21, 2015 01:49 — forked from thistleknot/temp.lua
TraitArrayBins = defclass(TraitArrayBins)
TraitArrayBins.ATTRS={
name=DEFAULT_NIL,
traitMin=0,
traitMed=0,
traitMax=0,
}
function TraitArrayBins.init(args) --not sure if needed
@warmist
warmist / classTest.lua
Last active December 21, 2015 01:49
some more class things
myclass=defclass(myclass)
myclass.ATTRS={name="default name"}
function myclass:init(args)
print("--constructing--")
printall(args)
end
function myclass:tostring()
return self.name .. (self.id or 0)
end
@warmist
warmist / SpawnUnitR3.lua
Last active December 22, 2015 22:49
A variation of spawnunit for r3 with little bug fixes. Ported by Putnam Fix for death age?
--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]
{name="Mount",f=function (unit_list,pos)
horse=getCreatureAtPointer()
for k,unit_rider in pairs(unit_list) do
if unit_rider.pos.x==horse.pos.x and unit_rider.pos.y==horse.pos.y
and unit_rider.pos.z==horse.pos.z then --check if they are on the same tile
horse.general_refs:insert("#",{new=df.general_ref_unit_riderst,unit_id=unit_rider.id})
unit_rider.relations.rider_mount_id=horse.id
unit_rider.flags1.rider=true
horse.flags1.ridden=true
insert_sorted(df.global.world.units.other.ANY_RIDER,unit_rider,"id")
@warmist
warmist / testEventful.lua
Created October 20, 2013 21:06
A eventful test script
local ev=require("plugins.eventful")
local freq={[1]=10,[2]=5,[3]=500,[4]=1000,[5]=500,[6]=100,[7]=1,[8]=1000}
for k,v in pairs(freq) do
ev.enableEvent(k,v)
end
ev.onBuildingCreatedDestroyed.one=function(id) print("building cr/d:",id) end
ev.onConstructionCreatedDestroyed.one=function(id) print("construct cr/d:",id) end
ev.onJobInitiated.one=function(job) print("job init:",job) end
ev.onJobCompleted.one=function(job) print("job complete :",job) end
ev.onUnitDeath.one=function(id) print("death:",id) end
function loopFix()
dofile('hack/scripts/fix/population-cap.lua')
dfhack.timeout(3,'months',loopFix)
end
loopFix()