Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 196 197 [198] 199 200 ... 243

Author Topic: DFHack 50.13-r2  (Read 820258 times)

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2955 on: June 22, 2021, 06:15:39 pm »

Code: [Select]
extern DFHACK_EXPORT df::plant *getPlantAtCoords(int32_t x, int32_t y, int32_t z);

inline df::plant *getPlantAtCoords(df::coord pos) { return getPlantAtCoords(pos.x, pos.y, pos.z); }

Was getting a red squiggly line for "return Lua::PushDFObject" in "static int maps_getPlantAtCoords(lua_State *L)" with the message. Error was result of copying from "maps_getTileBiomeRgn" and editing to "PushDFObject", instead of from "maps_ensureTileBlock" (which returns 1.)

Doing it like getBlock with WRAPN seems to work. Not used to working with function pointers, so the syntax was confusing.

How does the Lua C API way determine which implementation it's using?


Edit: Doesn't look like it's accepting DFCoord (using xyz2pos) in Lua using WRAPN with cast. C API works for both DFCoord and three int32_ts.
The function passed to WRAP is the one that's exposed to Lua. Casting the function to a specific type essentially forces the compiler to pick the implementation of that function that can be cast to that type - otherwise it would be ambiguous (I could have phrased this better earlier). if you're choosing to expose the one that takes (int32, int32, int32) params to Lua, you will only be able to pass those from Lua, not a df::coord object, and vice versa if you expose the other implementation. There isn't a way to support both types of arguments without using the Lua C API. If you want to do that, there are several examples - maps_getTileBlock() might be a good one since it returns a map_block pointer.
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.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2956 on: June 25, 2021, 11:07:28 am »

I made a small script that uses the new function to get a tree at the cursor and print a representation of its tree_tiles:
Code: (print-tree.lua) [Select]
--Print the tree at cursor
--@module = true

function printTreeTile(bits,roots)
local old_color = dfhack.color()
local none = true
if bits.trunk then
dfhack.color(COLOR_BROWN)
if roots then
dfhack.print(string.char(172)) --1/4
else
dfhack.print("O")
end
none = false
end
if bits.branches then
dfhack.color(COLOR_GREEN)
dfhack.print(string.char(172)) --1/4
none = false
end
if bits.twigs then
dfhack.color(COLOR_GREEN)
dfhack.print(";")
none = false
end
if bits.connection_north then
dfhack.color(COLOR_RESET)
dfhack.print(string.char(24)) --up arrow
none = false
end
if bits.connection_south then
dfhack.color(COLOR_RESET)
dfhack.print(string.char(25)) --down arrow
none = false
end
if bits.connection_west then
dfhack.color(COLOR_RESET)
dfhack.print(string.char(27)) --left arrow
none = false
end
if bits.connection_east then
dfhack.color(COLOR_RESET)
dfhack.print(string.char(26)) --right arrow
none = false
end
if bits.blocked then
dfhack.color(COLOR_RED)
dfhack.print("x")
none = false
end
if none then
dfhack.color(COLOR_RESET)
dfhack.print(".")
end
dfhack.color(old_color)
end

function printTree(t)
if not t then
return
end
print("---------------------------------------------------------")
for z = t.body_height-1, 0, -1 do
for i = 0, t.dim_x*t.dim_y-1 do
printTreeTile(t.body[z]:_displace(i))
if i%t.dim_x == t.dim_x-1 then
print("\t|")
else
dfhack.print("\t")
end
end
print("---------------------------------------------------------")
end
for z = 0, t.roots_depth-1 do
for i = 0, t.dim_x*t.dim_y-1 do
printTreeTile(t.roots[z]:_displace(i),true)
if i%t.dim_x == t.dim_x-1 then
print("\t|")
else
dfhack.print("\t")
end
end
print("---------------------------------------------------------")
end
end

if not dfhack_flags.module then
p = dfhack.maps.getPlantAtTile(pos2xyz(df.global.cursor))

if p then
printTree(p.tree_info)
end
end

Bits:
O/¼ - Trunk/Roots
¼ - Branches
; - Twigs
↑/↓/←/→ - Connects N/S/W/E
x - Blocked
. - Empty



« Last Edit: June 25, 2021, 11:18:56 am 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)?

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2957 on: July 03, 2021, 08:36:41 pm »

Is there any way to use DFHack to recover a book that has fallen over a waterfall, or is using pumps (including  some that would has to be placed at the bottom of a ravine) to dam and drain the riverbed the only way?  I tried using autodump, but it seems that books can’t be marked for dumping.  Any help would be greatly appreciated.
Logged
Really hoping somebody puts this in their signature.

Bumber

  • Bay Watcher
  • REMOVE KOBOLD
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2958 on: July 03, 2021, 08:49:22 pm »

