Help for function in new version Minetest

Jat
Member
 
Posts: 219
Joined: Fri Nov 11, 2011 16:15

Help for function in new version Minetest

by Jat » Tue Jun 05, 2012 18:45

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.
Last edited by Jat on Tue Jun 05, 2012 18:46, edited 1 time in total.
 

Jat
Member
 
Posts: 219
Joined: Fri Nov 11, 2011 16:15

by Jat » Wed Jun 06, 2012 12:45

Must be used get_meta for player ?????
 

User avatar
darkrose
Member
 
Posts: 91
Joined: Mon Jun 04, 2012 04:25

by darkrose » Wed Jun 06, 2012 12:55

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()
Last edited by darkrose on Wed Jun 06, 2012 12:57, edited 1 time in total.
Take a look at Minetest Classic, and it's updated Development Tree, also check out my server.
 

Jat
Member
 
Posts: 219
Joined: Fri Nov 11, 2011 16:15

by Jat » Wed Jun 06, 2012 13:55

Thx darkrose .
I am an idiot. :)
 


Return to WIP Mods

Who is online

Users browsing this forum: No registered users and 22 guests

cron