Bay 12 Games Forum

Dwarf Fortress => DF Modding => Utilities and 3rd Party Applications => Topic started by: FranchuFranchu on May 03, 2018, 03:56:18 pm

Title: DFHack: Bodyswap: Change the controlling unit in adventurer mode
Post by: FranchuFranchu on May 03, 2018, 03:56:18 pm
Finally, a way to do it
Code: [Select]
function index(ls,arg)
    for i,j in ipairs(ls) do
        if j == arg then return i end
    end
    qerror('Oops, something internal went wrong')
end
if dfhack.gui.getSelectedUnit() then
    unit = dfhack.gui.getSelectedUnit()
    active = df.global.world.units.active
    ni = index(active,unit)
    newadv = active[ni]
    adv = active[0]
    active[0] = newadv
    active[ni] = adv
    print('Correctly bodyswapped!')
end
Copy-paste it in a .lua file, put it on hack/scripts and enjoy