Bay 12 Games Forum

Please login or register.

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

Author Topic: relations-indicator [DFHack lua script] 1.17  (Read 27977 times)

Saiko Kila

  • Bay Watcher
  • Dwarven alchemist
    • View Profile
Re: relations-indicator [DFHack lua script] 1.13
« Reply #15 on: August 02, 2018, 02:58:12 pm »

Hi, I get a problem sometimes, when the script relations.indicator freezes the game. Technically it doesn't freeze it (I can still run scripts from console), it just disables keyboard input or something  in the main window, and to exit game I need to "die".

The problem is with lines 323 and 324:
Code: [Select]
323:                    if text:find("STERILE") or
324:                       text:find("OPPOSED_TO_LIFE") then
The error thrown is:
Spoiler (click to show/hide)

It seems that sometimes (on some units) the value returned by iterator is not string type but userdata type, which doesn't have this method (i.e. find).

I changed the lines to these:
Code: [Select]
323:                    if string.find(tostring(text),"STERILE") or
324:                       string.find(tostring(text),"OPPOSED_TO_LIFE") then

The conversion (tostring) is important. I don't know if it works as intended now, but at least it won't "freeze" my game anymore.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: relations-indicator [DFHack lua script] 1.13
« Reply #16 on: August 02, 2018, 03:12:24 pm »

Oh, that.

I'm aware of the bug...Was wondering if it would crop up.

See, the thing is: "text" is stored not as a string, but as value pair with text.value being the actual string. (I guess calling tostring() on it also works).

Why didn't I fix it, then?

Because I only encountered it in the custom changed compile of dfhack I did - it didn't throw the error, for the same unit, in normal 43.03 compile *shrug*.

For future reference, all scripts with my gui/indicator-screen close themselves on "?" as that is not implemented (on purpose).

Tested it being broken with a handy save on 44.10, my already-done fix for that working, and uploaded the fix (1.14). But feel free to keep using your old one.
« Last Edit: August 02, 2018, 03:16:44 pm by Fleeting Frames »
Logged

Saiko Kila

  • Bay Watcher
  • Dwarven alchemist
    • View Profile
Re: relations-indicator [DFHack lua script] 1.13
« Reply #17 on: August 02, 2018, 03:46:28 pm »

For future reference, all scripts with my gui/indicator-screen close themselves on "?" as that is not implemented (on purpose).

OK, pressing "?" kills the script and returns control. May be useful if some other issue shows up.

BTW, it's a nitpick but you are referring to the gui script (here and in the original post) as "indicator-screen", but the relations-indicator uses "indicator_screen"... I initially named the script as "indicator-screen.lua", and wondered why this didn't work :P
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: relations-indicator [DFHack lua script] 1.13
« Reply #18 on: August 02, 2018, 05:51:00 pm »

devel/pop-screen will also dismiss any screen that's open (note that if you run this when just one screen is open, it will quit DF). But that will work even if the screen doesn't implement a safety feature itself (no need for "die").

Edit:
See, the thing is: "text" is stored not as a string, but as value pair with text.value being the actual string. (I guess calling tostring() on it also works).
It's actually a pointer, and .value is equivalent to dereferencing the pointer in C++.

Note that tostring() will NOT work as you expect - it will produce something like "<string: 0x1286737>", which is a string representation of the pointer, not the actual value. tostring() doesn't do anything special for different types of pointers (e.g. pointers to strings).

Quote
Because I only encountered it in the custom changed compile of dfhack I did - it didn't throw the error, for the same unit, in normal 43.03 compile *shrug*.
Usually non-pointers don't change to pointers. But 0.43.03 is ancient enough that maybe something else changed.


