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 1913 times)


  • 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
    qerror('Oops, something internal went wrong')
if dfhack.gui.getSelectedUnit() then
    unit = dfhack.gui.getSelectedUnit()
    active =
    ni = index(active,unit)
    newadv = active[ni]
    adv = active[0]
    active[0] = newadv
    active[ni] = adv
    print('Correctly bodyswapped!')
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 »