mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2025-01-10 00:59:35 +01:00
Replace linear cart fill with mcl_loot.fill_inventory() using a fake inventory, remove debug print
This commit is contained in:
parent
bf3b98021f
commit
e28b55c16a
1 changed files with 18 additions and 8 deletions
|
@ -88,15 +88,25 @@ function tsm_railcorridors.create_cart_staticdata(entity_id, pos, pr)
|
||||||
if cartdata and has_loot[entity_id] then
|
if cartdata and has_loot[entity_id] then
|
||||||
local items = tsm_railcorridors.get_treasures(pr)
|
local items = tsm_railcorridors.get_treasures(pr)
|
||||||
|
|
||||||
-- TODO: determine if we should convert to use mcl_loot
|
local size = core.registered_entities[entity_id]._inv_size
|
||||||
-- mcl_loot.fill_inventory(inv, "main", items, pr_carts)
|
local inventory = {}
|
||||||
-- Convert from ItemStack to itemstrings
|
for i = 1,size do inventory[i] = "" end
|
||||||
for k,item in pairs(items) do
|
cartdata.inventory = inventory
|
||||||
items[k] = item:to_string()
|
|
||||||
end
|
-- Fill a fake inventory using mcl_loot
|
||||||
cartdata.inventory = items
|
local fake_inv = {
|
||||||
|
get_size = function(self)
|
||||||
|
return size
|
||||||
|
end,
|
||||||
|
get_stack = function(self, _, i)
|
||||||
|
return ItemStack(inventory[i])
|
||||||
|
end,
|
||||||
|
set_stack = function(self, _, i, stack)
|
||||||
|
inventory[i] = stack:to_string()
|
||||||
|
end,
|
||||||
|
}
|
||||||
|
mcl_loot.fill_inventory(fake_inv, "main", items, pr_carts)
|
||||||
|
|
||||||
print("cartdata = "..dump(cartdata))
|
|
||||||
save_cart_data(uuid)
|
save_cart_data(uuid)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue