Accessing other players' inventories

Post Reply
zeuner
Member
Posts: 55
Joined: Fri Dec 01, 2017 20:09
GitHub: zeuner

Accessing other players' inventories

by zeuner » Post

I noticed that when using the list[] element in a formspec, it will show lists from the current player's inventory, or detached inventories, but I don't seem to able to show another player's inventory using the player:<playername> syntax. It just doesn't show up, but there is also no error message.

Is this behaviour documented somewhere? I suppose that the player:<playername> will work under certain circumstances since it wouldn't be mentioned in doc/lua_api.txt. I would like to implement some UI-based interactions involving different players' inventories, so I need to better understand what is possible.

User avatar
ChimneySwift
Member
Posts: 320
Joined: Fri Sep 22, 2017 06:46
GitHub: ChimneySwift
IRC: ChimneySwift
In-game: ChimneySwift
Location: 127.0.0.1

Re: Accessing other players' inventories

by ChimneySwift » Post

I had this error when trying to do this a bit ago.

It doesn't show up because the player is only sent their inventory, so it doesn't know what to show.

The only option would be to make some implementation, such as a grid of images and simply display that, or to clone the player inventory into a detached inventory. You could possibly even use detached inventory callbacks and global step (or 5.0-dev) to try keep the 2 synced.
A spoon is basically a tiny bowl with a stick on it

User avatar
Krock
Developer
Posts: 4650
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Accessing other players' inventories

by Krock » Post

Similar forum post: viewtopic.php?f=47&t=20733
Reported issue with suggestions to work around this: https://github.com/minetest/minetest/issues/4859
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

zeuner
Member
Posts: 55
Joined: Fri Dec 01, 2017 20:09
GitHub: zeuner

Re: Accessing other players' inventories

by zeuner » Post

ChimneySwift wrote:I had this error when trying to do this a bit ago.

It doesn't show up because the player is only sent their inventory, so it doesn't know what to show.

The only option would be to make some implementation, such as a grid of images and simply display that, or to clone the player inventory into a detached inventory. You could possibly even use detached inventory callbacks and global step (or 5.0-dev) to try keep the 2 synced.
Thanks for the information. It seems as if detached inventories will work for me.

Still, the described behaviour seems to be undocumented, which makes the platform harder to understand for new modders. Therefore, I would suggest to make it more clear: https://github.com/minetest/minetest/pull/7720

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests