api.txt 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Hopper API
  2. ----------
  3. This API is kept simple by adding a single command which allows mods to add
  4. containers like chests and furnaces to the hopper check list.
  5. Command Usage
  6. -------------
  7. Make sure any mods using this function has 'hopper' in the depends.txt file.
  8. hopper:add_container({ {"where_from", "node_name", "inventory_name"} })
  9. 'where_from' is a string telling the api that items are coming from either
  10. the 'top' node into a hopper below, going into the 'bottom' node
  11. from the hopper above or coming from a 'side' hopper into the
  12. node next door.
  13. 'node_name" is the name of the container itself (e.g. "default:chest")
  14. 'inventory_name' is the name of the container inventory that is affected.
  15. e.g.
  16. hopper:add_container({
  17. {"top", "default:furnace", "dst"}, -- take cooked items from above into hopper below
  18. {"bottom", "default:furnace", "src"}, -- insert items below to be cooked from hopper above
  19. {"side", "default:furnace", "fuel"}, -- replenish furnace fuel from hopper at side
  20. })
  21. You can also register hopper interaction targets by group, or by a group and a specific group
  22. value. For example:
  23. hopper:add_container({
  24. {"top", "group:loot_chest", "loot"},
  25. {"bottom", "group:loot_chest", "loot"},
  26. {"side", "group:loot_chest", "loot"},
  27. })
  28. Would cause hoppers to interact with the "loot" inventory of all nodes belonging to the group
  29. "loot_chest", and
  30. hopper:add_container({
  31. {"top", "group:protected_container=1", "main"},
  32. {"bottom", "group:protected_container=1", "main"},
  33. {"side", "group:protected_container=1", "main"},
  34. })
  35. Would cause hoppers to interact with the "main" inventory of nodes belonging to the group
  36. "protected_container" provided they had a value of 1 in that group. Hoppers prioritize the most
  37. specific definition first; they check for registrations for a specific node name, then
  38. for registrations that apply to a node's group and group value, and then for registrations
  39. applying to a node's group in general.
  40. Note that if multiple group registrations apply to the same node it's undefined which group
  41. will take priority. Using the above examples, if there were a node that belonged to *both*
  42. the groups "loot_chest" and "protected_container=1" there's no way of knowing ahead of time
  43. whether hoppers would interact with the "loot" or "main" inventories. Try to avoid this situation.
  44. The hopper mod already have support for the wine barrel inside of the Wine mod and protected
  45. chests inside of Protector Redo, as well as default chests, furnaces and hoppers
  46. themselves.