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!

E2 lifesupport

SweetOneSweetOne Posts: 39Registered
edited January 2014 in Showcase #1
Hello!

I bring my E2 lifesupport to you. :D

Its a bit old schoolish since the last update.

-No wiring
-Links automatically all life support parts and core to the node
-Adjusts resources
-Adjusts capacitor
-Adjusts ship environment when probe is around
-Starts to repair shields when needed

Enjoy!
@name SweetOnes_Lifesupport
persist Players:array Caches:array Probes:array Fusions:array O2Hs:array Steams:array Waters:array LScores:array Nodes:array Storages:array SolarPanels:array Climates:array
persist Dispensers:array Waterpumps:array Cores:array Repairs:array
persist Fusion:wirelink Cache:wirelink Pump:wirelink O2H:wirelink Steam:wirelink Waterpump:wirelink Water:wirelink AtmoProbe:wirelink Climate:wirelink Core:wirelink
persist LSCore:wirelink Repair:wirelink
    
    #Lets find devices first and wirelink & link em
if(first()|dupefinished()){
        
    Players=players()
    O=owner()
    E=entity()

    for(I=1,Players:count()) {
        findExcludePlayerProps(Players[I,entity])
    }
    
    findAllowPlayerProps(O)
    findIncludeClass("resource_node")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Nodes=findToArray()
    
    if (!(Nodes)) {
        print("Unable to find a node close enough!")
    
    }
    if(Nodes){
        for(I=1,Nodes:count()) {
            Nodes[I, entity]:wirelink() 
            print(Nodes[I, entity]:toString()+" link has been made")
        }
    }

    findExcludeClass("resource_node")
    findIncludeClass("storage_cache")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Caches=findToArray()
    if (!(Caches)) {
        print("Unable to find a cache close enough!")
    }
    if(Caches){
        for(I=1,Caches:count()) {
            Caches[I, entity]:wirelink()
            Caches[I, entity]:link(Nodes[1, entity])
            Cache=Caches[1, wirelink] 
            print(Caches[1, entity]:toString()+" link has been made")
        }
    }

    findExcludeClass("storage_cache")
    findIncludeClass("other_probe")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Probes=findToArray()
    if (!(Probes)) {
        print("Unable to find a atmoprobe close enough!")
    }
    if(Probes){
        for(I=1,Probes:count()) {
            Probes[1, entity]:wirelink()
            Probes[1, entity]:link(Nodes[1, entity])
            AtmoProbe=Probes[I, wirelink]
            print(Probes[1, entity]:toString()+" link has been made")
        }
    }

    findExcludeClass("other_probe")
    findIncludeClass("other_dispenser")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Dispensers=findToArray()
    if (!(Dispensers)) {
        print("Unable to find a dispenser close enough!")
    }
    if(Dispensers){
        for(I=1,Dispensers:count()) {Dispensers[I, entity]:wirelink() Dispensers[I, entity]:link(Nodes[1, entity]) print(Dispensers[I, entity]:toString()+" link has been made")
        }
    }
    
    findExcludeClass("other_probe")
    findExcludeClass("other_dispenser")
    findIncludeClass("generator_energy_fusion")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Fusions=findToArray()
    if (!(Fusions)) {
        print("Unable to find a fusion close enough!")
    }
    if(Fusions){
        for(I=1,Fusions:count()) {
            Fusions[I, entity]:wirelink() 
            Fusions[I, entity]:link(Nodes[1, entity]) 
            Fusion=Fusions[I, wirelink]
            print(Fusions[I, entity]:toString()+" link has been made")
        }
    }
    
    findExcludeClass("generator_energy_fusion")
    findIncludeClass("generator_gas_o2h_water")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    O2Hs=findToArray()
    if (!(O2Hs)) {
        print("Unable to find a h20 close enough!")
    }
    if(O2Hs){
        for(I=1,O2Hs:count()) {
            O2Hs[I, entity]:wirelink() 
            O2Hs[I, entity]:link(Nodes[1, entity]) 
            O2H=O2Hs[I, wirelink]
            O2H["Multiplier",number]=200 
            O2H["Mute",number]=1 
            print(O2Hs[I, entity]:toString()+" link has been made")
        }
    }
    
    findExcludeClass("generator_gas_o2h_water")
    findIncludeClass("generator_liquid_water")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Waterpumps=findToArray()
    if (!(Waterpumps)) {
        print("Unable to find a core close enough!")
    }
    if(Waterpumps){
        for(I=1,Waterpumps:count()) {
            Waterpumps[1, entity]:wirelink() 
            Waterpumps[1, entity]:link(Nodes[1, entity]) 
            Waterpump=Waterpumps[I, wirelink] 
            Waterpump["Multiplier",number]=200 
            Waterpump["Mute",number]=1 
            print(Waterpumps[I, entity]:toString()+" link has been made")
        }
    }
    
    findExcludeClass("generator_liquid_water")
    findIncludeClass("generator_liquid_hvywater")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Steams=findToArray()
    if (!(Steams)) {
        print("Unable to find a core close enough!")
    }
    if(Steams){
        timer("continue",2000)
            for(I=1,Steams:count()) {
                Steams[I, entity]:wirelink() 
                Steams[I, entity]:link(Nodes[1, entity])
                Steam=Steams[I, wirelink]
                Steam["Multiplier",number]=200 
                Steam["Mute",number]=1
                print(Steams[I, entity]:toString()+" link has been made")}
            }
    }
    #if first have limited capacity so we need to continue it
    
