Merge pull request #4 from fluxionary/infotext_tweak

set infotext after swapping node
This commit is contained in:
Sokomine 2023-01-22 22:36:10 +01:00 committed by GitHub
commit 543144c693
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 11 deletions

View File

@ -388,17 +388,6 @@ chesttools.update_chest = function(pos, formname, fields, player)
player_inv:add_item( 'main', old_price_item..' '..tostring(old_price_amount));
end
-- set the owner field
meta:set_string( 'owner', pname );
if( fields.locked ) then
meta:set_string("infotext", "Locked Chest (owned by "..meta:get_string("owner")..")")
elseif( fields.shared ) then
meta:set_string("infotext", "Shared Chest (owned by "..meta:get_string("owner")..")")
else
meta:set_string("infotext", "Chest")
end
-- copy the old inventory
local inv = meta:get_inventory();
local main_inv = {};
@ -413,6 +402,14 @@ chesttools.update_chest = function(pos, formname, fields, player)
-- make sure the player owns the new chest
meta:set_string("owner", pname);
if( fields.locked ) then
meta:set_string("infotext", "Locked Chest (owned by "..pname..")")
elseif( fields.shared ) then
meta:set_string("infotext", "Shared Chest (owned by "..pname..")")
else
meta:set_string("infotext", "Chest")
end
-- put the inventory back
local new_inv = meta:get_inventory();
local new_inv_size = inv:get_size("main");