df-structures icon indicating copy to clipboard operation
df-structures copied to clipboard

df.global.world.items.other.ANY_COOKABLE may have misleading name

Open PatrikLundell opened this issue 6 years ago • 2 comments

I was trying to locate items that could be cooked, and started to look at what was in the vector mentioned above. However, in my 0.44.12 fortress there are a lot of things that would be cooked only as the result of losing a bet, such as artifact item_toolst with written contents, item_flaskst, item_cagest, item_bucketst, , item_barrelst, and item_boxst (in addition to a lot of things that can probably be cooked, such as e.g. seeds, eggs, drinks, and misc powders ["probably" means I haven't looked deeper to verify the particular seeds are of a cookable kind, etc.]). I have no theory of what the vector is supposed to contain, though, as all the flasks in my fortress are vials (so it can't be organic).

PatrikLundell avatar Nov 01 '18 09:11 PatrikLundell

If it didn't have food in it, my guess would be some missing vectors, like #235. However, that usually breaks other tools that deal with items in various ways, and we haven't had issues with that in 0.44.12-r1 that I know of. However, just to be sure, do any of the nearby vectors in world.items.other have an appropriate name for this group of items?

lethosor avatar Nov 01 '18 15:11 lethosor

No, the vector has food in it, but it also has non food in it. Most of the non food item types are containers, but "books" obviously aren't. The nearby vectors seem to contain what they're supposed to, given their names, while none of the generic ones seem to contain cookable items exclusively. ANY_GENERIC84 (the next one) seems to contain boxes only (I haven't checked everything), and so can't contain all cookable items, even if the boxes contain things following a common theme [which I haven't checked if they do]).

Thus, it seems the vector is misidentified, and is intended for some other purpose.

Edit: It seems ANY_COOKABLE is referenced by kitchen recipes, so it might not be totally wrong. A speculation is that it might be used for multiple purposes, which might include looking for "books" to store into bookcases or library coffers (speculation about why "books" are in there at all. At least one was a blank quire). Boxes might be targets for storing actions?

Edit 2: While not exactly the same issue, the "generic_item" references in df.item_vectors.xml entries seem to be incomplete. I ran a comparison script on my fortress and found EDIBLE_VERMIN_BOX to contain edible stuff; seedst, corpsest, corpsepiecest, eggst, plant_growthst, plantst, foodst, remainsst, powder_miscst. ANY_CAN_ROT contained globst, and ANY_GENERIC36 contained sheetst.

The script in question:

function x ()
  for i, vector in pairs (df.global.world.items.other) do    
    if df.items_other_id.attrs [i].generic_item and
       #df.items_other_id.attrs [i].generic_item > 0 then
      local reported = {}
      
      for k, item in ipairs (vector) do
        local found = false
      
        for l, generic_item in pairs (df.items_other_id.attrs [i].generic_item) do
          if item.getType (item) == generic_item then
            found = true
            break
          end
        end
      
        if not found then
          for l, report in ipairs (reported) do
            if report == item.getType (item) then
              found = true
              break
            end
          end
          
          if not found then
            dfhack.println ("Vector " .. i .. " contains unexpected item type " .. tostring (item._type))
            table.insert (reported, item.getType (item))
          end
        end
      end
    end
  end
end

x ()

PatrikLundell avatar Nov 01 '18 15:11 PatrikLundell