@name Steamsource Dynamo v1 - Resource E2 (MrStump) @inputs PumpManualWire:wirelink @persist SteamGenEnergyMaintain AllowSplitter SplitterOxyMaintain SplitterHydMaintain FusionGenEnergyMaintain @persist SetupSteps GearUp GEAR ModeToggle PumpGen HeavGen SpltGen NoSplitter HaveSplit @outputs PumpOn HeavOn StemOn SpltOn FusiOn IgnoreQuants FusionCount FusionMult MinWaterLevel @persist [E2 PumpEnt Node]:entity [Color]:vector [DeviceNames ErrorNames]:array @persist [Pump Heav Stem Splt Cache Fus1 Fus2 Fus3 Fus4 Quan]:wirelink @trigger none @model models/props_phx/life_support/battery_medium.mdl if(first()|dupefinished()){ Share = 0 #Make Share=1 to share this E2 with others, make Share=0 to make the e2 function ############### WHAT IS THIS ############### # A resource generation E2. It finds the nearest resource node (2000 unit radius) # and then looks for the right equipment linked to it. Then it runs it all automatically. # Will fill Energy/Water/Oxygen/Hydrogen when water pump is placed in water, and will generate # power with steam/fusions if pump is out of water. # The devices's 3 indicator lights on the front stand for the following: # Top - Water Pump On/Off # Center - Steam Turbine On/Off # Bottom - H20 Spliter On/Off ############### REQUIREMENTS ############### # (Have only ONE IF EACH of numbers 2-4 connected to the node # 1) Resource Node (Any model) # 2) Water pump (Any model) # 3) Heavy Water Extractor (Any model) # 4) Steam Turbine (Only model) # 5) Resource cache (Any model. DO NOT USE SEPERATE STEAM STORAGE! IT LEAKS!) # 6) Some Starting Power (Can use solar, wind, or hydroelectric for starting power) # (If Quantum or Fusion gen are linked to node, this e2 will use them) # (Any model Quantum or Fusion will work automatically) # (OPTIONAL) H20 Splitter (Any model) ########### INSTRUCTIONS FOR USE ########### # 1) Spawn all required items listed above. # 2) Link all items to the RESOURCE NODE. Must be linked directly to node. # 3) Place this e2 so it is within 2000 units of the node. # 4) Wait a few seconds. If bar light on device turns from yellow to green, it is ready! # -- FOLLOWING STEPS OPTIONAL -- # #) Change variables listed in special section below to your liking # #) Change "WaitForPump" in variables to allow you to manually wire a water pump ############ EDITABLE VARIABLES ############ WaitForPump = 0 # 1 pauses E2 in self-setup to allow you to manually wire a waterpump IgnoreQuants = 0 # 1 will have this e2 ignore any quantum generators on the node FuckYourHolos = 0 # 1 disables the holo indicators and decoration on the device Color = vec(255,255,255) #Color of the E2 once done setup #VARIABLES FOR WHEN WATERPUMP IS NOT IN WATER. PERCENTAGES IN 0%-100% FORM MinWaterLevel = 5 # minimum % of water required to activate turbine/fusions/splitter (100 keeps it off) FusionGenEnergyMaintain = 99 # % of minimum energy fusion generation maintains (0 keeps off fusions) SteamGenEnergyMaintain = 80 # % of minimum energy steam generation will maintain (0 disables steamgen) AllowSplitter = 0 # Allows splitter to be used while pump not in water # WARNING: SPLITTER IS EXTREMELY WATER INTENSIVE! Leave off! SplitterOxyMaintain = 0 # % of minimum oxygen the splitter will allow before activating SplitterHydMaintain = 0 # % of minimum hydrogen the splitter will allow before activating ######## END EDITABLE VARIABLES ######## ###### DO NOT EDIT PAST THIS POINT! ###### ############################################ if(Share){print("E2 is in SHARE MODE and will not work. Go to line 12 and make Share = 0") exit()} SetupSteps = 1 PumpOn = 0 HeavOn = 0 StemOn = 0 SpltOn = 0 FusiOn = 0 GearUp = 0 ModeToggle = 1 FusionMult = 0 E2 = entity() E2:setMaterial("spacebuild/SBLight5_D") #E2:setColor(vec(200,200,50)) DeviceNames[1, string] = " -Resource Cache (any model)" DeviceNames[2, string] = " -Steam Turbine (CE Small Steam Turbine)" DeviceNames[3, string] = " -Heavy Water Electrolizer (any model)" DeviceNames[4, string] = " -Water Pump (any model)" if(FuckYourHolos!=1){ holoCreate(1, E2:toWorld(vec(0,0,1)),vec(0.41,0.41,0.9),E2:toWorld(ang(0,-90,0))) holoModel( 1, "models/props_combine/combine_mortar01b.mdl") holoMaterial(1, "models/props/cs_office/snowmana") holoParent(1, E2) holoCreate(2, E2:toWorld(vec(0,-8.5,26.1)), vec(5,1,1.9)*0.2, E2:angles(), vec(200,50,50)) holoCreate(3, E2:toWorld(vec(0,-8.5,21.7)), vec(5,1,1.9)*0.2, E2:angles(), vec(200,50,50)) holoCreate(4, E2:toWorld(vec(0,-8.5,17.3)), vec(5,1,1.9)*0.2, E2:angles(), vec(200,50,50)) for(A=2,4){ holoModel( A, "models/hunter/blocks/cube025x025x025.mdl") holoParent(A, E2) } } } interval(1000) #For wiring all the correct devices if(SetupSteps!=0){ if(clk("SD")){selfDestruct() exit()} if(SetupSteps==100){ if(->PumpManualWire){ SetupSteps = 2 } } elseif(SetupSteps==1){ findIncludePlayerProps(owner()) findByClass("resource_node") E2POS = E2:pos() findClipToSphere(E2POS,2000) findSortByDistance(E2POS) Node = find() if(Node==noentity()){ print("ERROR: No player-owned node found within 2000 units. Place e2 near node.") Error = 1 } else{ if(WaitForPump==0){ SetupSteps = 2 } else { SetupSteps = 100 } } } elseif(SetupSteps==2){ LinkedDevices = Node:rdNetEntities() #For Pump manual override if(->PumpManualWire){ Device = PumpManualWire:entity() Model = Device:model() if(Model == "models/chipstiks_ls3_models/largeh2opump/largeh2opump.mdl"){ PumpGen = 0.35 } elseif(Model == "models/ce_ls3additional/water_pump/water_pump.mdl"){ PumpGen = 1.8242 } elseif(Model == "models/props_phx/life_support/gen_water.mdl"){ PumpGen = 4.63 } else{ print("ERROR: PumpManualWire must be wired to a water pump") Error = 1 } Pump = Device:getWirelink() PumpEnt = Pump:entity() DeviceNames:remove(4) DeviceNames:insertString(4,"Found") Pump["Mute",number] = 1 SkipPump = 1 } for(I=1,LinkedDevices:count()){ Device = LinkedDevices[I,entity] Class = Device:type() if(Class=="generator_liquid_water"){ if(SkipPump==0){ Model = Device:model() if(Model == "models/chipstiks_ls3_models/largeh2opump/largeh2opump.mdl"){ PumpGen = 0.35 } elseif(Model == "models/ce_ls3additional/water_pump/water_pump.mdl"){ PumpGen = 1.8242 } elseif(Model == "models/props_phx/life_support/gen_water.mdl"){ PumpGen = 4.63 } Pump = Device:getWirelink() PumpEnt = Pump:entity() DeviceNames:remove(4) DeviceNames:insertString(4,"Found") Pump["Mute",number] = 1 } } elseif(Class=="generator_liquid_hvywater"){ Model = Device:model() if(Model == "models/ce_ls3additional/water_heater/water_heater.mdl"){ HeavGen = 1 } elseif(Model == "models/chipstiks_ls3_models/nitrogenliquifier/nitrogenliquifier.mdl"){ HeavGen = 0.964 } elseif(Model == "models/props_wasteland/laundry_washer003.mdl"){ HeavGen = 0.232 } Heav = Device:getWirelink() DeviceNames:remove(3) DeviceNames:insertString(3,"Found") Heav["Mute",number] = 1 } elseif(Class=="generator_energy_steam_turbine"){ Stem = Device:getWirelink() DeviceNames:remove(2) DeviceNames:insertString(2,"Found") Stem["Mute",number] = 1 } elseif(Class=="generator_gas_o2h_water"){ Model = Device:model() if(Model == "models/ce_ls3additional/water_heater/water_heater.mdl"){ SpltGen = 0.3 } elseif(Model == "models/ce_ls3additional/water_air_extractor/water_air_extractor.mdl"){ SpltGen = 1.47 } elseif(Model == "models/lifesupport/generators/waterairextractor.mdl"){ SpltGen = 0.69 } Splt = Device:getWirelink() HaveSplit = 1 Splt["Mute",number] = 1 } elseif(Class=="storage_cache"){ Cache = Device:getWirelink() DeviceNames:remove(1) DeviceNames:insertString(1,"Found") } elseif(Class=="generator_energy_fusion"){ FusionCount++ if(FusionCount==1){ Fus1 = Device:getWirelink() } elseif(FusionCount==2){ Fus2 = Device:getWirelink() } elseif(FusionCount==3){ Fus3 = Device:getWirelink() } else{ Fus4 = Device:getWirelink() } Model = Device:model() if(Model == "models/props_phx/life_support/crylaser_small.mdl"){ #Tiny FusionMult += 1.92 } elseif(Model == "models/ce_ls3additional/fusion_generator/fusion_generator_small.mdl"){ #Small FusionMult += 2.24 } elseif(Model == "models/ce_ls3additional/fusion_generator/fusion_generator_medium.mdl"){ #Med FusionMult += 7.73 } elseif(Model == "models/ce_ls3additional/fusion_generator/fusion_generator_large.mdl"){ #Large FusionMult += 6.77 } elseif(Model == "models/ce_ls3additional/fusion_generator/fusion_generator_huge.mdl"){ #Huge FusionMult += 40.93 } elseif(Model == "models/lifesupport/generators/fusiongen.mdl"){ #Levy FusionMult += 64 } else{ #Shitbridge FusionMult += 3.44 } } elseif(Class=="generator_energy_quantum" & IgnoreQuants==0){ Quan = Device:getWirelink() } } SetupSteps=3 } elseif(SetupSteps==3){ for(B=1,4){ Name = DeviceNames[B,string] if(Name != "Found"){ ErrorNames:pushString(Name) } } ErrorCount = ErrorNames:count() if(ErrorCount != 0){ print("ERROR: You are missing required devices. Spawn correct models and link them to node. Missing units:") for(C=1, ErrorCount){ print(ErrorNames[C,string]) } Error = 1 } else{ SetupSteps=0 E2:setColor(Color) soundPlay(2, 1, "buttons/bell1.wav") } } if(Error==1){ stoptimer("interval") E2:setColor(vec(255,0,0)) soundPlay(1,1,"buttons/button10.wav") timer("SD",1000) } } #For running the system once all things are connected else{ NRG = Cache["Energy",number] WAT = Cache["Water",number] STM = Cache["Steam",number] OXY = Cache["Oxygen",number] HYD = Cache["Hydrogen",number] MAXNRG = Cache["Max Energy",number] MAXWAT = Cache["Max Water",number] MAXSTM = Cache["Max Steam",number] MAXOXY = Cache["Max Oxygen",number] MAXHYD = Cache["Max Hydrogen",number] NRGPer = NRG/MAXNRG WATPer = WAT/MAXWAT OXYPer = OXY/MAXOXY HYDPer = HYD/MAXHYD STMPer = STM/MAXSTM #If the pump is in the water and linked if(PumpEnt:rdNetCapacity("energy")!=0 & PumpEnt:isUnderWater()){ #Starting logic, also turns on all pumps for chargeup if(GearUp==0){ if(NRG < 1000){ Quan["On",number] = 1 FusiOn = 1 } elseif(WAT < 400){ PumpOn = 1 } elseif(STM < 300){ HeavOn = 1 } else{ FusiOn = 1 PumpOn = 1 HeavOn = 1 StemOn = 1 if(HaveSplit){SpltOn = 1} GearUp = 1 Quan["On",number] = 0 } } #Starts to gear up once all the levels are high enough to start the loop else{ if(ModeToggle==0){ ModeToggle = 1 FusiOn = 0 } #Lowers steam use to allow more generation if(STMPer < 0.8){ SteamGen = 2 } else { SteamGen = 2.59145333 } #Deactivates splitter if oxygen and hydrogen are full if(OXYPer==1 & HYDPer==1){ SpltOn=0 } #Determines the basic multiplier Mult = max(NRG/306, WAT/510) #Determines how much more of each is required in terms of the mult Need = max((MAXNRG-NRG)/306, (MAXWAT-WAT)/510) #Determines the need including the splitter or not SNeed = (HaveSplit ? max(Need,(MAXOXY-OXY)/500,(MAXHYD-HYD)/500) : Need) #Uses Need and maximum available resources to determine the max mult possible Max = min(SNeed, MAXWAT/255, MAXNRG/153) #Prevents Mult from going too high or going to 0 (breaking the gen cycle) GEAR = clamp( Mult, 0.1, Max ) #GEAR = 1 #Application of mults, multiplied by the variable Pump["Multiplier",number] = PumpGen * GEAR #0.35 Heav["Multiplier",number] = HeavGen * GEAR #1 Stem["Multiplier",number] = SteamGen * GEAR Splt["Multiplier",number] = SpltGen * GEAR #0.3 } } #If pump is unlinked or exits the water else{ if(ModeToggle){ GearUp = 0 ModeToggle = 0 FusiOn = 0 PumpOn = 0 HeavOn = 0 StemOn = 0 SpltOn = 0 Quan["On",number] = 0 Pump["Multiplier",number] = 1 Heav["Multiplier",number] = 1 Stem["Multiplier",number] = 1 Splt["Multiplier",number] = 1 holoColor(2, vec(200, 50,50)) } #Running logic for when out of the water #If Water is above % if( WATPer > MinWaterLevel/100 ){ #If NRG is below STEAM's percentage HeavOn = (NRGPer0){ if(FusiOn){ if(Fus1["On",number]==0) {Fus1["On",number] = 1} if(Fus2["On",number]==0) {Fus2["On",number] = 1} if(Fus3["On",number]==0) {Fus3["On",number] = 1} if(Fus4["On",number]==0) {Fus4["On",number] = 1} } else{ if(Fus1["On",number]==1) {Fus1["On",number] = 0} if(Fus2["On",number]==1) {Fus2["On",number] = 0} if(Fus3["On",number]==1) {Fus3["On",number] = 0} if(Fus4["On",number]==1) {Fus4["On",number] = 0} } } } # This is a freely distributed E2 written by MrStump for use on Diaspora servers. # You are permitted to alter it in any way you see fit, # but please do not distrubute altered versions. # Enjoy, and special thanks to Dara for the good setup idea.