From 6ff38aba1ec2d067d666a187090be397cd044735 Mon Sep 17 00:00:00 2001 From: Neoblacks Date: Sat, 2 Aug 2025 19:23:09 +0200 Subject: [PATCH] Fix getStorage energy --- getStorageEnergy.lua | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/getStorageEnergy.lua b/getStorageEnergy.lua index 4f6df7b..fb19a66 100644 --- a/getStorageEnergy.lua +++ b/getStorageEnergy.lua @@ -1,10 +1,28 @@ -local storageEnergy = left.getStoredEnergy() +print("Enter the direction of the peripheral (left, right, top, bottom, front, back):") +local direction = io.read() +if not direction or direction == "quit" or direction == "exit" then + print("No direction specified, exiting.") + return +end +local info = {} -local modem = peripheral.find("modem") -modem.open(1) +info = peripheral.getMethods(direction) +if not info then + print("No peripheral found in that direction.") + return +end -modem.transmit(1, 2, { - type= "display", - text = ("Storage energy : %s"):format(storageEnergy), - color = colors.green -}) +-- list the methods from info + +local nbOfMethods = 0 +for methodName, methodInfo in pairs(info) do + nbOfMethods = nbOfMethods + 1 + if nbOfMethods > 10 then + print("Too many methods, please press a key to continue...") + event, p1 = os.pullEvent("key") + nbOfMethods = 0 + term.clear() + term.setCursorPos(1, 1) + end + print(methodName .. ' ' .. methodInfo) +end