Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Erase current unit using dfhack?  (Read 5517 times)

utunnels

  • Bay Watcher
  • Axedwarf
    • View Profile
Erase current unit using dfhack?
« on: February 10, 2015, 03:32:04 am »

If I want to erase current selected unit from existence, how do I do it?

1) Select an unit/object like you do before calling gm-editor
2) run a script to erase the unit
Logged
The troglodyte head shakes The Troglodyte around by the head, tearing apart the head's muscle!

Risen Asteshdakas, Ghostly Recruit has risen and is haunting the fortress!

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Erase current unit using dfhack?
« Reply #1 on: February 10, 2015, 04:49:53 am »

Code: [Select]
dfhack.gui.getSelectedUnit().animal.vanish_countdown=1

Just put that after "lua" in the command line. You could also set animal.vanish_countdown to 1 with gm-editor.

utunnels

  • Bay Watcher
  • Axedwarf
    • View Profile
Re: Erase current unit using dfhack?
« Reply #2 on: February 10, 2015, 09:23:41 am »

Code: [Select]
dfhack.gui.getSelectedUnit().animal.vanish_countdown=1

Just put that after "lua" in the command line. You could also set animal.vanish_countdown to 1 with gm-editor.

Thanks.
However, the unit will appear in deceased/missing list.
Is there a way to erase them from the unit list, like that fix/dead-units script?



Edit*
Oh, I think I figured it out.

Code: [Select]
local units = df.global.world.units.active
local curunit = dfhack.gui.getSelectedUnit()

for i=#units-1,0,-1 do
    if units[i]==curunit then
        units:erase(i)
        break
    end
end

Now I saved the script as rm.lua, run rm from dfhack command line and the unit just vanished.
« Last Edit: February 10, 2015, 09:54:45 am by utunnels »
Logged
The troglodyte head shakes The Troglodyte around by the head, tearing apart the head's muscle!

Risen Asteshdakas, Ghostly Recruit has risen and is haunting the fortress!

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Erase current unit using dfhack?
« Reply #3 on: February 10, 2015, 10:04:15 am »

This has no negative effect on the save? I imagine that the game might complain in some form or another about units that are suddenly gone without any death message, etc.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

utunnels

  • Bay Watcher
  • Axedwarf
    • View Profile
Re: Erase current unit using dfhack?
« Reply #4 on: February 10, 2015, 10:08:47 am »

That fix/dead-units script only removes dead units. But dead units are also units. I don't know how the script works. So what happens to the unit? Is it still in memory or the game gets rid of it once for all?
Logged
The troglodyte head shakes The Troglodyte around by the head, tearing apart the head's muscle!

Risen Asteshdakas, Ghostly Recruit has risen and is haunting the fortress!

Roses

  • Bay Watcher
    • View Profile
Re: Erase current unit using dfhack?
« Reply #5 on: February 10, 2015, 10:19:47 am »

I'm unsure, but I would guess if you just remove a unit from the units list you will get some pretty serious issues (game crashing kind) if the unit was a noble, or in a relationship, or really anything that is connected to some other thing. The fix/dead-units only works on "uninteresting" units, meaning ones that aren't historical figures pretty much. Trying to :erase() a historical figure is bound to cause problems.
Logged

Meph

  • Bay Watcher
    • View Profile
    • worldbicyclist
Re: Erase current unit using dfhack?
« Reply #6 on: February 10, 2015, 10:42:26 am »

I remember deleting units some time ago (when trying to figure out emigration) and the saves always (100% of the time) started crashing. But that was a different command and on 34.11.
Logged
::: ☼Meph Tileset☼☼Map Tileset☼- 32x graphic sets with TWBT :::
::: ☼MASTERWORK DF☼ - A comprehensive mod pack now on Patreon - 250.000+ downloads and counting :::
::: WorldBicyclist.com - Follow my bike tours around the world - 148 countries visited :::

utunnels

  • Bay Watcher
  • Axedwarf
    • View Profile
Re: Erase current unit using dfhack?
« Reply #7 on: February 10, 2015, 10:54:34 am »

I'm unsure, but I would guess if you just remove a unit from the units list you will get some pretty serious issues (game crashing kind) if the unit was a noble, or in a relationship, or really anything that is connected to some other thing. The fix/dead-units only works on "uninteresting" units, meaning ones that aren't historical figures pretty much. Trying to :erase() a historical figure is bound to cause problems.
I see.
Logged
The troglodyte head shakes The Troglodyte around by the head, tearing apart the head's muscle!

Risen Asteshdakas, Ghostly Recruit has risen and is haunting the fortress!

ptb_ptb

  • Bay Watcher
    • View Profile
Re: Erase current unit using dfhack?
« Reply #8 on: February 10, 2015, 04:00:43 pm »

Could you exile them, and then kill them only after they've left the fortress?
Logged
()==[:::::::::::::>

utunnels

  • Bay Watcher
  • Axedwarf
    • View Profile
Re: Erase current unit using dfhack?
« Reply #9 on: February 10, 2015, 07:09:41 pm »

Perhaps.
My purpose was removing useless units from memory.
But if it is not safe, maybe I'm not going to use it.

By the way, dead-units also removes forgotten beasts. They are certainly historical figures.
Logged
The troglodyte head shakes The Troglodyte around by the head, tearing apart the head's muscle!

Risen Asteshdakas, Ghostly Recruit has risen and is haunting the fortress!

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: Erase current unit using dfhack?
« Reply #10 on: February 10, 2015, 07:12:27 pm »

Doesn't fix/dead-units basically remove useless units from memory anyway?

ptb_ptb

  • Bay Watcher
    • View Profile
Re: Erase current unit using dfhack?
« Reply #11 on: February 11, 2015, 06:35:54 am »

By the way, dead-units also removes forgotten beasts. They are certainly historical figures.
Are they historical beings _before_ they kill anyone?
Logged
()==[:::::::::::::>

utunnels

  • Bay Watcher
  • Axedwarf
    • View Profile
Re: Erase current unit using dfhack?
« Reply #12 on: February 12, 2015, 02:05:36 am »

By the way, dead-units also removes forgotten beasts. They are certainly historical figures.
Are they historical beings _before_ they kill anyone?
Yes. You can view them in legends mode.
Logged
The troglodyte head shakes The Troglodyte around by the head, tearing apart the head's muscle!

Risen Asteshdakas, Ghostly Recruit has risen and is haunting the fortress!