get Energy

This commit is contained in:
2025-08-02 19:52:52 +02:00
parent 72930c4452
commit 088c5f47a8

View File

@ -7,13 +7,14 @@ local function getPeripheralType(direction)
return peripheralType
end
local function findPeripheral(typeOfPeripheral)
local peripheral = peripheral.find(typeOfPeripheral)
if not peripheral then
print("No peripheral found in that direction.")
local function findPeripheralInfo(typeOfPeripheral)
local findingPeripheralInfo = peripheral.find(typeOfPeripheral)
if not findingPeripheralInfo then
print("No peripheral found of type: " .. typeOfPeripheral)
return nil
end
return peripheral
print("Found peripheral of type: " .. typeOfPeripheral)
return findingPeripheralInfo
end
local function uraniniteReactorStorageEnergy(peripheral)
@ -33,6 +34,9 @@ local function checkDirectionIsValid(direction)
return true
end
PeripheralInfo = {}
local function main()
print("Enter the direction of the peripheral (left, right, top, bottom, front, back):")
local direction = io.read()
if not checkDirectionIsValid(direction) then
@ -41,19 +45,24 @@ end
local typeOfPeripheral = getPeripheralType(direction)
if not typeOfPeripheral then
print("No peripheral found in that direction.")
return
end
local peripheral = findPeripheral(typeOfPeripheral)
if not peripheral then
print("No peripheral found of type: " .. typeOfPeripheral)
return
end
if peripheral == "uraninite_reactor" then
local energy = uraniniteReactorStorageEnergy(peripheral)
print("Stored energy in uranium reactor: " .. energy)
if typeOfPeripheral == "uraninite_reactor" then
-- alors on est dans le cas d'un reacteur de Powah
PeripheralInfo = findPeripheralInfo(typeOfPeripheral)
if PeripheralInfo then
local storedEnergy = uraniniteReactorStorageEnergy(PeripheralInfo)
if storedEnergy then
print("Stored energy in the reactor: " .. storedEnergy .. " RF")
else
print("Peripheral type is not a uranium reactor, cannot get stored energy.")
print("Could not retrieve stored energy from the reactor.")
end
else
print("No uraninite reactor found in that direction.")
end
return
end
end
main()