Good News! I have figured out how to butcher a corpse using a script. All you need is the corpse id (or unit id). unfortunately my only access to the internet for the next month or so is through work, and I can't put any files on these computers which means I can't upload anything. So I won't be able to upload my script, but I can give a walkthrough here of the steps and if someone else is adventurous they can upload a script (it's really pretty simple). Note that this is just an outline and the variables are from memory, so they might not be exactly right;
- change df.global.gametype to DWARF_ARENA
- change df.global.ui.main.mode to LOOK_AROUND
- change df.global.cursor.x/y/z to the x/y/z of the corpse (if given a unit id, find it's corpse first)
- iterate through df.global.ui_look_list until you find the corpse item id
- change df.global.ui_look to the index from df.global.ui_look_list
- simulate the input for butchering
- return df.ui.main.mode and df.global.gametype to what they were when you started
And there you have it, a butchered creature with a script. Now I haven't fully tested the behavior or even the outputs of butchering an animal this way vs the normal way, so that may throw a wrench in things.
On a related note, is there a script for creating trees? Because I realized when I was doing this that you could create trees the same way we create units with modtools/create-unit. You can even specify the age of the tree and a few other things (like type). Wasn't sure if we could already do this, but if not then a simple edit of create-unit will give you create-tree.
On an unrelated note, I have a lua programming question. Say I have a table, Table.A.B.C.D.E, if I want to check if the last entry is there I can simply do if Table.A.B.C.D.E then ... But if I want to check if the last entry is there and I'm not sure if the others are there I have to do a nested if, (i.e.
if Table.A then
if Table.A.B then
if Table.A.B.C then
if Table.A.B.C.D then
if Table.A.B.C.D.E then ...
Is there a simpler way of doing this? Can I do, if Table.A and Table.A.B and Table.A.B.C and Table.A.B.C.D and Table.A.B.C.D.E then ...?