forked from mtcontrib/maidroid
Fix wield item in get_staticdata and on_activate
This commit is contained in:
parent
7c32c4fb34
commit
0d66568a21
@ -445,6 +445,7 @@ function maidroid.register_maidroid(product_name, def)
|
||||
local inventory = create_inventory(self)
|
||||
local core_name = data["inventory"]["core"]
|
||||
local items = data["inventory"]["main"]
|
||||
local wield_item = data["inventory"]["wield_item"]
|
||||
|
||||
if core_name ~= "" then -- set a core
|
||||
core_stack = ItemStack(core_name)
|
||||
@ -458,6 +459,13 @@ function maidroid.register_maidroid(product_name, def)
|
||||
item_stack:set_count(item["count"])
|
||||
inventory:add_item("main", item_stack)
|
||||
end
|
||||
|
||||
if wield_item["name"] ~= "" then
|
||||
local item_stack = ItemStack(wield_item["name"])
|
||||
item_stack:set_count(wield_item["count"])
|
||||
inventory:add_item("wield_item", item_stack)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
update_infotext(self)
|
||||
@ -485,9 +493,11 @@ function maidroid.register_maidroid(product_name, def)
|
||||
["inventory"] = {
|
||||
["main"] = {},
|
||||
["core"] = self.core_name,
|
||||
["wield_item"] = nil,
|
||||
},
|
||||
}
|
||||
|
||||
-- set main list.
|
||||
for _, item in ipairs(inventory:get_list("main")) do
|
||||
local count = item:get_count()
|
||||
local itemname = item:get_name()
|
||||
@ -496,6 +506,14 @@ function maidroid.register_maidroid(product_name, def)
|
||||
table.insert(data["inventory"]["main"], itemdata)
|
||||
end
|
||||
end
|
||||
|
||||
do -- set wield_item list.
|
||||
local item = self:get_wield_item_stack()
|
||||
local count = item:get_count()
|
||||
local itemname = item:get_name()
|
||||
local itemdata = {count = count, name = itemname}
|
||||
data["inventory"]["wield_item"] = itemdata
|
||||
end
|
||||
return minetest.serialize(data)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user