From 9289a1ae9d55bbc76cfa99316cac3821db86faa4 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 21 Dec 2022 10:06:11 -0800 Subject: [PATCH] set infotext after swapping node --- init.lua | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/init.lua b/init.lua index cf9807d..4de9183 100644 --- a/init.lua +++ b/init.lua @@ -362,17 +362,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 = {}; @@ -387,6 +376,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");