cleaner loader

This commit is contained in:
Nigel Garnett 2020-02-24 12:17:18 +00:00
parent ee3924e713
commit 7eff40a34f
2 changed files with 15 additions and 6 deletions

View File

@ -102,6 +102,7 @@ minetest.register_on_player_receive_fields(function(player, bot_key, fields)
local inv_involved = {} local inv_involved = {}
if inv_list then if inv_list then
for _,v in pairs(inv_list) do for _,v in pairs(inv_list) do
--print(dump(v))
local parts = string.split(v," ") local parts = string.split(v," ")
if #parts == 3 then if #parts == 3 then
inv_involved[parts[1]]=true inv_involved[parts[1]]=true
@ -115,11 +116,19 @@ minetest.register_on_player_receive_fields(function(player, bot_key, fields)
inv:set_stack(i,a, "") inv:set_stack(i,a, "")
end end
end end
local i={}
for _,v in pairs(inv_list) do for _,v in pairs(inv_list) do
local parts = string.split(v," ") local parts = string.split(v," ")
if #parts == 3 then if not i[parts[1]] then
inv:add_item(parts[1],parts[2].." "..parts[3]) i[parts[1]]=1
else
i[parts[1]]=i[parts[1]]+1
end end
local stack=""
if #parts == 3 then
stack = parts[2].." "..parts[3]
end
inv:set_stack(parts[1], i[parts[1]], stack)
end end
end end
end end

View File

@ -134,10 +134,10 @@ vbots.save = function(pos)
for i,t in pairs(meta_table.inventory) do for i,t in pairs(meta_table.inventory) do
if i ~= "main" then if i ~= "main" then
for _,s in pairs(t) do for _,s in pairs(t) do
local itemname = s:get_name() --local itemname = s:get_name()
if s and s:get_count()>0 and itemname:sub(1,5)=="vbots" then --if s and s:get_count()>0 and itemname:sub(1,5)=="vbots" then
inv_list[#inv_list+1] = i.." "..s:get_name().." "..s:get_count() inv_list[#inv_list+1] = i.." "..s:get_name().." "..s:get_count()
end --end
end end
end end
end end