Merge remote-tracking branch 'dfhack/develop' into develop

Conflicts:
	NEWS
develop
expwnent 2014-11-14 18:58:21 -05:00
commit a474bc4dea
5 changed files with 125 additions and 21 deletions

10
NEWS

@ -1,10 +1,15 @@
DFHack Future
Internals:
EventManager should handle INTERACTION triggers a little better. It still can get confused about who did what but only rarely.
devel/all-bob.lua: renames everyone Bob to help test interaction-trigger
lua/persist-table.lua: a convenient way of using persistent tables of arbitrary structure and dimension in Lua
Fixes:
full-heal: Updated with proper argument handling.
New scripts:
scripts/
add-thought.lua
allows the user to add thoughts to creatures.
devel/
all-bob.lua: renames everyone Bob to help test interaction-trigger
DFHack 0.40.15-r1
Fixes:
@ -42,6 +47,9 @@ DFHack 0.40.14-r1
- civ-view-agreement: Fixes overlapping text on the "view agreement" screen
- nestbox-color: Fixes the color of built nestboxes
Misc Improvements:
- exportlegends.lua can now handle site maps
DFHack 0.40.13-r1
Internals:
- unified spatter structs

@ -1420,12 +1420,15 @@ Export dwarves to RuneSmith-compatible XML.
exportlegends
-------------
Exports data from legends mode; allowing a set-and-forget export of large worlds.
Controls legends mode to export data - especially useful to set-and-forget large
worlds, or when you want a map of every site when there are several hundred.
Options:
:info: Exports the world/gen info and the legends XML
:sites: Exports all available site maps
:maps: Exports all seventeen detailed maps
:all: first exports the world/gen info, then the XML, then all detailed maps
:all: Equivalent to calling all of the above, in that order
Job management

@ -60,7 +60,6 @@ keybinding add Ctrl-Shift-B "adv-bodyswap force"
# export all information, or just the detailed maps (doesn't handle site maps)
keybinding add Ctrl-A@legends "exportlegends all"
keybinding add Ctrl-D@legends "exportlegends maps"
#############################
# Context-specific bindings #

@ -0,0 +1,67 @@
-- Adds emotions to creatures.
local utils=require('utils')
local function addEmotionToUnit(emotions,thought,emotion,severity,subthought)
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,
unk3=1,
thought=thought,
subthought=subthought,
severity=severity,
flags=0,
unk7=0,
year=df.global.cur_year,
year_tick=df.global.cur_year_tick
})
end
validArgs = validArgs or utils.invert({
'unit',
'thought',
'emotion',
'severity',
'gui'
})
function tablify(iterableObject)
t={}
for k,v in ipairs(iterableObject) do
t[k] = v~=nil and v or 'nil'
end
return t
end
local args = utils.processArgs({...}, validArgs)
local unit = args.unit and df.unit.find(args.unit) or dfhack.gui.getSelectedUnit(true)
if not unit then qerror('A unit must be specified or selected.') end
if args.gui then
local script=require('gui.script')
script.start(function()
local tok,thought=script.showListPrompt('emotions','Which thought?',COLOR_WHITE,tablify(df.unit_thought_type),10,true)
if tok then
local eok,emotion=script.showListPrompt('emotions','Which emotion?',COLOR_WHITE,tablify(df.emotion_type),10,true)
if eok then
local sok,severity=script.showInputPrompt('emotions','At what severity?',COLOR_WHITE,'0')
if sok then
addEmotionToUnit(unit.status.current_soul.personality.emotions,thought,emotion,severity,0)
end
end
end
end)
else
local thought = args.thought or 180
local emotion = args.emotion or -1
local severity = args.severity or 0
local subthought = args.subthought or 0
addEmotionToUnit(unit.status.current_soul.personality.emotions,thought,emotion,severity,subthought)
end

@ -1,8 +1,7 @@
-- Export everything from legends mode
-- use "exportlegends maps" for detailed maps, or "exportlegends all" to also export legends
-- Valid args: "all", "info", "maps", "sites"
gui = require 'gui'
local args = {...}
local vs = dfhack.gui.getCurViewscreen()
local i = 1
@ -26,8 +25,18 @@ local MAPS = {
"Nobility and Holdings",
"Diplomacy",
}
-- export information and XML ('p, x')
function export_legends_info()
print(' Exporting: World map/gen info')
gui.simulateInput(vs, 'LEGENDS_EXPORT_MAP')
print(' Exporting: Legends xml')
gui.simulateInput(vs, 'LEGENDS_EXPORT_XML')
end
-- presses 'd' for detailed maps
function wait_for_legends_vs()
vs = dfhack.gui.getCurViewscreen()
local vs = dfhack.gui.getCurViewscreen()
if i <= #MAPS then
if df.viewscreen_legendsst:is_instance(vs) then
gui.simulateInput(vs, 'LEGENDS_EXPORT_DETAILED_MAP')
@ -37,30 +46,48 @@ function wait_for_legends_vs()
end
end
end
-- selects detailed map and export it
function wait_for_export_maps_vs()
vs = dfhack.gui.getCurViewscreen()
if df.viewscreen_export_graphical_mapst:is_instance(vs) then
local vs = dfhack.gui.getCurViewscreen()
if dfhack.gui.getCurFocus() == "export_graphical_map" then
vs.sel_idx = i
print(' Exporting: '..MAPS[i]..' map')
i = i + 1
gui.simulateInput(vs, 'SELECT')
i = i + 1
dfhack.timeout(10,'frames',wait_for_legends_vs)
else
dfhack.timeout(10,'frames',wait_for_export_maps_vs)
end
end
if df.viewscreen_legendsst:is_instance( vs ) then -- dfhack.gui.getCurFocus() == "legends"
if args[1] == "all" then
gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_MAP)
print(' Exporting: world map/gen info')
gui.simulateInput(vs, df.interface_key.LEGENDS_EXPORT_XML)
print(' Exporting: legends xml')
-- export site maps
function export_site_maps()
local vs = dfhack.gui.getCurViewscreen()
print(' Exporting: All possible site maps')
vs.main_cursor = 1
gui.simulateInput(vs, 'SELECT')
for i=1, #vs.sites do
gui.simulateInput(vs, 'LEGENDS_EXPORT_MAP')
gui.simulateInput(vs, 'STANDARDSCROLL_DOWN')
end
gui.simulateInput(vs, 'LEAVESCREEN')
end
-- main()
if dfhack.gui.getCurFocus() == "legends" then
if args[1] == "all" then
export_legends_info()
export_site_maps()
wait_for_legends_vs()
elseif args[1] == "maps" then wait_for_legends_vs()
elseif args[1] == "info" then
wait_for_legends_vs()
elseif args[1] == "maps" then
wait_for_legends_vs()
elseif args[1] == "sites" then
export_site_maps()
else dfhack.printerr('Valid arguments are "all", "info", "maps" or "sites"')
end
elseif df.viewscreen_export_graphical_mapst:is_instance(vs) then
if args[1] == "maps" or args[1] == "all" then wait_for_export_maps_vs() end
else
dfhack.printerr('Not in legends view')
end
dfhack.printerr('Not in main legends view')
end