if(clk("continue")){
    Players=players() O=owner() E=entity()
    for(I=1,Players:count()) {
        findExcludePlayerProps(Players[I,entity])
    }
    
    findAllowPlayerProps(O)
    findExcludeClass("generator_liquid_hvywater")
    findIncludeClass("generator_energy_steam_turbine")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Waters=findToArray()
    if (!(Waters)) {
        print("Unable to find a core close enough!")
    }
    if(Waters){
        for(I=1,Waters:count()) {
            Waters[I, entity]:wirelink()
            Waters[I, entity]:link(Nodes[1, entity])
            Water=Waters[I, wirelink]
            Water["Multiplier",number]=200
            Water["Mute",number]=1
            print(Waters[I, entity]:toString()+" link has been made")
        }
    }
    
    findExcludeClass("generator_energy_steam_turbine")
    findIncludeClass("ls_core")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    LSCores=findToArray()
    if (!(LSCores)) {
        print("Unable to find a core close enough!")
    }
    
    if(LSCores){
        for(I=1,LSCores:count()) {
            LSCores[1, entity]:wirelink()
            LSCores[1, entity]:link(Nodes[1, entity])
            LSCore=LSCores[I, wirelink]
            print(LSCores[1, entity]:toString()+" link has been made")
        }
    }
    
    findExcludeClass("ls_core")
    findIncludeClass("storage_energy")
    findIncludeClass("storage_liquid_water")
    findIncludeClass("storage_gas")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Storages=findToArray()
    if (!(Storages)) {
        print("Unable to find a core close enough!")
    }
    if(Storages){
        for(I=1,Storages:count()) {
            Storages[I, entity]:wirelink()
            Storages[I, entity]:link(Nodes[1, entity])
            print(Storages[I, entity]:toString()+" link has been made")
       }
    }
    
    findExcludeClass("storage_energy")
    findExcludeClass("storage_liquid_water")
    findExcludeClass("storage_gas")
    findIncludeClass("generator_energy_solar")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    SolarPanels=findToArray()
    if (!(SolarPanels)) {
        print("Unable to find a core close enough!")
    }
    if(SolarPanels){
        for(I=1,SolarPanels:count()) {
            SolarPanels[I, entity]:wirelink()
            SolarPanels[I, entity]:link(Nodes[1, entity])
            print(SolarPanels[I, entity]:toString()+" link has been made")
       }
    }
    findExcludeClass("generator_energy_solar")
    findIncludeClass("base_climate_control")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Climates=findToArray()
    if (!(Storages)) {
        print("Unable to find a core close enough!")
    }
    if(Climates){
        for(I=1,Climates:count()) {
            Climates[I, entity]:wirelink()
            Climates[I, entity]:link(Nodes[1, entity])
            print(Climates[I, entity]:toString()+" link has been made")
        }
        Climate=Climates[1, wirelink]
        Climate["Radius",number]=6000
    }
    findExcludeClass("base_climate_control")
    findIncludeClass("ship_core")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Cores=findToArray()
    if (!(Cores)) {
        print("Unable to find a core close enough!")
    }
    if(Cores){
        for(I=1,Cores:count()) {
            Cores[I, entity]:wirelink()
            Cores[I, entity]:link(Nodes[1, entity])
            print(Cores[I, entity]:toString()+" link has been made")
        }
        Core=Cores[1, wirelink]
    }
    
    findExcludeClass("ship_core")
    findIncludeClass("sc_shield_repair")
    findInSphere(E:pos(),5000)
    findSortByDistance(E:pos())
    Repairs=findToArray()
    if (!(Repairs)) {
        print("Unable to find a repair close enough!")
    }
    if(Repairs){
        for(I=1,Repairs:count()) {
            Repairs[I, entity]:wirelink()
            Repairs[I, entity]:link(Nodes[1, entity])
            print(Repairs[I, entity]:toString()+" link has been made")
        }
    }
    
    stoptimer("continue")
    }
    #
    #if first finally ends
    #
