Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 209 210 [211] 212 213 ... 243

Author Topic: DFHack 50.13-r1  (Read 812060 times)

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3150 on: April 18, 2022, 05:35:16 am »

What other things are necessary when splitting an item stack using splitStack? Currently when using it (in this case, on an item on the floor) it will create the split item as a phantom item, invisible and uninteractable, though listed if you mouse over the tile with the look menu. I've tried then using dfhack.items.moveToGround in case it needed placing somewhere, but that doesn't seem to fix it.

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r4
« Reply #3151 on: April 18, 2022, 04:44:44 pm »

What other things are necessary when splitting an item stack using splitStack? Currently when using it (in this case, on an item on the floor) it will create the split item as a phantom item, invisible and uninteractable, though listed if you mouse over the tile with the look menu. I've tried then using dfhack.items.moveToGround in case it needed placing somewhere, but that doesn't seem to fix it.
Somewhat counterintuitively, dfhack.items.moveToGround only works on items that are properly located somewhere in the world - if they're already in the "detached" state (as they are immediately after splitting a stack), the operation will fail. What you need to do is call the moveToGround(x,y,z) vmethod on the item itself.
« Last Edit: April 18, 2022, 04:46:22 pm by Quietust »
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3152 on: April 19, 2022, 02:20:20 am »

What other things are necessary when splitting an item stack using splitStack? Currently when using it (in this case, on an item on the floor) it will create the split item as a phantom item, invisible and uninteractable, though listed if you mouse over the tile with the look menu. I've tried then using dfhack.items.moveToGround in case it needed placing somewhere, but that doesn't seem to fix it.
Somewhat counterintuitively, dfhack.items.moveToGround only works on items that are properly located somewhere in the world - if they're already in the "detached" state (as they are immediately after splitting a stack), the operation will fail. What you need to do is call the moveToGround(x,y,z) vmethod on the item itself.
Unfortunately, even after changing to use the vmethod version, I'm still having the same problem with phantom items :c

myk

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3153 on: April 23, 2022, 12:21:43 am »

Anybody know why autochop might be marking my trees in marker instead of standard?
DF is not very good about clearing flags from tiles, so it is very possible that there are leftover "marker" flags on the surface tiles that are getting in the way. That being said, autochop should really handle this case and ensure the marker flag is off for trees that it designates. Could you file a bug for this at https://github.com/DFHack/dfhack/issues ?
Logged

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r4
« Reply #3154 on: April 25, 2022, 04:39:21 pm »

What other things are necessary when splitting an item stack using splitStack? Currently when using it (in this case, on an item on the floor) it will create the split item as a phantom item, invisible and uninteractable, though listed if you mouse over the tile with the look menu. I've tried then using dfhack.items.moveToGround in case it needed placing somewhere, but that doesn't seem to fix it.
Somewhat counterintuitively, dfhack.items.moveToGround only works on items that are properly located somewhere in the world - if they're already in the "detached" state (as they are immediately after splitting a stack), the operation will fail. What you need to do is call the moveToGround(x,y,z) vmethod on the item itself.
Unfortunately, even after changing to use the vmethod version, I'm still having the same problem with phantom items :c
Now that I think about it, I'm pretty sure you also need to categorize(true) the item after it's been split.

