-
Notifications
You must be signed in to change notification settings - Fork 14
Ability to access inventory #33
Comments
The 'inventory' plugin has event listeners that listen to events that occur when windows are opened or closed, and that triggers some callback function. However, the window that shows inventory and hot bar won't open every time the bot picks up something and it gets added to the inventory. Hence, I can't really find an event for simple inventory update in spockbot, that I can get spockControlPlugin to listen to. Help on this? |
Technically, the inventory (including hotbar and armor etc.) is always open. For what you are doing, you might want to look at the Picking up items works like this: the bot is near an item, then the server decides that the bot picks it up, kills the item entity and sends a set_slot to the bot. SpockBot handles this, updates the internal inventory state correctly, and emits |
So basically, I'm going to listen for the 'set_slot' event in the SpockControl.py plugin and convert the incoming data (which will have a window_id, slot_nr and slot_data) into a msg. I'll then publish this msg on to a topic and the node that subscribes to this topic can update the incoming inventory to atomspace. |
Oh, also I'm going to check if the window_id of the incoming data is INV_WINID_PLAYER (the inventory plugin sets this to -1, representing player's inventory window), then I'll be sure that something has been picked up and that's why the event set_slot has occured. Does that cover cases? |
You can pick up items when any window is open, so checking INV_WINID_PLAYER is unnecessary and wrong. It also looks like this project is using an old and incomplete inventory plugin (https://github.com/opencog/opencog-to-minecraft/blob/master/spockextras/inventory.py), please use the official one, it's python2 compatible now. |
Thanks! Also, could you briefly explain INV_SLOT_NR_CURSOR and INV_WINID_CURSOR? |
When you click a slot to pick it up, it follows your mouse as you move it around. that is modeled as a separate slot, the "cursor slot" Btw, thanks for helping me to find out what we need docs for 😉 |
Thanks! In the messenger plugin's, setMessage() function:
If the data[key] is a list or dict, it just sets the corresponding msg value to an empty list or dict. However, the .msg file I am looking to create, does have a list in it. How can this be handled? |
Issue by fredyvilla
Wednesday Jan 13, 2016 at 04:47 GMT
Originally opened as fredyvilla#6
Give the bot the ability to store its inventory in the atomspace. Use spock to receive an event when a new inventory item is added.
The text was updated successfully, but these errors were encountered: