From 085594ac04ef5242aada8a3208b7c57a2a7f5f35 Mon Sep 17 00:00:00 2001 From: PatR Date: Fri, 21 Jul 2023 23:09:39 -0700 Subject: [PATCH] more PR #1051, take II I realized that the previous attempt was misusing the item's locked state when attempting to create the chest that the item would go into, which was absurd. I hadn't realized that I was also misspelling "olocked" as "locked". This fix was already in progress before the mail about the previous commit. I did try switching to 'lckd = nil' for the attempt to retain the chest's random locked/unlocked state but that resulted in all the chests being created locked. Using separate box=... expressions does work as intended. Doing something with totable() doesn't seem to be necessary. The indentation seems to be messed up compared to the rest of the file (initial indent of 5 with increments of 4 rather than 3 and 3); I have't done anything to try to fix it. --- dat/themerms.lua | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/dat/themerms.lua b/dat/themerms.lua index 78d90eb42..f45acae26 100644 --- a/dat/themerms.lua +++ b/dat/themerms.lua @@ -645,14 +645,15 @@ xx|.....|xx }; local itm = obj.new(escape_items[math.random(#escape_items)]); local itmcls = itm:class() - local lckd; + local box if itmcls[ "material" ] == 19 then -- GLASS==19 - lckd = false; -- for glass item, force box to be unlocked + -- item is made of glass so explicitly force chest to be unlocked + box = des.object({ id = "chest", coord = chest_spots[1], + olocked = "no" }); else - lckd = itm.locked; -- else keep random lock state from box's creation + -- item isn't made of glass; accept random locked/unlocked state + box = des.object({ id = "chest", coord = chest_spots[1] }); end; - local box = des.object({ id = "chest", coord = chest_spots[1], - locked = lckd }); box:addcontent(itm); for i = 2, #chest_spots do