Skip to content

Instantly share code, notes, and snippets.

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

Warmist warmist

๐Ÿ•น๏ธ
View GitHub Profile
@warmist
warmist / spellbook.lua
Last active December 10, 2015 00:59
A list of functions easily called
--show a list of 'spells'
local dlg=require("gui.dialogs")
function doNothing()
print("Doing nothing real good")
end
function greetAndStuff()
dlg.showMessage("Greetings", "Season's greatings and lols")
@warmist
warmist / make-monarch.lua
Created January 4, 2013 17:05
A script for changing monarchy
--set target unit as king/queen
local unit=dfhack.gui.getSelectedUnit()
if not unit then qerror("No unit selected") end
local newfig=dfhack.units.getNemesis(unit).figure
local my_entity=df.historical_entity.find(df.global.ui.civ_id)
local monarch_id
for k,v in pairs(my_entity.positions.own) do
if v.code=="MONARCH" then
monarch_id=v.id
break
@warmist
warmist / arena-list.lua
Created January 11, 2013 21:49
Fills the arena mode spawn table
--add races to the arena spawn list
local arena_spawn=df.global.world.arena_spawn
arena_spawn.race:resize(0)
arena_spawn.caste:resize(0)
for num,race in pairs(df.global.world.raws.creatures.all) do
for caste_id,caste in pairs(race.caste) do
arena_spawn.race:insert("#",num)
arena_spawn.caste:insert("#",caste_id)
end
end
--teleport in travel map
local utils=require("utils")
if df.global.ui_advmode.travel_not_moved then
qerror("please leave current site")
end
print("Current location:",pos2xy(df.global.world.world_data.travel[0].pos))
print("Teleport to:")
local tx=utils.prompt_input("x:",utils.check_number,"q")
local ty=utils.prompt_input("y:",utils.check_number,"q")
if tx and ty then
@warmist
warmist / thoughts.lua
Last active December 11, 2015 21:28
A thought collector
local events_by_type={}
for k,v in pairs(df.global.world.units.active) do
if dfhack.units.isCitizen(v) then
local mytypes={}
for idx,event in pairs(v.status.recent_events) do
local t=event.type
if mytypes[t]==nil then
if events_by_type[t] then
events_by_type[t]=events_by_type[t]+1
else
@warmist
warmist / init.lua
Last active December 14, 2015 11:49
Adv-mode additions
local eventful=require("plugins.eventful")
function add_site(size,civ,site_type,name)
local x=(df.global.world.map.region_x+1)%16;
local y=(df.global.world.map.region_y+1)%16;
local minx,miny,maxx,maxy
if(x<size) then
minx=0
maxx=2*size
elseif(x+size>16) then
maxx=16
@warmist
warmist / waypoints.lua
Last active December 14, 2015 12:59
Adv mode teleportation cheat in travel map.
-- adv mode waypoint system.
local args={...}
function printHelp()
print("An adventure mode travel map teleporation system.")
print(" -s <name> - save current position as <name> waypoint")
print(" -g <name> - goto waypoint <name>")
print(" -dg <name> - goto waypoint <name>")
print(" -d <name> - delete waypoint")
print(" -l (or no arguments) - list waypoint names")
listWaypoints()
@warmist
warmist / bla.lua
Created March 7, 2013 07:16
Using body modifiers
local race=465
local modifiers={}
local modifiers_idx={}
local caste=df.creature_raw.find(race).caste[1]
local bp=caste.bp_appearance
local unit=dfhack.gui.getSelectedUnit()
for k,v in pairs(bp.modifiers) do
if v.noun=='hair' then
print(k,df.appearance_modifier_type[v.type])
modifiers_idx[k]=true
@warmist
warmist / portals.lua
Last active December 15, 2015 02:59
Gui teleportation thingy... Needs a way to add waypoints... maybe...
--traveling mk2
--if map is loaded then
local dialog = require("gui.dialogs")
function showWaypointDialog(onSelect,onCancel)
local choices={}
local wps=dfhack.persistent.get_all('!WP!/',true)
if wps~=nil then
for k,v in ipairs(wps) do
table.insert(choices,{text=string.sub(v.key,6),x=v.ints[1],y=v.ints[2]})
end
@warmist
warmist / advfort.lua
Last active December 15, 2015 07:49
Advfort with workshop filter and filters by race.
-- allows to do jobs in adv. mode.
--[==[
version: 0.002
changelog:
*0.002
- kind-of fixed the item problem... now they get teleported (if teleport_items=true which should be default for adventurer)
- gather plants still not working... Other jobs seem to work.
- added new-and-improved waiting. Interestingly it could be improved to be interuptable.
--]==]