mirror of
https://github.com/minetest-mods/craftguide.git
synced 2024-11-26 04:23:44 +01:00
Store inventory in player data
This commit is contained in:
parent
671fae8926
commit
61af916fa1
13
init.lua
13
init.lua
@ -839,9 +839,9 @@ local function groups_to_items(groups, get_all)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function get_stack_max(data, is_recipe, rcp)
|
local function get_stack_max(data, is_recipe, rcp)
|
||||||
local inv = data.player:get_inventory()
|
data.inv = data.player:get_inventory()
|
||||||
local list = inv:get_list("main")
|
local list = data.inv:get_list("main")
|
||||||
local size = inv:get_size("main")
|
local size = data.inv:get_size("main")
|
||||||
local counts_inv, counts_rcp, counts = {}, {}, {}
|
local counts_inv, counts_rcp, counts = {}, {}, {}
|
||||||
local rcp_usg = is_recipe and "recipe" or "usage"
|
local rcp_usg = is_recipe and "recipe" or "usage"
|
||||||
|
|
||||||
@ -892,7 +892,6 @@ local function get_stack_max(data, is_recipe, rcp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function craft_stack(player, pname, data, craft_rcp)
|
local function craft_stack(player, pname, data, craft_rcp)
|
||||||
local inv = player:get_inventory()
|
|
||||||
local rcp_usg = craft_rcp and "recipe" or "usage"
|
local rcp_usg = craft_rcp and "recipe" or "usage"
|
||||||
local output = craft_rcp and data.recipes[data.rnum].output or data.usages[data.unum].output
|
local output = craft_rcp and data.recipes[data.rnum].output or data.usages[data.unum].output
|
||||||
output = ItemStack(output)
|
output = ItemStack(output)
|
||||||
@ -922,7 +921,7 @@ local function craft_stack(player, pname, data, craft_rcp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(items) do
|
for k, v in pairs(items) do
|
||||||
inv:remove_item("main", sprintf("%s %s", k, v * scrbar_val))
|
data.inv:remove_item("main", sprintf("%s %s", k, v * scrbar_val))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -937,8 +936,8 @@ local function craft_stack(player, pname, data, craft_rcp)
|
|||||||
message = clr("#ff0", sprintf("%s", desc))
|
message = clr("#ff0", sprintf("%s", desc))
|
||||||
end
|
end
|
||||||
|
|
||||||
if inv:room_for_item("main", stack) then
|
if data.inv:room_for_item("main", stack) then
|
||||||
inv:add_item("main", stack)
|
data.inv:add_item("main", stack)
|
||||||
msg(pname, sprintf("%s added in your inventory", message))
|
msg(pname, sprintf("%s added in your inventory", message))
|
||||||
else
|
else
|
||||||
local dir = player:get_look_dir()
|
local dir = player:get_look_dir()
|
||||||
|
Loading…
Reference in New Issue
Block a user