Edit 2: late here, but
i love the idea of this, but when i put the relations indicator and indicator screen luas into the right places, i came across a problem - the onmapload_extra.init doesn't exist, so i popped the keybinds into the dfhack.init which seemed to work.
In general, you could just create the file.
Fleeting Frames: keybinding commands affect the whole DF session, so they don't require a map to be loaded. Sure, the commands being run may require a map, but "keybinding" itself doesn't care at all. You even provided contexts for all of them, which prevents them from running before a map is loaded, which is good. But telling people to add them to dfhack.init would be better - that's where all of the default keybindings are.
(Oh, and the "_extra" suffix isn't necessary either - anything matching "onMapLoad*.init" or "onLoadMap*.init" will work.)
« Last Edit: August 02, 2018, 06:03:11 pm by lethosor »
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: relations-indicator [DFHack lua script] 1.13
« Reply #19 on: August 02, 2018, 09:55:19 pm »

@string: Hm, *tests*, right you are. How foolish and optimistic was I to merely guess!

(For those who don't know what is dereferencing a pointer, it means .value outputs the actul text (tested).)

@keybinds: figured it'd save processor cycles to have them in onmapload_init, but there's not much difference. Corrected.

@Saiko Kila: Huh. So I did. Sorry about that.

lethosor

  • Bay Watcher
    • View Profile
Re: relations-indicator [DFHack lua script] 1.13
« Reply #20 on: August 03, 2018, 09:24:21 am »

(For those who don't know what is dereferencing a pointer, it means .value outputs the actul text (tested).)
(Technically it doesn't have to be strings - there are pointers to integers and other things too, although only pointers to primitive types like strings and integers require ".value" to get to the value. Basically, primitive pointers are represented in Lua as a structure with one field, "value", which is the value at the address pointed to.)
Quote
@keybinds: figured it'd save processor cycles to have them in onmapload_init, but there's not much difference. Corrected.
dfhack.init runs in a separate thread so it doesn't delay startup. onLoad*.init files don't. Really, though, "keybinding" commands themselves are very fast. The only noticeably slow thing in the default dfhack.init that I know of is enabling plugins which use vmethod hooks (e.g. ones that draw/intercept input on existing screens, like "search"), because that requires patching read-only memory and can be slow.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Uthimienure

  • Bay Watcher
  • O frabjous day!!
    • View Profile
Re: relations-indicator [DFHack lua script] 1.14
« Reply #21 on: July 31, 2020, 05:41:43 pm »

I must be doing something wrong (DFHack is sometimes confusing to me), indicator_screen.lua and relations-indicator.lua are in the proper folders.

I edited dfhack.init as shown:

Spoiler (click to show/hide)

Open DF in an existing fortress, and this happens:

Spoiler (click to show/hide)

I probably need some basic help, so hopefully it's obvious what's wrong to experienced Hack users.
Logged
"I've never really had issues with the old DF interface (I mean, I loved even 'umkh'!)" ... brewer bob
As we say in France: "ah, l'amour toujours l'amour"... François D.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: relations-indicator [DFHack lua script] 1.14
« Reply #22 on: July 31, 2020, 10:57:07 pm »

I probably need some basic help, so hopefully it's obvious what's wrong to experienced Hack users.

I'd guess "historical_figure_info.unk_14" got a proper name and the script hasn't been updated to use it.

Or something changed in the data with the Villains release, such as children out of wedlock, which the script doesn't account for.
« Last Edit: July 31, 2020, 11:21:28 pm by Bumber »
Logged
Reading his name would trigger it. Thinking of him would trigger it. No other circumstances would trigger it- it was strictly related to the concept of Bill Clinton entering the conscious mind.

THE xTROLL FUR SOCKx RUSE WAS A........... DISTACTION        the carp HAVE the wagon

A wizard has turned you into a wagon. This was inevitable (Y/y)?

lethosor

  • Bay Watcher
    • View Profile
Re: relations-indicator [DFHack lua script] 1.14
« Reply #23 on: August 01, 2020, 12:05:12 am »

I'd guess "historical_figure_info.unk_14" got a proper name and the script hasn't been updated to use it.
It did indeed change, to "whereabouts" (as of 0.47.04-beta1): https://github.com/dfhack/df-structures/commit/c3c06bd988623fa9dc0a9d2d34bd242137b9308c#diff-35ab45624fa78d4a8c071f3c0fee5d76L128

It looks like there are two instances of "unk_14" in this script, on lines 681 and 682. If you change both of those to "whereabouts", that should resolve the issue you're seeing. There could be other issues, though, given that this script appears to have last been updated in 2018.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.

Uthimienure

  • Bay Watcher
  • O frabjous day!!
    • View Profile
Re: relations-indicator [DFHack lua script] 1.14
« Reply #24 on: August 01, 2020, 10:50:03 am »

Thanks, that worked, and as you thought there are other issues. And aside from the next issue that popped up, I'm only seeing the script work in a small part of what is outlined by Fleeting Frames in the OP here.

So I'll leave this in Fleeting Frames' hands.
Logged
"I've never really had issues with the old DF interface (I mean, I loved even 'umkh'!)" ... brewer bob
As we say in France: "ah, l'amour toujours l'amour"... François D.

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: relations-indicator [DFHack lua script] 1.15
« Reply #25 on: August 02, 2020, 10:01:50 pm »

Whoops, sorry about missing this earlier; wasn't diligent enough when going through new replies...

This should work at glance. Minimal changes, such as keeping the now antique 10 year limit for pairs checking (Unknown mechanics: It's supposed to expand with loneliness, and go up to ⅓ age - or is that the other way around and how quick does that happen?).

It's not like I don't have future progress saved in local copies, but that's not complete - and more importantly, stalled because post-47 relationships aren't clear.

For instance, I disabled checking for grudges in above copy; being that I'm not sure how to distill loyalty, fear, love, respect, trust, and possibly some anons into actual grudges right now. Previously it was just checking a number, now there's a vector stored where that number used to be.

That said, with the new intrigue webs it can be fairly said relationships have become more important now than before. Unfortunately, as you might guess, I haven't really played much .47 yet (on account of earlier forts).

PatrikLundell

  • Bay Watcher
    • View Profile
Re: relations-indicator [DFHack lua script] 1.15
« Reply #26 on: August 03, 2020, 02:36:27 am »

The age relation logic is known; it was described by Toady in a FotF:
- They're compatible age-wise if the older is at most ½ again the younger party's age, or 10 years older is that's a greater range. This means that up to an age of 20 the old +/- 10 years rule controls the range, and when older than that it's the +50% one that's in effect.
- Hist fig relations are completely controlled by the Love value beyond the passing/long-term one (which is only based on some version of time). The exact boundaries where the relation change are described in my "47" pull request (which is in a rather laborious process of being checked for acceptance). The other values factor in when it comes to intrigue related influencing and the resistance to it, but have no effect on the relations visible to players (i.e. the relations screen).
- Note that there are also competitive grudges in vague relationships.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: relations-indicator [DFHack lua script] 1.15
« Reply #27 on: August 03, 2020, 11:14:19 am »

I did read that bit in FotF, but I also read devlog notes that their range expands when they spend enough time unmarried.

Good to know about love being sole factor; though I'm afraid I could not find the link after spending some time traversing your github for 2020 - can you point me the link?

Not sure if those bar marriages or not, though; albeit even if they don't there can be stoic interest in charting grudges in fortress.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: relations-indicator [DFHack lua script] 1.15
« Reply #28 on: August 03, 2020, 04:14:05 pm »

Here's the page with the pull requests https://github.com/DFHack/df-structures/pulls. At the time of this posting it's the second outstanding one (out of 3), and if it's gone from there it's would have been accepted.

You can also find the code here https://github.com/PatrikLundell/df-structures/tree/47 (not up to date, as I tired of merging in things conflicting with my stuff that others did long after my changes).

Unless I've misunderstood things, the marriage range expands naturally as characters get older (1½ year per year, once past 20), which is what I think Toady referred to.
Thus: A 20, B 40. Not eligible.
10 years later: A 30, B 50. Still not eligible.
10 years after that: A 40, B 60. Yes, A has finally gotten B inside the eligibility window (but only just: it's now down to specific dates).
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: relations-indicator [DFHack lua script] 1.15
« Reply #29 on: August 04, 2020, 12:29:50 am »

Here's the page with the pull requests https://github.com/DFHack/df-structures/pulls. At the time of this posting it's the second outstanding one (out of 3), and if it's gone from there it's would have been accepted.

You can also find the code here https://github.com/PatrikLundell/df-structures/tree/47 (not up to date, as I tired of merging in things conflicting with my stuff that others did long after my changes).
Yeah, that's partly my fault. I should have merged it sooner before the conflicts arose. For what it's worth, I do plan on fixing those and merging it before r2, hopefully this week. (I looked at it late one night last week, and it looked too complicated for me to deal with right then.) For reference, it's usually easier to review multiple smaller and logically-separated PRs than one large PR (although it is admittedly harder to make multiple PRs, especially when you want to use changes from more than one of them at a time). I will try to merge them in faster in the future. If you do have additional updates that you haven't pushed, I would be happy to review those once I've gotten your current 0.47 PR taken care of.
Logged
DFHack - Dwarf Manipulator (Lua) - DF Wiki talk

There was a typo in the siegers' campfire code. When the fires went out, so did the game.
Pages: 1 [2] 3