Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!

My E2 Ship computer

StarkkzStarkkz Posts: 17Registered
edited January 2014 in Showcase #1
Hello there, just came here to publish my ship computer. Forgive me if I've put this in the wrong section, I just joined today.

Featuring
- Target finder
- Resource manager
- Auto updater (This one attempts to find any E2 newer than itself)
- EGP (Console, resources and core)
- Ship classifier (I took this from the forum)
- Water finder for water pump
- Ship environment activator
@name Ship Computer by Starkkz

#Updater
persist NewVersion:number NewCode:string
outputs Version:number

#EGP
inputs EGP:wirelink ResourceEGP:wirelink CoreEGP:wirelink

#Cached globals
persist Cache:table Owner:entity

#Target finder
inputs PrevTarget NextTarget Seats:array Core:entity
persist TargetI TargetRequest:entity
outputs Target:entity TargetName:string

#Core
persist Armor Hull Shield Cap MaxArmor MaxHull MaxShield MaxCap

#Water Finder
persist FindPosition:vector FindSize:vector WaterPosition:vector WaterFound
persist LastPosition:array LastAngle:array

#Life Support
persist ResourceNode:entity
persist LifeSupportWL:array LifeSupportMult:array LifeSupportMute:array
persist MultMax LSEntities:array LSEntIndex StorageWL:wirelink
persist Energy Oxygen Hydrogen Steam Water HvyWater
persist MaxEnergy MaxOxygen MaxHydrogen MaxSteam MaxWater MaxHvyWater
persist StorageCache:entity SteamTurbines:array WaterElectrolyzers:array WaterSplitters:array FusionReactors:array SolarPanels:array WaterPumps:array Regulators:array
outputs ActivateRegulator LifeSupportOn
if (duped()){reset()}