Is there any way to use DFHack to recover a book that has fallen over a waterfall, or is using pumps (including  some that would has to be placed at the bottom of a ravine) to dam and drain the riverbed the only way?  I tried using autodump, but it seems that books can’t be marked for dumping.  Any help would be greatly appreciated.

Try "gui/gm-editor" with your cursor on the book. You should be able to edit its coordinates.

Maybe I should write a teleport-item script that can move any item anywhere.
« Last Edit: July 03, 2021, 08:51:39 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)?

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2959 on: July 03, 2021, 09:26:57 pm »

Is there any way to use DFHack to recover a book that has fallen over a waterfall, or is using pumps (including  some that would has to be placed at the bottom of a ravine) to dam and drain the riverbed the only way?  I tried using autodump, but it seems that books can’t be marked for dumping.  Any help would be greatly appreciated.

Try "gui/gm-editor" with your cursor on the book. You should be able to edit its coordinates.

Maybe I should write a teleport-item script that can move any item anywhere.

How do I find out what coordinates to send it to?
Logged
Really hoping somebody puts this in their signature.

PatrikLundell

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2960 on: July 04, 2021, 02:05:28 am »

Place the cursor on the location you want to teleport the item to (any of the cursor types will do, such as k, v, or t). Type gui/gm-editor df.global.cursor. The coordinates you see are the coordinates of the cursor location.
Logged

Fleeting Frames

  • Bay Watcher
  • Spooky cart at distance
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2961 on: July 04, 2021, 03:21:54 am »

Is there any way to use DFHack to recover a book that has fallen over a waterfall, or is using pumps (including  some that would has to be placed at the bottom of a ravine) to dam and drain the riverbed the only way?  I tried using autodump, but it seems that books can’t be marked for dumping.  Any help would be greatly appreciated.

Try "gui/gm-editor" with your cursor on the book. You should be able to edit its coordinates.

Maybe I should write a teleport-item script that can move any item anywhere.

You want dfhack.items.moveToGround instead. Catches corner issues like occupancy.

Btw, already wrote something like that:
Spoiler: hackdump.lua (click to show/hide)
For safety, by default only dumps forbidden items on ground that aren't in job or inventory, but  this can be altered ofc.

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2962 on: July 04, 2021, 05:37:03 pm »

I followed PatrikLundell and Bumber’s advice (didn’t see Freeting Flames’ post until afterwards).  The only problem is that the ‘k’ look command stopped working until I saved and reloaded.  Thanks, everyone!
Logged
Really hoping somebody puts this in their signature.

chickrickepachimecho

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2963 on: July 05, 2021, 02:33:03 pm »

I want to make 3 plugins for dfhack.

One that can cut down the one non food tree that will give the most wood.
Another for taking all the dwarves bad thoughts and listing them with the number of times it has occurred.
The last one would count all the dwarves worn clothes and print out a list with numbers of how many worn clothes there are of each subtype.

Do these sound feasible? Are they replicating functionality already built in?

I plan on starting with the tree one since autochop is a thing.
Logged

Kat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2964 on: July 05, 2021, 03:25:11 pm »

Hello,
I was using the "show unit syndromes" in my game, and it was throwing an error on one of the citizens, who had a vampire curse active on them. It wouldn't show syndromes on any other citizens after it found the cursed one.

in the stderr.log, it has this:

Invoking: show-unit-syndromes
E: NoMethodError: undefined method `unk_6c' for #<DFHack::CreatureInteractionEffectBodyMatInteractionst:0x000000090e48c8>
 hack/scripts/show-unit-syndromes.rb:840:in `get_effect'
 hack/scripts/show-unit-syndromes.rb:886:in `block (2 levels) in <top (required)>'
 E:/Dwarf stuff/df_47_05_win/hack/ruby/ruby-autogen-defs.rb:439:in `block in each'
 E:/Dwarf stuff/df_47_05_win/hack/ruby/ruby-autogen-defs.rb:439:in `each'
 E:/Dwarf stuff/df_47_05_win/hack/ruby/ruby-autogen-defs.rb:439:in `each'
 hack/scripts/show-unit-syndromes.rb:886:in `collect'
 hack/scripts/show-unit-syndromes.rb:886:in `block in <top (required)>'
 hack/scripts/show-unit-syndromes.rb:947:in `[]'

Once I used add-syndrome to remove the syndrome (I used -eraseClass with both VAMPCURSE and DISTURBANCE_CURSE), then show-unit-syndromes ran properly with all citizens with syndromes shown.

Would this be because I am using modded creatures in my game ? Or because those kinds of curses cause a problem with the show-unit-syndromes command ?
Logged

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2965 on: July 05, 2021, 11:28:53 pm »

Hello,
I was using the "show unit syndromes" in my game, and it was throwing an error on one of the citizens, who had a vampire curse active on them. It wouldn't show syndromes on any other citizens after it found the cursed one.

in the stderr.log, it has this:

Invoking: show-unit-syndromes
E: NoMethodError: undefined method `unk_6c' for #<DFHack::CreatureInteractionEffectBodyMatInteractionst:0x000000090e48c8>
 hack/scripts/show-unit-syndromes.rb:840:in `get_effect'
 hack/scripts/show-unit-syndromes.rb:886:in `block (2 levels) in <top (required)>'
 E:/Dwarf stuff/df_47_05_win/hack/ruby/ruby-autogen-defs.rb:439:in `block in each'
 E:/Dwarf stuff/df_47_05_win/hack/ruby/ruby-autogen-defs.rb:439:in `each'
 E:/Dwarf stuff/df_47_05_win/hack/ruby/ruby-autogen-defs.rb:439:in `each'
 hack/scripts/show-unit-syndromes.rb:886:in `collect'
 hack/scripts/show-unit-syndromes.rb:886:in `block in <top (required)>'
 hack/scripts/show-unit-syndromes.rb:947:in `[]'