Also, it looks like moving the item to the ground is only necessary if you specify false for the last parameter - if you specify true, then the newly-split item will be placed in the exact same location as the original item (on the floor, in a container, in a building, or even in another creature's inventory), just like when food items get claimed for eating.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3155 on: April 26, 2022, 01:14:37 pm »

What other things are necessary when splitting an item stack using splitStack? Currently when using it (in this case, on an item on the floor) it will create the split item as a phantom item, invisible and uninteractable, though listed if you mouse over the tile with the look menu. I've tried then using dfhack.items.moveToGround in case it needed placing somewhere, but that doesn't seem to fix it.
Somewhat counterintuitively, dfhack.items.moveToGround only works on items that are properly located somewhere in the world - if they're already in the "detached" state (as they are immediately after splitting a stack), the operation will fail. What you need to do is call the moveToGround(x,y,z) vmethod on the item itself.
Unfortunately, even after changing to use the vmethod version, I'm still having the same problem with phantom items :c
Now that I think about it, I'm pretty sure you also need to categorize(true) the item after it's been split.

Also, it looks like moving the item to the ground is only necessary if you specify false for the last parameter - if you specify true, then the newly-split item will be placed in the exact same location as the original item (on the floor, in a container, in a building, or even in another creature's inventory), just like when food items get claimed for eating.
Out of curiosity, what does categorize(true) do?  I searched through the DFHack documentation and could find anything about a function with that name.
Logged
Really hoping somebody puts this in their signature.

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r4
« Reply #3156 on: April 26, 2022, 05:41:22 pm »

Out of curiosity, what does categorize(true) do?  I searched through the DFHack documentation and could find anything about a function with that name.
It's not part of DFHack, but a virtual method within Dwarf Fortress itself.

If you look at df.global.world.items, you will see a list named "all" and a whole bunch of lists inside "other". What categorize() does is insert references to the item into all of the "other" lists according to the item's properties (and the "true" parameter in particular adds it to the "IN_PLAY" list at the top).

These "other" lists are used primarily for finding job items more quickly - instead of a hungry dwarf having to check every single item in your fortress (including all of the rocks in your mining tunnels), it just needs to look in the "ANY_EDIBLE_RAW" list to find something to eat. In case you're curious, Buildings are "categorized" in the exact same way.

For what it's worth, I just checked the "find food" code (which uses splitStack) in an older DF version and it does immediately call categorize(true) on the newly-split item. Of course, it's also possible the version I'm looking at is too old (which is certainly possible since the version I checked was v0.23.130.23a) and that the current version needs to do more stuff afterwards, but it'll take me a while to find the relevant code in 0.47.05.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

A_Curious_Cat

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3157 on: April 26, 2022, 06:11:13 pm »

Out of curiosity, what does categorize(true) do?  I searched through the DFHack documentation and could find anything about a function with that name.
It's not part of DFHack, but a virtual method within Dwarf Fortress itself.

If you look at df.global.world.items, you will see a list named "all" and a whole bunch of lists inside "other". What categorize() does is insert references to the item into all of the "other" lists according to the item's properties (and the "true" parameter in particular adds it to the "IN_PLAY" list at the top).

These "other" lists are used primarily for finding job items more quickly - instead of a hungry dwarf having to check every single item in your fortress (including all of the rocks in your mining tunnels), it just needs to look in the "ANY_EDIBLE_RAW" list to find something to eat. In case you're curious, Buildings are "categorized" in the exact same way.

For what it's worth, I just checked the "find food" code (which uses splitStack) in an older DF version and it does immediately call categorize(true) on the newly-split item. Of course, it's also possible the version I'm looking at is too old (which is certainly possible since the version I checked was v0.23.130.23a) and that the current version needs to do more stuff afterwards, but it'll take me a while to find the relevant code in 0.47.05.
Fascinating.  Thanks for the explanation.  I assume I can look at this with gui/gm-editor, right?  If it requires Lua, than I’m currently putting off learning Lua while I try and learn C++ first (I first tried to learn C, but it turned out the book I got was too old.  Then I found a found a good website for learning C++…)
Logged
Really hoping somebody puts this in their signature.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3158 on: April 27, 2022, 08:09:14 am »

What other things are necessary when splitting an item stack using splitStack? Currently when using it (in this case, on an item on the floor) it will create the split item as a phantom item, invisible and uninteractable, though listed if you mouse over the tile with the look menu. I've tried then using dfhack.items.moveToGround in case it needed placing somewhere, but that doesn't seem to fix it.
Somewhat counterintuitively, dfhack.items.moveToGround only works on items that are properly located somewhere in the world - if they're already in the "detached" state (as they are immediately after splitting a stack), the operation will fail. What you need to do is call the moveToGround(x,y,z) vmethod on the item itself.
Unfortunately, even after changing to use the vmethod version, I'm still having the same problem with phantom items :c
Now that I think about it, I'm pretty sure you also need to categorize(true) the item after it's been split.

Also, it looks like moving the item to the ground is only necessary if you specify false for the last parameter - if you specify true, then the newly-split item will be placed in the exact same location as the original item (on the floor, in a container, in a building, or even in another creature's inventory), just like when food items get claimed for eating.
That did it - thanks! I could finally release one of the mods I've been sitting on :D

There was a bit of jank I ran into (though managed to avoid): Weirdly the categorized items would disappear completely if splitStack was used with copying contaminants set to false, and while split items usually ended up in the same location as the original item, that didn't happen for items in unit's inventories (in that case I had to use the moveToGround method first before then using a function to work out where the original stack is equipped + dfhack.items.moveToInventory).

Quietust

  • Bay Watcher
  • Does not suffer fools gladly
    • View Profile
    • QMT Productions
Re: DFHack 0.47.05-r4
« Reply #3159 on: April 27, 2022, 08:52:54 am »

Weirdly the categorized items would disappear completely if splitStack was used with copying contaminants set to false
That flag isn't for copying contaminants - it's for preserving contAINment (i.e. putting it inside the same building, item, or unit inventory as the original item). I suppose "same_location" might've been a better name for that parameter, since even I've misread it in the same way that you did.
Logged
P.S. If you don't get this note, let me know and I'll write you another.
It's amazing how dwarves can make a stack of bones completely waterproof and magmaproof.
It's amazing how they can make an entire floodgate out of the bones of 2 cats.

Atkana

  • Bay Watcher
  • [CURIOUSBEAST]
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3160 on: April 27, 2022, 09:19:03 am »

Weirdly the categorized items would disappear completely if splitStack was used with copying contaminants set to false
That flag isn't for copying contaminants - it's for preserving contAINment (i.e. putting it inside the same building, item, or unit inventory as the original item). I suppose "same_location" might've been a better name for that parameter, since even I've misread it in the same way that you did.
Oh whoops, I guess since I'd been making a mod based around contaminants while reading the documentation, I had them on my mind :P That makes more sense.

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3161 on: April 29, 2022, 06:18:51 pm »

Hello, I am trying to understand how to use Eventful.

In the Musket mode, there's a check that is supposed to delete bullets on impact (but doesn't, I cannot figure out why yet).
I tried to test and explicitly delete projectiles by name, it didn't work.

Spoiler (click to show/hide)

To understand it better, I would like to know why is it called like this:
"eventful.onProjItemCheckImpact.musket"

Can someone explain to me what does ".musket" at the end mean in this call?
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

Putnam

  • Bay Watcher
  • DAT WIZARD
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3162 on: April 29, 2022, 06:32:33 pm »

That's just the name of the function. Lua functions are first-class, i.e. they're just variables like anything else. That line is adding a function named musket to the onProjItemCheckImpact table; every function in that table is called when a projectile impacts something.

Deon

  • Bay Watcher
  • 💀 💀 💀 💀 💀
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3163 on: April 29, 2022, 07:29:47 pm »

Gotcha, so I dont need to register it in some magical place I couldn't find. I was missing the fact that it auto-calls all functions loaded. Thank you, Putnam.
Logged
▬(ஜ۩۞۩ஜ)▬
✫ DF Wanderer ✫ - the adventure mode crafting and tweaks
✫ Cartographer's Lounge ✫ - a custom worldgen repository

lethosor

  • Bay Watcher
    • View Profile
Re: DFHack 0.47.05-r4
« Reply #3164 on: April 29, 2022, 09:33:47 pm »

Fascinating.  Thanks for the explanation.  I assume I can look at this with gui/gm-editor, right?  If it requires Lua, than I’m currently putting off learning Lua while I try and learn C++ first (I first tried to learn C, but it turned out the book I got was too old.  Then I found a found a good website for learning C++…)
Depends on what "this" is. You can definitely look at df.global.world or other globals (you can actually leave off the "df.global" prefix in gui/gm-editor and the Lua interpreter, so running "gui/gm-editor world" will work, or "gui/gm-editor world.items" if you want to pull up the items collection directly).

Methods, on the other hand, are not easily enumerable from Lua. You can call them, if you know their name, but if you don't know them, you'd need to look up a list in the df-structures XML files. gui/gm-editor also doesn't support calling arbitrary methods.
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 ... 209 210 [211] 212 213 ... 243