Page 1 of 1

Help for function in new version Minetest

PostPosted: Tue Jun 05, 2012 18:45
by Jat
With the new version minetest I have a bug with this code

minetest.register_on_punchnode(function(p, node, player)
if node.name=="default:dirt" then
local a=0
for a = 1,player:get_inventory():get_size('main') do
if not(player:get_inventory():get_list('main')[a]=="") then
local element=player:get_inventory():get_list("main")[a]:split(" ")
print(element[1])
print(element[2])
end
end
end
end)

Precisely here
local element=player:get_inventory():get_list("main")[a]:split(" ")

The code is used just to navigate in the inventory.
And retrieve the names of items and their numbers.
But player:get_inventory():get_list("main")[a] have nothing returns.

Thank for help.

Sorry for bad english.

PostPosted: Wed Jun 06, 2012 12:45
by Jat
Must be used get_meta for player ?????

PostPosted: Wed Jun 06, 2012 12:55
by darkrose
you want to use get_stack not get_list
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 type=player:get_inventory():get_stack("main",a):get_name()
local count = player:get_inventory():get_stack("main",a):get_count()

PostPosted: Wed Jun 06, 2012 13:55
by Jat
Thx darkrose .
I am an idiot. :)