Skip to content

Commit

Permalink
Update search-filter.lua
Browse files Browse the repository at this point in the history
I believe I'm done. I couldn't figure out how to add panels/tabs/buttons to the widget, but that's ok. I changed the conditions so visitors and hostile can be searched alongside citizens using the program.
  • Loading branch information
unboundlopez authored Oct 5, 2023
1 parent ca8714e commit 1d2f3c3
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions search-filter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function SearchEngine:getFortControlledUnits()
-- Use the race name if the unit's name field is empty
unitName = dfhack.units.getRaceName(unit)
end
if dfhack.units.isFortControlled(unit) then
if dfhack.units.isVisible(unit) and dfhack.units.isActive(unit) then
table.insert(fortControlledUnits, {text=unitName, search_normalized=dfhack.toSearchNormalized(unitName), id=unit.id})
end
end
Expand All @@ -62,7 +62,6 @@ function SearchEngine:onSelect(index, unit)
-- Assign the unit to a specific id
local unit = df.unit.find(unit.id)

print(unit.id)
-- Get the position of the unit and center the camera on the unit
local x, y, z = dfhack.units.getPosition(unit)
dfhack.gui.revealInDwarfmodeMap(xyz2pos(x, y, z), true)
Expand All @@ -81,6 +80,8 @@ df.global.enabler.mouse_lbut = 1
df.global.enabler.mouse_lbut_down = 1

-- Simulate a left mouse click at the current mouse position
gui.simulateInput(dfhack.gui.getDFViewscreen(), '_MOUSE_R')

gui.simulateInput(dfhack.gui.getDFViewscreen(), '_MOUSE_L')

-- Disable mouse tracking and set the left mouse button as not pressed
Expand Down

0 comments on commit 1d2f3c3

Please sign in to comment.