Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: DFHack: Bodyswap: Change the controlling unit in adventurer mode  (Read 2585 times)

FranchuFranchu

  • Escaped Lunatic
  • '); DROP TABLE users;--
    • View Profile

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
« Last Edit: May 03, 2018, 05:22:07 pm by FranchuFranchu »
Logged