Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hacknique/item_tracking
Provides a API to mod developers to track which inventories items are in.
https://github.com/hacknique/item_tracking
api library minetest minetest-mod
Last synced: 14 days ago
JSON representation
Provides a API to mod developers to track which inventories items are in.
- Host: GitHub
- URL: https://github.com/hacknique/item_tracking
- Owner: Hacknique
- License: agpl-3.0
- Created: 2023-10-14T08:26:14.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-10-15T06:25:02.000Z (about 1 year ago)
- Last Synced: 2024-10-17T02:38:18.466Z (29 days ago)
- Topics: api, library, minetest, minetest-mod
- Language: Lua
- Homepage:
- Size: 180 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Description
A Minetest mod that provides a API to mod developers to track which inventories
items are in.# API
## Track Items Attached Inventory
You can track the inventories the items are in. To say for example, check if the
item still exists in a inventory.```lua
item_tracking.track_attached_inventory({
name = "modular_computers:motherboard_tier_1",
meta = {id = "ze0ei1beb0Xsz4VuUB4nLPS1BME"} -- meta is optional
}, function(name) minetest.log("action", "Attached to " .. name) end)
```## Track Item
You Can track a given item across node,detached and player inventories, when
someone puts something in a inventory, or moves the item within the inventory.```lua
local node_callbacks = {
on_put = function(pos, listname, index, stack, player)
minetest.log("action", "Item put in node inventory")
end,
on_move = function(pos, from_list, from_index, to_list, to_index, count,
player) act("Item moved in node inventory") end
}local detached_callbacks = {
on_put = function(inventories, listname, index, stack, player)
minetest.log("action", "Item put in detached inventory")
end,
on_move = function(inv, from_list, from_index, to_list, to_index, count,
player) act("Item moved in detached inventory") end
}local player_callbacks = {
on_put = function(itemstack, player, inventory, index)
minetest.log("action", "Item put in players inventory")
end,
on_move = function(inventory, from_list, from_index, to_list, to_index,
count, player)
minetest.log("action", "Item is moved in player's inventory")
end
}item_tracking.register_tracker({
name = "modular_computers:motherboard_tier_1",
meta = {id = "some_unique_id"} -- optional
}, node_callbacks, detached_callbacks, player_callbacks)
```# License
- [Code License](LICENSE)