RealBadAngel wrote:Propably you need something like this:
Thank you for the link, that is an excellent example of the problem. Notice the code:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
local hotbar = inv:get_list("main")
for i = 1, 8 do
It's hard coded to check the first 8 inventory slots to see if the flashlight is in them. This is similar to how I am currently doing it. And it will work just fine with the default minetest gui. But, as 4aiman pointed out to me back when I was working on the explorertools mod, what if someone is using a mod that changes the inventory width? What if the server is running a mod that makes the inventory larger and the "hotbar" is now 9 across?
Thats why it would be handy to have a function that would tell me the width of the inventory so that I could determine within the program how wide the hotbar actually was instead of hardcoding it to 8.