1. dfhack.gui.getDepthAt(x, y) - This states that it "Returns the distance from the z-level of the tile at map coordinates (x, y) to the closest ground z-level below". I'm not really sure what it is tying to say, since it doesn't take a z level as an argument.
Like Warmist said, it's for TWBT. Maybe the docs should read "distance in z-levels" or something. Basically, it's supposed to take in x and y map coordinates, and calculate the number of z-levels you would need to move down to reach a solid tile. This only happens when TWBT or another plugin is enabled that implements this behavior, though. The
default behavior is to always return 0.
3. dfhack.items.moveToBuilding(item,building[,use_mode[,force_in_building]) - When using force_in_building, should use_mode = 2? Is force_in_building temporary?
force_in_building is only used
here. It looks to me like the opposite of what you said - if you want the item to be "in" the building, and
don't set use_mode = 2, you'll need to set force_in_building = true. I'm not very familiar with why this behavior makes sense, though.
4. dfhack.buildings.checkFreeTiles(pos,size[,extents,change_extents,allow_occupied]) - What is the format for size?
From its
definition, it takes a df::coord2d. Not sure off the top of my head whether there's a shorthand, but passing in a table with "x" and "y" keys set might work.
How do I check the type of a block_events struct in Lua? I want the one of type df.block_square_event_type.frozen_liquid (if it exists for the block.)
I see the line <vmethod ret-type='block_square_event_type' name='getType'/> in df/structures, but I'm sure if I can call that in Lua.
Is there a proper way to do this, or should I just check for the existence of a "tiles" array (which only the frozen_liquid type seems to have?)
A couple other ways, in addition to what Warmist mentioned:
df.block_square_event_frozen_liquidst:is_instance(event)
event._type == df.block_square_event_frozen_liquidst
https://docs.dfhack.org/en/stable/docs/Lua%20API.html#struct-references mentions vmethod calls, by the way, although it is a very brief mention.
Found something odd in MapCache.cpp:
<snip>
The checks for G_SOIL and G_STONE seem to be swapped. Is this a mistake or not?
At first glance, I think it's intentional. In the soil case, it looks up the material at the specified position. If it happens to actually be stone, instead of soil, then it tries to look up the default soil type, and uses that for the return value instead if it's available.
Are you seeing behavior that would suggest that this is incorrect, or did this just look surprising from a read-through?