Update backpacks with kingdoms_game version
This commit is contained in:
parent
a7a9fa04fd
commit
88c3caedac
23
init.lua
23
init.lua
@ -99,6 +99,8 @@ end
|
||||
minetest.after(CLEANUP_PERIOD__S, cleanInventory)
|
||||
|
||||
dropbackpack = function(player)
|
||||
local player = player
|
||||
minetest.after(.1, function(player)
|
||||
local name = player:get_player_name()
|
||||
if player_backpack[name] then
|
||||
local pos = player:getpos()
|
||||
@ -107,9 +109,11 @@ dropbackpack = function(player)
|
||||
pos.y = pos.y + 0.4
|
||||
pack.owner = nil
|
||||
obj:set_detach()
|
||||
obj:setpos(pos)
|
||||
local addnewentity = rezEntity(nil, pos, player, pack.contents)
|
||||
if addnewentity then obj:remove() end
|
||||
player_backpack[name] = nil
|
||||
end
|
||||
end, player)
|
||||
end
|
||||
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
@ -280,11 +284,11 @@ minetest.register_entity(
|
||||
loop = false
|
||||
})
|
||||
end,
|
||||
on_step = function(self, dt)
|
||||
--[[on_step = function(self, dt)
|
||||
if self.owner then
|
||||
self.object:setpos(self.owner:getpos())
|
||||
end
|
||||
end
|
||||
end--]]
|
||||
--[[on_step = function(self, dt)
|
||||
self.timer = self.timer - dt
|
||||
if self.timer > 0.0 then return end
|
||||
@ -380,7 +384,7 @@ minetest.register_entity(
|
||||
end--]]
|
||||
})
|
||||
|
||||
local function rezEntity(stack, pos, player)
|
||||
function rezEntity(stack, pos, player, contents)
|
||||
local x = pos.x
|
||||
local y = math.floor(pos.y)
|
||||
local z = pos.z
|
||||
@ -396,14 +400,15 @@ local function rezEntity(stack, pos, player)
|
||||
|
||||
local obj = minetest.env:add_entity(pos, "backpack:bag_entity")
|
||||
if not obj then return stack end
|
||||
|
||||
if stack then
|
||||
local contentData = stack:get_metadata()
|
||||
local contents = deserializeContents(contentData)
|
||||
contents = deserializeContents(contentData)
|
||||
obj:set_hp(BAG_MAX_HP - BAG_MAX_HP * stack:get_wear() / 2^16)
|
||||
end
|
||||
if contents then
|
||||
obj:get_luaentity().contents = contents
|
||||
end
|
||||
|
||||
obj:set_hp(BAG_MAX_HP - BAG_MAX_HP * stack:get_wear() / 2^16)
|
||||
obj:set_hp(4)
|
||||
|
||||
minetest.sound_play(
|
||||
DROP_BAG_SOUND,
|
||||
@ -421,7 +426,7 @@ end
|
||||
minetest.register_tool(
|
||||
"backpack:backpack",
|
||||
{
|
||||
description = "Backpack",
|
||||
description = "Backpack (WORK IN PROGRESS, USE AT YOUR OWN RISK)",
|
||||
groups = { bag = BAG_WIDTH*BAG_HEIGHT, flammable = 1 },
|
||||
inventory_image = "inventory_plus_backpack.png",
|
||||
wield_image = "inventory_plus_backpack.png",
|
||||
|
Loading…
x
Reference in New Issue
Block a user