Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 82 83 [84] 85 86 ... 122

Author Topic: DFHack 0.44.12-r2  (Read 173507 times)

Saiko Kila

  • Bay Watcher
  • Dwarven alchemist
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1245 on: July 05, 2018, 02:27:14 am »

I have a problem with function dfhack.units.getVisibleName() in lua script.

When I want the script to show real name, I use simply
Code: [Select]
string.gsub(unit.first_name,"^%l",string.upper)
When I wanted to show fake name, I tried this:
Code: [Select]
string.gsub(dfhack.units.getVisibleName(unit).first_name,"^%l",string.upper)
However, the last code still shows the same real first name as the first one (and thus reveals an identity of a vampire). According to description the function  should show the fake name, right? So why would it show the real one?

And the reason for that is that flags2.killed is the one that tells if a unit is dead. All killed units are inactive, but all inactive units are not killed (e.g. inbound/outbound). Also consider whether you actually need to access the flags directly, or can use the Units.isKilled/.isActive/.isMerchant etc. functions instead.

After the rename I just changed the names of flags in my scripts from "flags1.dead " to "flags1[1]", so they will work with both names under different dfhacks. Problems with functions is that you need to test them first, because they are not always working as expected. Using a flag is quicker and less stressful, if you know what it's supposed to do.
Logged

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1246 on: July 05, 2018, 03:59:05 am »

...the reason for the rename is because it did not mean what we thought it meant and using it to mean "dead" is incorrect so it should be replaced in anything that assumes that having that flag be "true" must mean that unit is dead.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1247 on: July 05, 2018, 07:26:05 am »

Yes, as Putnam said, just changing scripts to use the same flag (regardless of access method) without checking the logic for why that flag is used isn't a winning strategy. Sometimes the logic turns out to work out as desired, and sometimes it needs to be revised. All the scripts and plugins in DFHack have been examined, and many of them had to have their logic revised.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1248 on: July 05, 2018, 08:31:30 am »

Also, flags1[1] is much less readable. Saying you need to "test functions first" is a bad excuse - you can look at the source of isDead here - it's literally just two flag checks that indicate dead units. If you really care about inactive units instead, either use "flags1.inactive" or "not dfhack.units.isActive(unit)".
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.

Saiko Kila

  • Bay Watcher
  • Dwarven alchemist
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1249 on: July 05, 2018, 11:51:26 am »

Also, flags1[1] is much less readable. Saying you need to "test functions first" is a bad excuse - you can look at the source of isDead here - it's literally just two flag checks that indicate dead units. If you really care about inactive units instead, either use "flags1.inactive" or "not dfhack.units.isActive(unit)".

I do care about inactive units. Flag flags1.inactive/flags1.dead (on) and flags2.killed (off) together are used to determine that the unit just went off the map or is coming in (like migrants, merchants, invaders or animals do). So both flags are useful. If I want to make my script usable in two different versions of DF, then I have to use more direct method of accessing, because of this name change. This is much less pain than editing the script for every version separately, when I change something.

That, and some functions are not available in earlier dfhacks, or do not work like I think they should (like this dfhack.units.getVisibleName() I have problem with now, or dfhack.units.isCitizen() I had problems with).
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1250 on: July 05, 2018, 02:15:48 pm »

You should write your own function, then, or just drop support for older DFHack versions. Never use flags1[1] or anything like that - it's just not readable.

The point of functions is that they'll work correctly across DFHack versions, barring bugs. If you find an issue, reporting it is a better solution than ignoring it and using something that will break later. Of course, new functions don't exist in old DFHack versions, but you can implement your own version of a function in a script if that's an issue.

There is a reported issue with getVisibleName: https://github.com/DFHack/dfhack/issues/1279. I think it has to do with new false identity stuff in 0.44. Not quite sure how to fix it.
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.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-alpha1 (dev)
« Reply #1251 on: July 05, 2018, 04:52:24 pm »

The way I deal with support for multiple, incompatible, versions in scripts is to write version dependent scripts, so if it's older than the new structure I use the old name/location, while if it's new I use the new one. One of the few advantages with scripts not checking semantics legality is this ability. I certainly don't complain about newer DFHack versions updating things to be more correct, like e.g. naming anon fields, or removing a nesting level that's probably artificial.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1252 on: July 06, 2018, 07:39:09 pm »

0.44.11-beta1 is up: https://github.com/DFHack/dfhack/releases/tag/0.44.11-beta1
Thanks to BenLubar for handling most of the things I forgot to do when publishing the release.

This should fix the getVisibleName issue, I think. If it doesn't, a save that has issues would be very helpful.
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.

Radipon

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1253 on: July 07, 2018, 05:57:43 am »

The console seems to hang on startup. Encountered on the x86_win64 build and reproduced with a fresh install.
« Last Edit: July 07, 2018, 06:01:17 am by Radipon »
Logged

scourge728

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1254 on: July 07, 2018, 12:37:53 pm »

I can't actually USE the console, it loads and everything, but typing does nothing.....

Imperator314

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1255 on: July 07, 2018, 02:21:12 pm »

I can't actually USE the console, it loads and everything, but typing does nothing.....

Same here. I did a 100% fresh install and I still can't figure it out.
Logged

Ispil

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1256 on: July 07, 2018, 02:51:34 pm »

I can't actually USE the console, it loads and everything, but typing does nothing.....
Same. Alpha1 works fine; Beta1 does not.
Logged
"Those who can make you believe absurdities can make you commit atrocities." - Voltaire

"I have never made but one prayer to God, a very short one: 'O Lord, make my enemies ridiculous.' And God granted it."- Voltaire

I transcribe things, too.

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1257 on: July 07, 2018, 03:20:51 pm »

If you could all specify that you're using Windows, that would help.
In any case, we're aware of the issue: https://github.com/DFHack/dfhack/issues/1345
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.

Imperator314

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1258 on: July 07, 2018, 04:10:10 pm »

If you could all specify that you're using Windows, that would help.

Yes, Windows 10.
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.44.10-r2 | 0.44.11-beta1 (dev)
« Reply #1259 on: July 07, 2018, 06:59:58 pm »

We've found the issue, and 0.44.11-beta2 should be up in an hour or two at https://github.com/dfhack/dfhack/releases to fix it.

Edit: Stonesense is garbage and broke the build. The 64-bit Windows one worked, though, so it's up at https://github.com/DFHack/dfhack/releases/tag/0.44.11-beta2. Just in time for 0.44.12, too! We'll try to get a beta2.1 or something up before moving away from 0.44.11.
« Last Edit: July 07, 2018, 08:32:15 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.
Pages: 1 ... 82 83 [84] 85 86 ... 122