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