Once I used add-syndrome to remove the syndrome (I used -eraseClass with both VAMPCURSE and DISTURBANCE_CURSE), then show-unit-syndromes ran properly with all citizens with syndromes shown.

Would this be because I am using modded creatures in my game ? Or because those kinds of curses cause a problem with the show-unit-syndromes command ?
It's an issue with the script. Looks like you're the first one that's reported it since it broke a year or so ago, so thank you! (It may be a rare case - I don't seem to have a save where I can reproduce the issue easily.)

Here's a fix that should work. If you can test it out, that'd be great. You can either make the changes manually to hack/scripts/show-unit-syndromes.rb, or replace that file with the new version (be sure to save the new one with a ".rb" extension and overwrite the existing one).

This fix will also be in the next DFHack release, which is hopefully soon.
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.47.05-r1
« Reply #2966 on: July 06, 2021, 01:43:50 am »

I want to make 3 plugins for dfhack.

One that can cut down the one non food tree that will give the most wood.
Another for taking all the dwarves bad thoughts and listing them with the number of times it has occurred.
The last one would count all the dwarves worn clothes and print out a list with numbers of how many worn clothes there are of each subtype.

Do these sound feasible? Are they replicating functionality already built in?

I plan on starting with the tree one since autochop is a thing.
I'd suggest writing Lua scripts rather than plugins, as it seems these are intended to be used as commands entered by the player, and neither of them should require compiled code for efficiency reasons.
All of them seem to be quite possible to implement.

As a starting point for the first one, here's one of my scripts intended to control which trees to cut, sparing one of each resource providing kind of tree, selecting the ones closest to the center of the embark. It skips cavern trees, and deals with elven logging restrictions.
Spoiler (click to show/hide)
Logged

Kat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2967 on: July 06, 2021, 01:25:58 pm »

It's an issue with the script. Looks like you're the first one that's reported it since it broke a year or so ago, so thank you! (It may be a rare case - I don't seem to have a save where I can reproduce the issue easily.)

Here's a fix that should work. If you can test it out, that'd be great. You can either make the changes manually to hack/scripts/show-unit-syndromes.rb, or replace that file with the new version (be sure to save the new one with a ".rb" extension and overwrite the existing one).

ah, I don't have an earlier save. I _do_ know the curse that was inflicted on the unit concerned though. Can I apply that again somehow ? curse was "DEITY_CURSE_VAMPIRE_19"
Logged

stroppycarpet

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2968 on: July 07, 2021, 01:32:57 pm »

Hello everybody.


I'm running a modded DF that adds special military castes that have a really bad learning rate in all skills except a few skills they're specialized in. (a few skills are +100% exp, and all others are -1% or raw value -101 meaning they will never level up)
Unfortunately the mod author forgot to add a very crucial skill (discipline) to the list of skills that have a bonus, meaning they can never level up discipline.
It's running an older verion of dfhack, namely 0.44.12-r2.

My first go-to fix was to search the dfhack documentation and there's a script mentioned there, assign-skills which allows you to set skill levels.
I dragged and dropped the assign-skills.lua into the folder with all my dfhack scripts from the mod, and it did work.

However, it left me curious on how to mod learning rate for individual dwarves if I wanted to. I noticed that in assign-skills.lua theres a line that says "unit.status.current_soul.skills" in order to access the skill levels. Is there a similar 'method' for skill rate like .e.g.  unit.status.current_soul.skillrates? Does this exist? If I were to assign something to that, how do I assign to it?

Or you could point me to a list of all the possible methods or objects within "unit", because I can't find it.

thanks in advance!
Logged

Clément

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r1
« Reply #2969 on: July 07, 2021, 02:13:22 pm »

If Dwarf Therapist is doing it correctly, there is no individual skill rate, it's only in castes (caste_raw.skill_rates). Did you try fixing the raws first? It might not need to re-run worldgen.
Logged
Pages: 1 ... 196 197 [198] 199 200 ... 243