From f41ebbe4a20fbb57a931e3fcdb0755119cc306b4 Mon Sep 17 00:00:00 2001 From: StormFusions <62036454+StormFusions@users.noreply.github.com> Date: Sat, 15 May 2021 19:51:51 +0100 Subject: [PATCH] Add files via upload --- reactor.lua | 40 ++++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/reactor.lua b/reactor.lua index 6ceaab2..242937d 100644 --- a/reactor.lua +++ b/reactor.lua @@ -2,9 +2,6 @@ os.loadAPI("lib/f") os.loadAPI("lib/button") -local reactorSide = "back" -local fluxgateSide = "left" - local targetStrength = 50 local maxTemp = 8000 local safeTemp = 3000 @@ -12,11 +9,42 @@ local lowFieldPer = 15 local activateOnCharge = true -local version = 0.1 +local version = 0.2 local autoInputGate = 1 local curInputGate = 222000 +local sides = { + "left", + "right", + "back", + "front", + "bottom", +} + +function Identify(name, data) + if name == data then + return true + else + return false + end +end + +function getPeripheral(id) + local names = peripheral.getNames() + for k, v in pairs(names) do + local Type = peripheral.getType(v) + local isType = Identify(id, Type) + if isType then + for _, t in pairs(sides) do + if v == t then + return peripheral.wrap(t) + end + end + end + end +end + local mon, monitor, monX, monY local reactor @@ -32,8 +60,8 @@ local emergencyTemp = false monitor = f.periphSearch("monitor") inputFluxgate = f.periphSearch("flux_gate") -fluxgate = peripheral.wrap(fluxgateSide) -reactor = peripheral.wrap(reactorSide) +fluxgate = getPeripheral("flux_gate") +reactor = getPeripheral("draconic_reactor") if monitor == null then error("No valid monitor was found")