runOnChat(1)
interval(1000)
    
if (Cache["Water",number]<= Cache["Max Water",number] * 0.99 & Cache["Max Steam",number]>0 & Cache["Energy",number] >= Cache["Max Energy",number] *0.2) {
    for(I=1,Waters:count()){
        Water=Waters[I, wirelink]
        Water["On",number]=1
    }
}
if (Cache["Water",number]<= Cache["Max Water",number] * 0.99 & Cache["Energy",number] >= Cache["Max Energy",number] *0.02) {
    Waterpump["On",number]=1
}
if (Cache["Water",number] >= Cache["Max Water",number] *0.99) { 
    Waterpump["On",number]=0 
    for(I=1,Waters:count()){
        Water=Waters[I, wirelink] 
        Water["On",number]=0
    }
}
    
if(Cache["Water",number] >= Cache["Max Water",number] *0.02){
    if(Cache["Energy",number] <= Cache["Max Energy",number] * 0.50 | Core["Capacitor",number] <= Core["Max Capacitor",number] * 0.99) {
        for(I=1,Fusions:count()) {
            Fusion=Fusions[I, wirelink]
            Fusion["On",number]=1
        }
    }
}
if (Core["Capacitor",number] >= Core["Max Capacitor",number] * 0.99 & Cache["Energy",number] >= Cache["Max Energy",number] * 0.50) {
    for(I=1,Fusions:count()) {
        Fusion=Fusions[I, wirelink] 
        Fusion["On",number]=0
    }
}
    
if(Cache["Water",number] >= Cache["Max Water",number] *0.3 & Cache["Energy",number] >= Cache["Max Energy",number] *0.98 || Cache["Hvy Water",number] < Cache["Max Hvy Water",number] *0.02){
    if (Cache["Steam",number] <= Cache["Max Steam",number] * 0.95) {
        for(I=1,Steams:count()) {
            Steam=Steams[I, wirelink] 
            Steam["On",number]=1
        }
    }
    if (Cache["Steam",number] >= Cache["Max Steam",number] *0.99) {
        for(I=1,Steams:count()) {
            Steam=Steams[I, wirelink] 
            Steam["On",number]=0
        }
    }
}
    
if(Cache["Water",number] >= Cache["Max Water",number] *0.02 & Cache["Energy",number] >= Cache["Max Energy",number] *0.10){
    if (Cache["Oxygen",number] <= Cache["Max Oxygen",number] * 0.91 || Cache["Hydrogen",number] <= Cache["Max Hydrogen",number] * 0.90) {
        for(I=1,O2Hs:count()) {
            O2H=O2Hs[I, wirelink]
            O2H["On",number]=1
        }
    }
    if (Cache["Oxygen",number] >= Cache["Max Oxygen",number] *0.99 & Cache["Hydrogen",number] >= Cache["Max Hydrogen",number] *0.99) {
        for(I=1,O2Hs:count()) {
            O2H=O2Hs[I, wirelink]
            O2H["On",number]=0
        }
    }
}
    
if(Cache["Energy",number] >= Cache["Max Energy",number] * 0.02){
    AtmoProbe["On",number]=1 
    LSCore["On",number]=1
}
else{
    AtmoProbe["On",number]=0 
    LSCore["On",number]=0
}
    
if(Core["Shield",number] <= Core["Max Shield",number] * 0.99){    
    for(I=1,Repairs:count()) {
        Repair=Repairs[I, wirelink]
        Repair["On",number]=1
    }
}else{
    for(I=1,Repairs:count()) {
        Repair=Repairs[I, wirelink]
        Repair["On",number]=0
    }
}
    

Leave a Comment

bolditalicunderlinestrikecodeimageurlquotespoiler
Drop image/file