Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 3 4 [5]

Author Topic: Libraries and Books  (Read 17827 times)

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Libraries and Books
« Reply #60 on: January 21, 2020, 04:50:59 am »

I think the error is in the line that assumes hist fig vector indices are equal to hist fig id + 1. The "proper" way to get a hist fig is to use the find function. The script as written might work if culling of unimportant hist figs is disabled, but will definitely not work if it's enabled.

The somewhat weird find binary search functions operate on the type contained in the vector, with the actual vector targeted being completely implicit. My guess, without looking at any types, would be something like:
histfig = df.historical_figure.find (unit.hist_figure_id)
Logged

Scruiser

  • Bay Watcher
    • View Profile
Re: Libraries and Books
« Reply #61 on: January 21, 2020, 10:00:18 am »

That sounds like it may be it.  My quick test worlds only had 125 years of history, so I left cull historical figures off, but for my super old world, I had turned it on of course.  I will figure out the correct way of finding the histfig...
Logged
Things I have never done in Dwarf Fortress;

- Won.

therahedwig

  • Bay Watcher
    • View Profile
    • wolthera.info
Re: Libraries and Books
« Reply #62 on: January 21, 2020, 01:57:42 pm »

I never generate worlds with culled histfigs, so that might be why I didn't see it either :)
Logged
Stonesense Grim Dark 0.2 Alternate detailed and darker tiles for stonesense. Now with all ores!

Scruiser

  • Bay Watcher
    • View Profile
Re: Libraries and Books
« Reply #63 on: January 21, 2020, 11:18:11 pm »

The alternative method suggested by PatrikLundell works for that section... but later on the script again uses the hist fig id+1 method in another way...
Line 80
Code: [Select]
maker = df.global.world.history.figures[(book.author+histfigOffset+1)]
I couldn't quite figure out make use of the book.author.  For some reason maker = df.historical_figure.find(book.author) didn't work.  Maybe the book author is a culled historical figure.

So to fix that part, I just commented out the part that finds and prints the book authors.  The full list of books is also kind of cumbersome, I might cut and paste it into a different script.

For now what I have is as follows (note I also commented out the skill information because I can just get that from therapist...).  It seems to be working okay.

Spoiler (click to show/hide)
Logged
Things I have never done in Dwarf Fortress;

- Won.

hun

  • Bay Watcher
    • View Profile
Re: Libraries and Books
« Reply #64 on: January 22, 2020, 03:04:16 am »

On a different note, is there a way (dfhack script?) to search for the specific artifacts for creating a mission? I am trying to raid for specific books, but looking for those manually in the list with hundreds, if not thousands, entries is just insanely tedious.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: Libraries and Books
« Reply #65 on: January 22, 2020, 03:41:20 am »

DF shouldn't cull a hist fig if it has written a book, as it shouldn't leave dangling references around, so if it does, it's a bug.

@hun: It ought to be possible to e.g. write a script that checks that the appropriate raid page is open and inserts an appropriate reference in the correct field. Note, though, that there tends to be multiple books with the same title, so you'd need some way to select the "correct" one.
Logged
Pages: 1 ... 3 4 [5]