From 742f8eb81d5d52d6764a01e706ff44a0829ca610 Mon Sep 17 00:00:00 2001 From: Gabriel Tofvesson Date: Thu, 15 May 2025 18:03:59 +0200 Subject: [PATCH] Wrap peripheral if string is given instead of table --- localchest.lua | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/localchest.lua b/localchest.lua index bde5cf0..b7d4a4d 100644 --- a/localchest.lua +++ b/localchest.lua @@ -108,15 +108,19 @@ local metatable = { } function localchest.fromPeripheral(per) - local chest = { - peripheral = per, - slots = {}, - size = 0 - } + if type(per) == "string" then + per = peripheral.wrap(per) + end - setmetatable(chest, metatable) + local chest = { + peripheral = per, + slots = {}, + size = 0 + } - return chest + setmetatable(chest, metatable) + + return chest end function localchest.fromString(str)