if (first()|dupefinished()){
    stopAllTimers()
    
    #Updater version
    Version = 0.81
    setName("Ship Computer by Starkkz\nv"+Version)
    
    #Life Support
    MultMax = 20
    timer("RegulatorUpdate", 100)
    
    #EGP Timers
    timer("CoreEGP", 500)
    timer("LSEGP", 1000)
    timer("UpdateLS", 1500)
    timer("MainEGP", 2000)
    
    #Water Pump finder
    rangerIgnoreWorld(1)
    rangerHitEntities(0)
    rangerHitWater(1)
    rangerPersist(1)
    
    #Console
    runOnChat(1)
    dsSetScope(2)
    dsJoinGroup("console")
    dsJoinGroup("LS")
    Owner = owner()
    
    function string shortHandNumber(FNumber){
        if (FNumber < 1000){
            return toString(FNumber)
        }else{
            if (FNumber < 1000000){
                return round(FNumber / 1000, 1) + "K"
            }elseif (FNumber < 1000000000){
                return round(FNumber / 1000000, 2) + " Mill"
            }else {
                return round(FNumber / 1000000000,2) + "Bill"
            }
        }
    }
    
    function string shortTime(T){
        T = round(T)
        local Hours = floor(T/3600)
        T = mod(T, 3600)
        local Mins = floor(T/60)
        T = mod(T, 60)
        local Time = ""
        if (Hours > 0){Time = " "+Hours+" Hours"}
        if (Mins > 0){Time = Time+" "+Mins+" Mins."}
        if (T > 0){Time = Time+" "+T+" Secs."}
        return Time
    }
    
    function entity lsEntity(){
        if (ResourceNode:isValid()){
            return ResourceNode
        }
        return entity()
    }
    
    function output(Text:string,R,G,B){
        local Output = table()
        local Vector = vec(R, G, B)
        Output["Text", string] = Text
        Output["Color", vector] = Vector
        
        if (Cache:count() > 23){
            for (I = 2, Cache:count()){
                Cache[I - 1, table] = Cache[I, table]
            }
            Cache[Cache:count(), table] = Output
        }else{
            Cache:pushTable(Output)
        }
        stoptimer("MainEGP")
        timer("MainEGP", 1)
    }
    
    function string getDataGroup(){
        local Groups = dsGetGroups()
        return Groups[1, string]
    }
    
    function processLine(Text:string,Player:entity){
        local Split = Text:explode(" ")
        local Command = Split[1, string]
        if (Command == "playercords"){
            local PlayerName = Split:concat(" ", 2)
            local Player = findPlayerByName(PlayerName)
            if (Player:isValid()){
                output("Found player '"+Player:name()+"' at coordinates "+round(Player:pos()), 0, 255, 0)
            }else{
                output("Couldn't find player '"+PlayerName+"'", 255, 0, 0)
            }
        }elseif (Command == "ls"){
            if (Owner:trusts(Player)){
                local Mode = Split[2, string]
                if (Mode == "on"){
                    if (!LifeSupportOn){
                        if (ResourceNode:isValid()){
                            LifeSupportOn = 1
                            output("Activated life support", 0, 255, 0)
                            
                            FindPosition = ResourceNode:pos()
                            FindSize = vec(2048, 2048, 2048)
                            WaterPosition = vec()
                            WaterFound = 0
                            LastPosition = array()
                            LastAngle = array()
                            
                            stoptimer("FindInSquares")
                            stoptimer("UpdateLS")
                            timer("FindInSquares", 100)
                            timer("UpdateLS", 100)
                        }else{
                            output("Error: Invalid resource node", 255, 0, 0)
                        }
                    }
                }elseif (Mode == "off"){
                    if (LifeSupportOn){
                        stoptimer("FindInSquares")
                        stoptimer("UpdateLS")
                        timer("UpdateLS", 100)
                        LifeSupportOn = 0
                        output("Deactivated life support", 0, 255, 0)
                        
                        if (WaterFound){
                            for (I = 1, WaterPumps:count()){
                                local WaterPump = WaterPumps[I, entity]
                                if (WaterPump:isValid()){
                                    local ID = WaterPump:id()
                                    WaterPump:setPos(ResourceNode:toWorld(LastPosition[ID, vector]))
                                    WaterPump:setAng(ResourceNode:toWorld(LastAngle[ID, angle]))
                                }
                            }
                        }
                    }
                }
            }else{
                output("Error: You haven't got enough privileges for this command", 255, 0, 0)
            }
        }elseif (Command == "target"){
            if (Owner:trusts(Player)){
                local Name = Text:sub(8)
                if (Name:length() > 0){
                    local Ent = findPlayerByName(Name)
                    if (Ent:isValid()){
                        Target = Ent
                        TargetName = Ent:name()
                        output(TargetName+" is the new target", 0, 255, 0)
                    }else{
                        output("Error: Failed to find player with name "+Name, 255, 0, 0)
                    }
                }else{
                    output("Usage: target [name]", 255, 0, 0)
                }
            }else{
                output("Error: You haven't got enough privileges for this command", 255, 0, 0)
            }
        }elseif (Command == "classify"){
            local PlayerName = Text:sub(10)
            local PlayerEnt = findPlayerByName(PlayerName)
            if (PlayerEnt:isValid() & PlayerEnt:isPlayer()){
                findClearWhiteList()
                findClearBlackList()
                findIncludePlayerProps(PlayerEnt)
                findInSphere(PlayerEnt:pos(), 9999999999)
                findClipToClass("ship_core")
                local CoreProp = findResult(1)
      
                if (CoreProp:isValid()){
                    local CoreEnt = CoreProp:getCoreEnt()
                    if(CoreEnt){
                        local Shield = CoreEnt:getShieldMax()
                        local Armor = CoreEnt:getArmorMax()
                        local Hull = CoreEnt:getHullMax()
                        
                        T = Shield + Armor + Hull
                        
                        if(T<100000){Classification="Fighter / Bomber / Interceptor\n0 - 100k HP"}
                        elseif(T<150000){Classification="Heavy - Fighter / Bomber / Interceptor\n100 - 150k HP"}
                        elseif(T<175000){Classification="Corvette\n150 - 175k HP"}
                        elseif(T<250000){Classification="Frigate\n175 - 250k HP"}
                        elseif(T<275000){Classification="Heavy Frigate\n250 - 275k HP"}
                        elseif(T<400000){Classification="Destroyer\n275 - 400k HP"}
                        elseif(T<800000){Classification="Cruiser\n400 - 800k HP"}
                        elseif(T<1000000){Classification="Battle-Cruiser\n800k - 1 million HP"}
                        elseif(T<1400000){Classification="Battleship\n1 - 1.4 mill HP"}
                        elseif(T<2500000){Classification="Dreadnaught\n1.4 - 2.5 mill HP"}
                        elseif(T<6000000){Classification="Super Battleship\n2.5 - 6 mill HP"}
                        elseif(T<10000000){Classification="Class 1 Leviathon\n6 - 10 mill HP"}
                        elseif(T<14000000){Classification="Class 2 Leviathon\n10 - 14 mill HP"}
                        elseif(T<18000000){Classification="Class 3 Leviathon\n14 - 18 mill HP"}
                        elseif(T<26000000){Classification="Class 1 Titan\n18 - 26 mill HP"}
                        elseif(T<34000000){Classification="Class 2 Titan\n26 - 42 mill HP"}
                        elseif(T<50000000){Classification="Battle-Barge\n34 - 50 mill HP"}
                        elseif(T<60000000){Classification="Super Dreadnaught\n50 - 60 mill HP"}
                        elseif(T<75000000){Classification="Leviathon Destroyer\n60 - 75 mill HP"}
                        elseif(T<100000000){Classification="Mega Titan\n75 - 100 mill HP"}
                        elseif(T<125000000){Classification="Super Leviathon\n100 - 125 mill HP"}
                        elseif(T<150000000){Classification="Titan Destroyer\n 125 - 150 mill HP"}
                        elseif(T<250000000){Classification="Eversor Regalis\n150 - 250 mill HP"}
                        else{Classification="HOLY FUCKING JESUS"}
                        
                        output(CoreEnt:owner():name()+"'s Ship Classification", 0, 255, 0)
                        output(Classification + "("+shortHandNumber(T)+")", 0, 255, 0)
                    }else{
                        output("Error: Invalid core entity", 255, 0, 0)
                    }
                }else{
                    output("Error: Failed to find core", 255, 0, 0)
                }
            }else{
                output("Error: Failed to find player", 255, 0, 0)
            }
        }elseif (Text:sub(1, 10) == "core stats"){
            if (Core:getCoreEnt():isValid()){
                output("Hull: "+Hull+"/"+MaxHull+" ("+shortHandNumber(Hull/MaxHull*100)+"%)", 255, 0, 255)
                output("Shield: "+Shield+"/"+MaxShield+" ("+shortHandNumber(Shield/MaxShield*100)+"%)", 255, 0, 255)
                output("Armor: "+Armor+"/"+MaxArmor+" ("+shortHandNumber(Armor/MaxArmor*100)+"%)", 255, 0, 255)
                output("Cap: "+Cap+"/"+MaxCap+" ("+shortHandNumber(Cap/MaxCap*100)+"%)", 255, 0, 255)
            }else{
                output("Error: Core is not valid, spawn a core and rewire it", 255, 0, 0)
            }
        }elseif (Command == "dsjoin"){
            local Group = Split:concat(" ", 2)
            if (Group:length() > 0){
                dsClearGroups()
                dsJoinGroup(Group)
                dsJoinGroup("LS")
            } 
        }elseif (Command == "dsmsg"){
            local Message = Split:concat(" ", 2)
            if (Message:length() > 0){
                dsSend("dsmsg", getDataGroup(), 2, Message)
            }
        }elseif (Command == "dstarget"){
            local TargetName = Split:concat(" ", 2)
            if (TargetName:length() > 0){
                local TargetEnt = findPlayerByName(TargetName)
                if (TargetEnt:isValid()){
                    dsSend("dstarget", getDataGroup(), 2, TargetEnt)
                }else{
                    output("Error: Failed to find target "+TargetName, 255, 0, 0)
                }
            }
        }elseif (Text:sub(1, 6) == "accept"){
            if (Owner:trusts(Player)){
                if (TargetRequest){
                    Target = TargetRequest
                    TargetName = Target:name()
                    output(TargetName+" is the new target", 0, 255, 0)
                    dsSend("dstargetaccepted", getDataGroup(), 2, Target)
                }
            }else{
                output("Error: You haven't got enough privileges for this command", 255, 0, 0)
            }
        }elseif (Text:sub(1, 6) == "reject"){
            if (Owner:trusts(Player)){
                if (TargetRequest){
                    TargetRequest = noentity()
                    output("Rejected target "+TargetRequest:name(), 255, 0, 0)
                    dsSend("dstargetdenied", getDataGroup(), 2, TargetRequest)
                }
            }else{
                output("Error: You haven't got enough privileges for this command", 255, 0, 0)
            }
        }elseif (Text:sub(1, 4) == "help"){
            output("--- Starkkz Inc. Computer Help", 255, 0, 0)
            output("1. playercords [playername]", 0, 255, 0)
            output("2. ls [on/off]", 0, 255, 0)
            output("3. target [playername]", 0, 255, 0)
            output("4. classify [playername]", 0, 255, 0)
            output("5. core stats", 0, 255, 0)
            output("6. dsjoin [group]", 0, 255, 0)
            output("7. dsmsg [message]", 0, 255, 0)
            output("8. dstarget [name]", 0, 255, 0)
        }elseif (Text:length() > 0){
            output(Player:name()+"> "+Text, 0, 125, 255)
        }
    }
    
    function switchTargets(){
        #Find player targets
        findClearWhiteList()
        findClearBlackList()
        if (Seats:count() > 0){
            for (I = 1, Seats:count()){
                local Driver = Seats[I, entity]:driver()
                if (Driver:isValid()){
                    findExcludePlayer(Driver)
                }
            }
        }
        findByClass("player")
        local Players = findToArray()
        
        findClearWhiteList()
        findClearBlackList()
        if (Core:isValid()){
            findExcludeEntity(Core)
        }
        findByClass("ship_core")
        local Cores = findToArray()
        
        local Targets = Players:add(Cores)
        if (PrevTarget){TargetI--}
        if (NextTarget){TargetI++}
        
        if (TargetI < 1){TargetI = Targets:count()}
        if (TargetI > Targets:count()){TargetI = 1}
        Target = Targets[TargetI, entity]
        if (Target:getCoreEnt()){
            TargetName = Target:owner():name()+"'s Ship Core"
        }else{
            TargetName = Target:name()
        }
    }

    switchTargets()
    dsSend("ver", getDataGroup(), 2, Version)
}elseif (clk("FindInSquares")){
    local FindSizeOffset = FindSize/2
    local VecA = FindPosition + FindSizeOffset * vec(-1, -1, -1)
    local VecB = FindPosition + FindSizeOffset * vec(1, 1, 1)
    local VecC = FindPosition + FindSizeOffset * vec(1, -1, 1)
    local VecD = FindPosition + FindSizeOffset * vec(-1, 1, -1)
    local VecE = FindPosition + FindSizeOffset * vec(-1, -1, 1)
    local VecF = FindPosition + FindSizeOffset * vec(1, -1, -1)
    local VecG = FindPosition + FindSizeOffset * vec(1, 1, -1)
    local VecH = FindPosition + FindSizeOffset * vec(-1, 1, 1)
    local Rangers = array(
        rangerOffsetHull(VecA, VecA, FindSize),
        rangerOffsetHull(VecB, VecB, FindSize),
        rangerOffsetHull(VecC, VecC, FindSize),
        rangerOffsetHull(VecD, VecD, FindSize),
        rangerOffsetHull(VecE, VecE, FindSize),
        rangerOffsetHull(VecF, VecF, FindSize),
        rangerOffsetHull(VecG, VecG, FindSize),
        rangerOffsetHull(VecH, VecH, FindSize)
    )
    local RangerHits = array()
    for (I = 1, Rangers:count()){
        if (Rangers[I, ranger]:hit()){
            RangerHits:pushNumber(I)
        }
    }
    
    if (RangerHits:count() >= 8){
        WaterPosition = FindPosition
        WaterFound = 1
        for (I = 1, WaterPumps:count()){
            local WaterPump = WaterPumps[I, entity]
            if (WaterPump:isValid()){
                local ID = WaterPump:id()
                LastPosition[ID, vector] = ResourceNode:toLocal(WaterPump:pos())
                LastAngle[ID, angle] = ResourceNode:toLocal(WaterPump:angles())
                        
                WaterPump:setPos(WaterPosition)
                WaterPump:setAng(ang(180, 0, 0))
            }
        }
    }elseif (RangerHits:count() > 0){
        local Ranger = Rangers[RangerHits[1, normal], ranger]
        FindPosition = Ranger:pos()
        if (FindSize:length() <= 50){
            WaterPosition = FindPosition
            WaterFound = 1
            for (I = 1, WaterPumps:count()){
                local WaterPump = WaterPumps[I, entity]
                if (WaterPump:isValid()){
                    local ID = WaterPump:id()
                    LastPosition[ID, vector] = ResourceNode:toLocal(WaterPump:pos())
                    LastAngle[ID, angle] = ResourceNode:toLocal(WaterPump:angles())
                        
                    WaterPump:setPos(WaterPosition)
                    WaterPump:setAng(ang(180, 0, 0))
                }
            }
        }else{
            FindSize = FindSize / 2
            timer("FindInSquares", 200)
        }
    }
}elseif (clk("RegulatorUpdate")){
    local LSEnt = lsEntity()
    if (LSEnt:lsO2Percent() <= 1 | LSEnt:lsTemperature() >= 400 | LSEnt:lsTemperature() <= 235){
        ActivateRegulator = 1
        if (Regulators:count() > 0){
            for (I = 1, Regulators:count()){
                local WL = Regulators[I, entity]:wirelink()
                WL["On", normal] = 1
            }
        }
    }else{
        ActivateRegulator = 0
        if (Regulators:count() > 0){
            for (I = 1, Regulators:count()){
                local WL = Regulators[I, entity]:wirelink()
                WL["On", normal] = 0
            }
        }
    }
    timer("RegulatorUpdate", 500)
}elseif (clk("CoreEGP")){
    if (CoreEGP:entity():isValid()){
        CoreEGP:egpClear()
        CoreEGP:egpBox(1, vec2(256, 256), vec2(512, 512))
        CoreEGP:egpColor(1, vec(0, 125, 255))
        
        CoreEGP:egpText(2, "Core Stats", vec2(140, 20))
        CoreEGP:egpSize(2, 50)

        local CoreEnt = Core:getCoreEnt()
        if (CoreEnt){
            Armor = CoreEnt:getArmor()
            Hull = CoreEnt:getHull()
            Shield = CoreEnt:getShield()
            Cap = CoreEnt:getCap()
            
            MaxArmor = CoreEnt:getArmorMax()
            MaxHull = CoreEnt:getHullMax()
            MaxShield = CoreEnt:getShieldMax()
            MaxCap = CoreEnt:getCapMax()
            
            local ArmorPercent = round(Armor/MaxArmor, 4)
            local HullPercent = round(Hull/MaxHull, 4)
            local ShieldPercent = round(Shield/MaxShield, 4)
            local CapPercent = round(Cap/MaxCap, 4)
            
            CoreEGP:egpText(3, "Armor", vec2(20, 80))
            CoreEGP:egpSize(3, 25)
            CoreEGP:egpRoundedBox(4, vec2(340 - 163 * (1 - ArmorPercent), 90), vec2(326 * ArmorPercent, 20))
            CoreEGP:egpColor(4, vec(255 * (1 - ArmorPercent), 255 * ArmorPercent, 0))
            CoreEGP:egpRoundedBoxOutline(5, vec2(340, 90), vec2(325, 20))
            CoreEGP:egpText(6, (ArmorPercent*100)+"%", vec2(300, 80))
            if ($Armor > 0){
                CoreEGP:egpText(7, "+"+round($Armor)+" ["+round(($Armor/MaxArmor)*100, 2)+"%]", vec2(190, 100))
                CoreEGP:egpColor(7, vec(0, 255, 0))
            }elseif ($Armor < 0){
                CoreEGP:egpText(7, round($Armor)+" ["+round(-($Armor/MaxArmor)*100, 2)+"%]", vec2(190, 100))
                CoreEGP:egpColor(7, vec(255, 0, 0))
            }
            
            CoreEGP:egpText(8, "Hull", vec2(20, 130))
            CoreEGP:egpSize(8, 25)
            CoreEGP:egpRoundedBox(9, vec2(340 - 163 * (1 - HullPercent), 140), vec2(326 * HullPercent, 20))
            CoreEGP:egpColor(9, vec(255 * (1 - HullPercent), 255 * HullPercent, 0))
            CoreEGP:egpRoundedBoxOutline(10, vec2(340, 140), vec2(325, 20))
            CoreEGP:egpText(11, (HullPercent*100)+"%", vec2(300, 130))
            if ($Hull > 0){
                CoreEGP:egpText(12, "+"+round($Hull)+" ["+round(($Hull/MaxHull)*100, 2)+"%]", vec2(190, 150))
                CoreEGP:egpColor(12, vec(0, 255, 0))
            }elseif ($Hull < 0){
                CoreEGP:egpText(12, round($Hull)+" ["+round(-($Hull/MaxHull)*100, 2)+"%]", vec2(190, 150))
                CoreEGP:egpColor(12, vec(255, 0, 0))
            }
            
            CoreEGP:egpText(13, "Shield", vec2(20, 180))
            CoreEGP:egpSize(13, 25)
            CoreEGP:egpRoundedBox(14, vec2(340 - 163 * (1 - ShieldPercent), 190), vec2(326 * ShieldPercent, 20))
            CoreEGP:egpColor(14, vec(255 * (1 - ShieldPercent), 255 * ShieldPercent, 0))
            CoreEGP:egpRoundedBoxOutline(15, vec2(340, 190), vec2(325, 20))
            CoreEGP:egpText(16, (ShieldPercent*100)+"%", vec2(300, 180))
            if ($Shield > 0){
                CoreEGP:egpText(17, "+"+round($Shield)+" ["+round(($Shield/MaxShield)*100, 2)+"%]", vec2(190, 200))
                CoreEGP:egpColor(17, vec(0, 255, 0))
            }elseif ($Shield < 0){
                CoreEGP:egpText(18, round($Shield)+" ["+round(-($Shield/MaxShield)*100, 2)+"%]", vec2(190, 200))
                CoreEGP:egpColor(18, vec(255, 0, 0))
            }
            
            CoreEGP:egpText(19, "Capacitor", vec2(20, 230))
            CoreEGP:egpSize(19, 25)
            CoreEGP:egpRoundedBox(20, vec2(340 - 163 * (1 - CapPercent), 240), vec2(326 * CapPercent, 20))
            CoreEGP:egpColor(20, vec(255 * (1 - CapPercent), 255 * CapPercent, 0))
            CoreEGP:egpRoundedBoxOutline(21, vec2(340, 240), vec2(325, 20))
            CoreEGP:egpText(22, (CapPercent*100)+"%", vec2(300, 230))
            if ($Cap > 0){
                CoreEGP:egpText(23, "+"+round($Cap)+" ["+round(($Cap/MaxCap)*100, 2)+"%]", vec2(190, 250))
                CoreEGP:egpColor(23, vec(0, 255, 0))
            }elseif ($Cap < 0){
                CoreEGP:egpText(23, round($Cap)+" ["+round(-($Cap/MaxCap)*100, 2)+"%]", vec2(190, 250))
                CoreEGP:egpColor(23, vec(255, 0, 0))
            }
        }
    }
    timer("CoreEGP", 1000)
}elseif (clk("MainEGP")){
    if (EGP:entity():isValid()){
        EGP:egpClear()
        local Count = Cache:count()
        
        EGP:egpBox(Count + 1, vec2(256, 256), vec2(512, 512))
        EGP:egpColor(Count + 1, vec4(50, 50, 50, 150))
        
        EGP:egpText(Count + 2, "Starkkz Inc. Computer EGP", vec2(30, 15))
        EGP:egpColor(Count + 2, vec(255, 0, 0))
        EGP:egpText(Count + 3, "Development date 30-12-2013", vec2(30, 30))
        EGP:egpColor(Count + 3, vec(255, 0, 0))
        EGP:egpText(Count + 4, "http://www.unrealsoftware.de/profile.php?userid=10464", vec2(30, 45))
        EGP:egpColor(Count + 4, vec(255, 0, 0))
        EGP:egpText(Count + 5, "Write 'help' for command list", vec2(30, 60))
        EGP:egpColor(Count + 5, vec(255, 0, 0))
        
        for (I = 1, Count){
            local CacheI = Cache[I, table]
            EGP:egpText(I, CacheI["Text", string], vec2(30, I * 15 + 100))
            EGP:egpColor(I, CacheI["Color", vector])
        }
    }
    timer("MainEGP", 5000)
}elseif (clk("LSEGP")){
    if (StorageCache:isValid()){
        Energy = StorageWL["Energy", number]
        Oxygen = StorageWL["Oxygen", number]
        Hydrogen = StorageWL["Hydrogen", number]
        Steam = StorageWL["Steam", number]
        Water = StorageWL["Water", number]
        HvyWater = StorageWL["Hvy Water", number]
            
        MaxEnergy = StorageWL["Max Energy", number]
        MaxOxygen = StorageWL["Max Oxygen", number]
        MaxHydrogen = StorageWL["Max Hydrogen", number]
        MaxSteam = StorageWL["Max Steam", number]
        MaxWater = StorageWL["Max Water", number]
        MaxHvyWater = StorageWL["Max Hvy Water", number]
    }
    if (ResourceEGP:entity():isValid()){
        ResourceEGP:egpClear()
        ResourceEGP:egpBox(1, vec2(256, 256), vec2(512, 512))
        ResourceEGP:egpColor(1, vec(0, 125, 255))
        
        ResourceEGP:egpText(2, "Resources", vec2(140, 20))
        ResourceEGP:egpSize(2, 50)
        
        ResourceEGP:egpText(3, "Energy", vec2(20, 80))
        ResourceEGP:egpSize(3, 25)
        local EnergyPercent = round(Energy/MaxEnergy, 4)
        ResourceEGP:egpRoundedBox(4, vec2(340 - 163 * (1 - EnergyPercent), 90), vec2(326 * EnergyPercent, 20))
        ResourceEGP:egpColor(4, vec(255 * (1 - EnergyPercent), 255 * EnergyPercent, 0))
        ResourceEGP:egpRoundedBoxOutline(5, vec2(340, 90), vec2(325, 20))
        ResourceEGP:egpText(6, (EnergyPercent*100)+"%"+shortTime((MaxEnergy-Energy)/$Energy), vec2(300, 80))
        if ($Energy > 0){
            ResourceEGP:egpText(7, "+"+round($Energy)+" ["+round(($Energy/MaxEnergy)*100, 2)+"%]", vec2(190, 100))
            ResourceEGP:egpColor(7, vec(0, 255, 0))
        }elseif ($Energy < 0){
            ResourceEGP:egpText(7, round($Energy)+" ["+round(-($Energy/MaxEnergy)*100, 2)+"%]", vec2(190, 100))
            ResourceEGP:egpColor(7, vec(255, 0, 0))
        }
        
        ResourceEGP:egpText(8, "Oxygen", vec2(20, 130))
        ResourceEGP:egpSize(8, 25)
        local OxygenPercent = round(Oxygen/MaxOxygen, 4)
        ResourceEGP:egpRoundedBox(9, vec2(340 - 163 * (1 - OxygenPercent), 140), vec2(326 * OxygenPercent, 20))
        ResourceEGP:egpColor(9, vec(255 * (1 - OxygenPercent), 255 * OxygenPercent, 0))
        ResourceEGP:egpRoundedBoxOutline(10, vec2(340, 140), vec2(325, 20))
        ResourceEGP:egpText(11, (OxygenPercent*100)+"%"+shortTime((MaxOxygen-Oxygen)/$Oxygen), vec2(300, 130))
        if ($Oxygen > 0){
            ResourceEGP:egpText(12, "+"+round($Oxygen)+" ["+round(($Oxygen/MaxOxygen)*100, 2)+"%]", vec2(190, 150))
            ResourceEGP:egpColor(12, vec(0, 255, 0))
        }elseif ($Oxygen < 0){
            ResourceEGP:egpText(12, round($Oxygen)+" ["+round(-($Oxygen/MaxOxygen)*100, 2)+"%]", vec2(190, 150))
            ResourceEGP:egpColor(12, vec(255, 0, 0))
        }
        
        ResourceEGP:egpText(13, "Hydrogen", vec2(20, 180))
        ResourceEGP:egpSize(13, 25)
        local HydrogenPercent = round(Hydrogen/MaxHydrogen, 4)
        ResourceEGP:egpRoundedBox(14, vec2(340 - 163 * (1 - HydrogenPercent), 190), vec2(326 * HydrogenPercent, 20))
        ResourceEGP:egpColor(14, vec(255 * (1 - HydrogenPercent), 255 * HydrogenPercent, 0))
        ResourceEGP:egpRoundedBoxOutline(15, vec2(340, 190), vec2(325, 20))
        ResourceEGP:egpText(16, (HydrogenPercent*100)+"%"+shortTime((MaxHydrogen-Hydrogen)/$Hydrogen), vec2(300, 180))
        if ($Hydrogen > 0){
            ResourceEGP:egpText(17, "+"+round($Hydrogen)+" ["+round(($Hydrogen/MaxHydrogen)*100, 2)+"%]", vec2(190, 200))
            ResourceEGP:egpColor(17, vec(0, 255, 0))
        }elseif ($Hydrogen < 0){
            ResourceEGP:egpText(18, round($Hydrogen)+" ["+round(-($Hydrogen/MaxHydrogen)*100, 2)+"%]", vec2(190, 200))
            ResourceEGP:egpColor(18, vec(255, 0, 0))
        }
        
        ResourceEGP:egpText(19, "Water", vec2(20, 230))
        ResourceEGP:egpSize(19, 25)
        local WaterPercent = round(Water/MaxWater, 4)
        ResourceEGP:egpRoundedBox(20, vec2(340 - 163 * (1 - WaterPercent), 240), vec2(326 * WaterPercent, 20))
        ResourceEGP:egpColor(20, vec(255 * (1 - WaterPercent), 255 * WaterPercent, 0))
        ResourceEGP:egpRoundedBoxOutline(21, vec2(340, 240), vec2(325, 20))
        ResourceEGP:egpText(22, (WaterPercent*100)+"%"+shortTime((MaxWater-Water)/$Water), vec2(300, 230))
        if ($Water > 0){
            ResourceEGP:egpText(23, "+"+round($Water)+" ["+round(($Water/MaxWater)*100, 2)+"%]", vec2(190, 250))
            ResourceEGP:egpColor(23, vec(0, 255, 0))
        }elseif ($Water < 0){
            ResourceEGP:egpText(23, round($Water)+" ["+round(-($Water/MaxWater)*100, 2)+"%]", vec2(190, 250))
            ResourceEGP:egpColor(23, vec(255, 0, 0))
        }
        
        ResourceEGP:egpText(24, "Steam", vec2(20, 280))
        ResourceEGP:egpSize(24, 25)
        local SteamPercent = round(Steam/MaxSteam, 4)
        ResourceEGP:egpRoundedBox(25, vec2(340 - 163 * (1 - SteamPercent), 290), vec2(326 * SteamPercent, 20))
        ResourceEGP:egpColor(25, vec(255 * (1 - SteamPercent), 255 * SteamPercent, 0))
        ResourceEGP:egpRoundedBoxOutline(26, vec2(340, 290), vec2(325, 20))
        ResourceEGP:egpText(27, (SteamPercent*100)+"%"+shortTime((MaxSteam-Steam)/$Steam), vec2(300, 280))
        if ($Steam > 0){
            ResourceEGP:egpText(28, "+"+round($Steam)+" ["+round(($Steam/MaxSteam)*100, 2)+"%]", vec2(190, 300))
            ResourceEGP:egpColor(28, vec(0, 255, 0))
        }elseif ($Steam < 0){
            ResourceEGP:egpText(28, round($Steam)+" ["+round(-($Steam/Steam)*100, 2)+"%]", vec2(190, 300))
            ResourceEGP:egpColor(28, vec(255, 0, 0))
        }
        
        ResourceEGP:egpText(29, "Heavy Water", vec2(20, 330))
        ResourceEGP:egpSize(29, 25)
        local HvyWaterPercent = round(HvyWater/MaxHvyWater, 4)
        ResourceEGP:egpRoundedBox(30, vec2(340 - 163 * (1 - HvyWaterPercent), 340), vec2(326 * HvyWaterPercent, 20))
        ResourceEGP:egpColor(30, vec(255 * (1 - HvyWaterPercent), 255 * HvyWaterPercent, 0))
        ResourceEGP:egpRoundedBoxOutline(31, vec2(340, 340), vec2(325, 20))
        ResourceEGP:egpText(32, (HvyWaterPercent*100)+"%"+shortTime((MaxHvyWater-HvyWater)/$HvyWater), vec2(300, 330))
        if ($HvyWater > 0){
            ResourceEGP:egpText(33, "+"+round($HvyWater)+" ["+round(($HvyWater/MaxHvyWater)*100, 3)+"%]", vec2(190, 350))
            ResourceEGP:egpColor(33, vec(0, 255, 0))
        }elseif ($HvyWater < 0){
            ResourceEGP:egpText(33, round($HvyWater)+" ["+round(-($HvyWater/MaxHvyWater)*100, 3)+"%]", vec2(190, 350))
            ResourceEGP:egpColor(33, vec(255, 0, 0))
        }
    }
    timer("LSEGP", 1000)
}elseif (clk("UpdateLS")){
    if (LifeSupportOn & StorageCache:isValid()){
        local En = Energy
        local St = Steam
        local Wa = Water
        local Hw = HvyWater
        local Ox = Oxygen
        local Hy = Hydrogen

        if (WaterPumps:count() > 0){
            for (I = 1, WaterPumps:count()){
                local Ent = WaterPumps[I, entity]
                if (Ent:isValid() & Ent:owner():trusts(Owner)){
                    local ID = Ent:id()
                    local Wirelink = LifeSupportWL[ID, wirelink]
                    local EntMult = clamp(LifeSupportMult[ID, number], 1, MultMax)
                    local Usage = Wirelink["EnergyUsage", number] / EntMult
                    local Multiplier = clamp(En/Usage, 0, MultMax)
                    if (round(Multiplier) > 0 & Ent:isUnderWater() & Wa < MaxWater){
                        if (LifeSupportMute[ID, normal] == 1){
                            Wirelink["On", normal] = 1
                            Wirelink["Multiplier", normal] = Multiplier
                            LifeSupportMult[ID, number] = Multiplier
                            
                            En = En - Usage * Multiplier
                            Wa = Wa + (Wirelink["WaterProduction", number] / EntMult) * Multiplier
                        }else{
                            Wirelink["Mute", normal] = 1
                            LifeSupportMute[ID, normal] = 1
                            LifeSupportMult[ID, normal] = 1
                        }
                    }else{
                        Wirelink["On", normal] = 0
                    }
                }else{
                    WaterPumps:removeEntity(I)
                }
            }
        }
        
        if (WaterElectrolyzers:count() > 0){
            for (I = 1, WaterElectrolyzers:count()){
                local Ent = WaterElectrolyzers[I, entity]
                if (Ent:isValid()){
                    local ID = Ent:id()
                    local Wirelink = LifeSupportWL[ID, wirelink]
                    local EntMult = clamp(LifeSupportMult[ID, number], 1, MultMax)
                    local WaterUsage = Wirelink["Water Usage", number] / EntMult
                    local EnergyUsage = Wirelink["Energy Usage", number] / EntMult
                    local Multiplier = clamp(clamp(Wa/WaterUsage, 0, MultMax), 0, En/EnergyUsage)
                    if (round(Multiplier) > 0 & WaterPumps:count() > 0 & St < MaxSteam){
                        if (LifeSupportMute[ID, normal] == 1){
                            Wirelink["On", normal] = 1
                            Wirelink["Multiplier", normal] = Multiplier
                            LifeSupportMult[ID, number] = Multiplier
                            
                            Wa = Wa - WaterUsage * Multiplier
                            En = En - EnergyUsage * Multiplier
                            Hw = Hw + (Wirelink["Heavy Water Production", number] / EntMult) * Multiplier
                            St = St + (Wirelink["Steam Production", number] / EntMult) * Multiplier
                        }else{
                            Wirelink["Mute", normal] = 1
                            LifeSupportMute[ID, normal] = 1
                            LifeSupportMult[ID, number] = 1
                        }
                    }else{
                        Wirelink["On", normal] = 0
                    }
                }else{
                    WaterElectrolyzers:removeEntity(I)
                }
            }
        }
        
        if (SteamTurbines:count() > 0){
            for (I = 1, SteamTurbines:count()){
                local Ent = SteamTurbines[I, entity]
                if (Ent:isValid()){
                    local ID = Ent:id()
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    local EntMult = clamp(LifeSupportMult[ID, number], 1, MultMax)
                    local Usage = Wirelink["SteamUsage", number] / EntMult
                    local Multiplier = clamp(St/Usage, 0, MultMax)
                    if (round(Multiplier) > 0 & (Wa < MaxWater | En < MaxEnergy)){
                        if (LifeSupportMute[ID, normal] == 1){
                            Wirelink["On", normal] = 1
                            Wirelink["Multiplier", normal] = Multiplier
                            LifeSupportMult[ID, number] = Multiplier
                            
                            St = St - Usage * Multiplier
                            Wa = Wa + (Wirelink["WaterProduction", number] / EntMult) * Multiplier
                            En = En + (Wirelink["EnergyProduction", number] / EntMult) * Multiplier
                        }else{
                            Wirelink["Mute", normal] = 1
                            LifeSupportMute[ID, normal] = 1
                            LifeSupportMult[ID, number] = 1
                        }
                    }else{
                        Wirelink["On", normal] = 0
                    }
                }else{
                    SteamTurbines:removeEntity(I)
                }
            }
        }
        
        if (WaterSplitters:count() > 0){
            for (I = 1, WaterSplitters:count()){
                local Ent = WaterSplitters[I, entity]
                if (Ent:isValid()){
                    local ID = Ent:id()
                    local Wirelink = LifeSupportWL[ID, wirelink]
                    local EntMult = clamp(LifeSupportMult[ID, number], 1, MultMax)
                    local WaterUsage = Wirelink["WaterUsage", number] / EntMult
                    local EnergyUsage = Wirelink["EnergyUsage", number] / EntMult
                    local Multiplier = clamp(clamp(Wa/WaterUsage, 0, MultMax), 0, En/EnergyUsage)
                    if (round(Multiplier) > 0 & WaterPumps:count() > 0 & (Hy < MaxHydrogen | Ox < MaxOxygen)){
                        if (LifeSupportMute[ID, normal] == 1){
                            Wirelink["On", normal] = 1
                            Wirelink["Multiplier", normal] = Multiplier
                            LifeSupportMult[ID, number] = Multiplier
                            
                            Wa = Wa - WaterUsage * Multiplier
                            En = En - EnergyUsage * Multiplier
                            Ox = Ox + (Wirelink["OxygenProduction", number] / EntMult) * Multiplier
                            Hy = Hy + (Wirelink["HydrogenProduction", number] / EntMult) * Multiplier
                        }else{
                            Wirelink["Mute", normal] = 1
                            LifeSupportMute[ID, normal] = 1
                            LifeSupportMult[ID, number] = 1
                        }
                    }else{
                        Wirelink["On", normal] = 0
                    }
                }else{
                    WaterSplitters:removeEntity(I)
                }
            }
        }
        
        if (FusionReactors:count() > 0){
            for (I = 1, FusionReactors:count()){
                local Ent = FusionReactors[I, entity]
                if (Ent:isValid()){
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    if (WaterPumps:count() > 0 & Water > 0 & En < MaxEnergy*0.99){
                        Wirelink["On", normal] = 1
                    }else{
                        Wirelink["On", normal] = 0
                    }
                }else{
                    FusionReactors:removeEntity(I)
                }
            }
        }
        timer("UpdateLS", 1000)
    }else{
        if (WaterPumps:count() > 0){
            for (I = 1, WaterPumps:count()){
                local Ent = WaterPumps[I, entity]
                if (Ent:isValid()){
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    Wirelink["On", normal] = 0
                }
            }
        }
        
        if (SteamTurbines:count() > 0){
            for (I = 1, SteamTurbines:count()){
                local Ent = SteamTurbines[I, entity]
                if (Ent:isValid()){
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    Wirelink["On", normal] = 0
                }else{
                    SteamTurbines:removeEntity(I)
                }
            }
        }
        
        if (WaterElectrolyzers:count() > 0){
            for (I = 1, WaterElectrolyzers:count()){
                local Ent = WaterElectrolyzers[I, entity]
                if (Ent:isValid()){
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    Wirelink["On", normal] = 0
                }else{
                    WaterElectrolyzers:removeEntity(I)
                }
            }
        }
        
        if (WaterSplitters:count() > 0){
            for (I = 1, WaterSplitters:count()){
                local Ent = WaterSplitters[I, entity]
                if (Ent:isValid()){
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    Wirelink["On", normal] = 0
                }else{
                    WaterSplitters:removeEntity(I)
                }
            }
        }
        
        if (FusionReactors:count() > 0){
            for (I = 1, FusionReactors:count()){
                local Ent = FusionReactors[I, entity]
                if (Ent:isValid()){
                    local Wirelink = LifeSupportWL[Ent:id(), wirelink]
                    Wirelink["On", normal] = 0
                }else{
                    FusionReactors:removeEntity(I)
                }
            }
        }
    }
}elseif (dsClk("dstarget")){
    local Target = dsGetEntity()
    local Sender = dsGetSender():owner()
    if (Target:isValid()){
        if (Sender != Owner){
            TargetRequest = Target
            output(Sender:name()+" requests targeting "+Target:name()+" [accept/reject]?", 255, 125, 0)
        }else{
            output(Sender:name()+" requests targeting "+Target:name(), 255, 125, 0)
        }
    }
}elseif (dsClk("targetaccepted")){
    local Target = dsGetEntity()
    local Sender = dsGetSender():owner()
    if (Target:isValid()){
        output(Sender:name()+" accepted targeting "+Target:name(), 255, 125, 0)
    }
}elseif (dsClk("targetdenied")){
    local Target = dsGetEntity()
    local Sender = dsGetSender():owner()
    if (Target:isValid()){
        output(Sender:name()+" denied targeting "+Target:name(), 255, 125, 0)
    }
}elseif (~PrevTarget|~NextTarget){
    switchTargets()
}elseif (chatClk()){
    local Text = lastSaid()
    local Player = lastSpoke()
    if (Player:aimEntity() == EGP:entity() & EGP:entity():isValid()){
        processLine(Text, Player)
        hideChat(1)
    }
}elseif (dsClk("dsmsg")){
    local Text = dsGetString()
    local Sender = dsGetSender():owner()
    output(Sender:name()+" says: "+Text, 125, 255, 0)
}elseif (clk("autoupdate")){
    print("Auto-updating ship computer")
    print("NOTE: If the chip has an error during the update, reset it with expression 2 tool")
    if (LifeSupportOn){
        processLine("ls off", Owner)
    }
    entity():remoteSetCode(NewCode)
    exit()
}elseif (dsClk("ver")){
    local E2Version = dsGetNumber()
    if (E2Version < Version & dsGetSender() != owner()){
        dsSend("newver", getDataGroup(), 2, array(Version, getCode()))
    }
}elseif (dsClk("newver")){
    local Response = dsGetArray()
    local E2Version = Response[1, number]
    local Code = Response[2, string]
    if (E2Version > Version & E2Version > NewVersion){
        NewCode = Code
        NewVersion = E2Version
        stoptimer("autoupdate")
        timer("autoupdate", 2000)
    }
}elseif (dsClk("ResourceNode")){
    local RN = dsGetEntity()
    if (RN:type() == "resource_node"){
        ResourceNode = RN
    }
}elseif (dsClk("StorageCache")){
    local SC = dsGetEntity()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        StorageCache = SC
        StorageCache:link(ResourceNode)
        StorageWL = SC:wirelink()
    }
}elseif (dsClk("SteamTurbines")){
    local ST = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        SteamTurbines = array()
        for (I = 1, ST:count()){
            local Ent = ST[I, entity]
            if (Ent:isValid()){
                SteamTurbines:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("WaterElectrolyzers")){
    local WE = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        WaterElectrolyzers = array()
        for (I = 1, WE:count()){
            local Ent = WE[I, entity]
            if (Ent:isValid()){
                WaterElectrolyzers:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("WaterSplitters")){
    local WS = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        WaterSplitters = array()
        for (I = 1, WS:count()){
            local Ent = WS[I, entity]
            if (Ent:isValid()){
                WaterSplitters:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("FusionReactors")){
    local FR = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        FusionReactors = array()
        for (I = 1, FR:count()){
            local Ent = FR[I, entity]
            if (Ent:isValid()){
                FusionReactors:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("SolarPanels")){
    local SP = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        SolarPanels = array()
        for (I = 1, SP:count()){
            local Ent = SP[I, entity]
            if (Ent:isValid()){
                SolarPanels:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("StorageCaches") | dsClk("GasTanks") | dsClk("WaterTanks") | dsClk("HvyWaterTanks") | dsClk("Batteries")){
    local Storage = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        for (I = 1, Storage:count()){
            local Ent = Storage[I, entity]
            if (Ent:isValid()){
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("WaterPumps")){
    local WP = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        WaterPumps = array()
        for (I = 1, WP:count()){
            local Ent = WP[I, entity]
            if (Ent:isValid()){
                WaterPumps:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}elseif (dsClk("Regulators")){
    local R = dsGetArray()
    local Sender = dsGetSender():owner()
    if (Sender == Owner){
        Regulators = array()
        for (I = 1, R:count()){
            local Ent = R[I, entity]
            if (Ent:isValid()){
                Regulators:pushEntity(Ent)
                LifeSupportWL[Ent:id(), wirelink] = Ent:wirelink()
                Ent:link(ResourceNode)
            }
        }
    }
}

Resource finder
I made this because the ship computer was using too much CPU power with it integrated. It should find most of the Life Support stuff.
@name Resource Finder by Starkkz
inputs ResourceNode:entity
persist Parts:array Index Control
persist C:array ST:array WE:array WS:array FR:array SP:array WP:array SC:array ES:array HWS:array GT:array WT:array
outputs SteamTurbines:array WaterElectrolyzers:array WaterSplitters:array FusionReactors:array SolarPanels:array WaterPumps:array
outputs StorageCache:entity StorageCacheW:wirelink
outputs StorageCaches:array EnergyStorage:array HvyWaterStorage:array GasTanks:array WaterTanks:array Regulators:array
if (duped()){reset()}

if (first()|dupefinished()){
    dsSetScope(1)
    dsJoinGroup("LS")
    
    Control = 1
    timer("Control", 1000)
}elseif (clk("Control")){
    if (Control == 1){
        if (ResourceNode:isValid()){
            findClearWhiteList()
            findClearBlackList()
            #findIncludeClass("base_climate_control")
            findIncludeClass("resource_node")
            findIncludeClass("generator_energy_steam_turbine")
            findIncludeClass("generator_liquid_hvywater")
            findIncludeClass("generator_liquid_water")
            findIncludeClass("generator_gas_o2h_water")
            findIncludeClass("generator_energy_fusion")
            findIncludeClass("generator_energy_solar")
            findIncludeClass("ls_core")
            findIncludeClass("storage_cache")
            findIncludeClass("storage_energy")
            findIncludeClass("storage_liquid_hvywater")
            findIncludeClass("storage_gas")
            findIncludeClass("storage_liquid_water")
            findInSphere(ResourceNode:pos(), 2048)
            Parts = findToArray()
        }else{
            Parts = array()
        }
        
        C = array()
        ST = array()
        WE = array()
        WS = array()
        FR = array()
        SP = array()
        WP = array()
        SC = array()
        ES = array()
        HWS = array()
        GT = array()
        WT = array()
        Index = 0
        Control = 2
        timer("Control", 1)
    }elseif (Control == 2){
        if (Parts:count() > 0){
            while (Index <= Parts:count()){
                if (minquota() < 100){
                    timer("Control", 1)
                    break
                }
                local Ent = Parts[Index, entity]
                local Type = Ent:type()
                if (ResourceNode:isValid() & Ent:owner():trusts(owner())){
                    if (Type == "generator_energy_steam_turbine"){
                        ST:pushEntity(Ent)
                    }elseif (Type == "generator_liquid_hvywater"){
                        WE:pushEntity(Ent)
                    }elseif (Type == "generator_liquid_water"){
                        WP:pushEntity(Ent)
                    }elseif (Type == "generator_gas_o2h_water"){
                        WS:pushEntity(Ent)
                    }elseif (Type == "generator_energy_fusion"){
                        FR:pushEntity(Ent)
                    }elseif (Type == "generator_energy_solar"){
                        SP:pushEntity(Ent)
                    }elseif (Type == "storage_cache"){
                        SC:pushEntity(Ent)
                        StorageCache = Ent
                        StorageCacheW = Ent:wirelink()
                    }elseif (Type == "storage_energy"){
                        ES:pushEntity(Ent)
                    }elseif (Type == "storage_liquid_hvywater"){
                        HWS:pushEntity(Ent)
                    }elseif (Type:sub(1, 11) == "storage_gas"){
                        GT:pushEntity(Ent)
                    }elseif (Type == "storage_liquid_water"){
                        WT:pushEntity(Ent)
                    }elseif (Type == "base_climate_control" | "ls_core"){
                        C:pushEntity(Ent)
                    }
                }
                Index = Index + 1
            }
        }
        if (Index > Parts:count() | Parts:count() == 0){
            Control = 3
            timer("Control", 1)
        }
    }elseif (Control == 3){
        Regulators = C
        SteamTurbines = ST
        WaterElectrolyzers = WE
        WaterSplitters = WS
        WaterPumps = WP
        FusionReactors = FR
        SolarPanels = SP
        StorageCaches = SC
        EnergyStorage = ES
        HvyWaterStorage = HWS
        GasTanks = GT
        WaterTanks = WT
        
        if (ResourceNode:isValid()){dsSend("ResourceNode", "LS", 0, ResourceNode)}
        dsSend("StorageCache", "LS", 0, StorageCache) 
        dsSend("SteamTurbines", "LS", 0, SteamTurbines)
        dsSend("WaterElectrolyzers", "LS", 0, WaterElectrolyzers)
        dsSend("WaterSplitters", "LS", 0, WaterSplitters)
        dsSend("FusionReactors", "LS", 0, FusionReactors)
        dsSend("SolarPanels", "LS", 0, SolarPanels)
        dsSend("StorageCaches", "LS", 0, StorageCaches)
        dsSend("WaterPumps", "LS", 0, WaterPumps)
        dsSend("Regulators", "LS", 0, Regulators)
        dsSend("GasTanks", "LS", 0, GasTanks)
        dsSend("WaterTanks", "LS", 0, WaterTanks)
        dsSend("HvyWaterTanks", "LS", 0, HvyWaterStorage)
        
        local Name = "Resource Finder by Starkkz"
        if (SteamTurbines:count() > 0){Name = Name+"\nSteam Turbines: "+SteamTurbines:count()}
        if (WaterElectrolyzers:count() > 0){Name = Name+"\nHeavy Water Electrolyzer: "+WaterElectrolyzers:count()}
        if (WaterSplitters:count() > 0){Name = Name+"\nWater Splitters: "+WaterSplitters:count()}
        if (FusionReactors:count() > 0){Name = Name+"\nFusion Reactors: "+FusionReactors:count()}
        if (SolarPanels:count() > 0){Name = Name+"\nSolar Panels: "+SolarPanels:count()}
        if (WaterPumps:count() > 0){Name = Name+"\nWater Pumps: "+WaterPumps:count()}
        if (StorageCaches:count() > 0){Name = Name+"\nStorage Caches: "+StorageCaches:count()}
        if (EnergyStorage:count() > 0){Name = Name+"\nEnergy Storages: "+EnergyStorage:count()}
        if (HvyWaterStorage:count() > 0){Name = Name+"\nHeavy Water Tanks: "+HvyWaterStorage:count()}
        if (GasTanks:count() > 0){Name = Name+"\nGas Tanks: "+GasTanks:count()}
        if (WaterTanks:count() > 0){Name = Name+"\nWater Tanks: "+WaterTanks:count()}
        if (Regulators:count() > 0){Name = Name+"\nClimate Regulators: "+Regulators:count()}
        setName(Name)
        
        Control = 1
        timer("Control", 10000)
    }
}

If any of you finds an error, or has an issue with it, please post.

Leave a Comment

bolditalicunderlinestrikecodeimageurlquotespoiler
Drop image/file