Space Engineers

Space Engineers

评价数不足
OHM2: Oxygen/Hydrogen Management 2
   
奖励
收藏
已收藏
取消收藏
文件大小
发表于
更新日期
23.890 KB
2019 年 1 月 30 日 下午 1:05
2019 年 11 月 11 日 下午 5:07
2 项改动说明 ( 查看 )

订阅以下载
OHM2: Oxygen/Hydrogen Management 2

描述
OHM was getting a bit out of date, and there were several features that would have been extremely difficult to work in to the old version, so I present OHM2, a new and significantly improved gas level manager.

Features:
Independent management of hydrogen and oxygen levels on the same loop.
Triggering of timers when an event in the code is triggered. Eg. Hydrogen drops below it's threshold; Oxygen reaches capacity.
A cycle feature that ensures compatability with airlock scripts. Note, this feature is more performance intensive and halves your hydrogen production when it is active.
LCD display of system statistics.
Arguments that make oxygen tanks available to airlocks or force the script to manually cycle.

Setup:
Put all of the blocks you want the script to manage in the Life Support group ( case sensitive, you can change the name inside the script itself). The script will automatically detect the type of block and sort into the proper lists. Supported blocks are: gas generators, oxygen farms, vents, any gas tank, lcds, and timers.
The script will automatically detect any change in the size of the group and refresh.
To set up timers simply input "o2Timer" or "hyTimer" in the custom data of the timer (not case sensitive) to indicate whether it triggers when oxygen or hydrogen goes above their threshold respectively. Put a "-" somewhere in with the argument to cause the timer to trigger when the tank drops below the threshold. Timers don't update if you change them after adding them to the group, so make sure to recompile the script when you are finished setting them up.
The script requires you have at least one form of oxygen generation (gas generator, vent in atmosphere, oxygen farm)
and at least one oxygen tank in order to operate.

Configuration:
The configuration values are in the custom data of the programmable block. To change, simply adjust the value after the equals sign to the desired value.
The threshold variables are the value (in decimal) below which the tanks will try to stay above. The cycle threshold indicates the percentage of hydrogen level above which the program can cycle. Set this to 0 to allow the system to cycle no matter what.
The "cycle" variable indicates whether the script is allowed to automatically cycle. Use this setting with airlock scripts.

Behavior:
The script will ensure oxygen tanks don't fall below a certian threshold and stop production when it reaches it while filling hydrogen tanks.
If cycle is enabled and it is full on oxygen and the hydrogen tanks need fuel and the hydrogen levels are above the cycle threshhold, the script will periodically switch between hydrogen production and making tanks available for airlocks. A cycle indicator will show next to the state to indicate this.
If it recieves the argument "Cycle" (not case sensitive), the script will be forced to cycle once. If it recieves the argument "Airlock" (not case sensitive, you can change this value in the script), it will ensure oxygen tanks are available for one run.
If it is in an oxygen atmosphere and it needs oxygen it will prioritize using vents, if any. If it can't get oxygen from vents then it will default to using oxygen farms, if any. If there is no other option the script will use gas generators to generate oxygen.

Notes/Troubleshooting:
If you want to fill tanks on a docked craft, you will have to put them in the correct group, and go in the script and set USE_OTHER_CONSTRUCTS to true.
If you have cycle turned off, the script will leave gas generators off when they aren't needed. If you want to refill bottles directly from the gas generator, you can set up a button that runs the programmable block with the argument "Cycle" to temporarily power it.
If the script fills the oxygen tanks too much, try lowering the threshold to a lower value to allow for more wiggle-room. If you have multiple gas generators for few oxygen tanks consider starting at a lower value.
If the script shows "Initialize" as it's state, then it does not have the required blocks to continue running. If it stops working but shows the script is updating then recompile and check if it is stuck on Initialize.
13 条留言
Trekki  [作者] 2019 年 11 月 11 日 下午 5:11 
I have finally gone in and fixed the headless mode issue. Hopefully this makes the script a bit more intuitive with it simply not calling it's Render() method if there are no displays in the group.
Kiithnaras 2019 年 10 月 2 日 下午 5:54 
The failure to operate and error (Index out of Range) occurs when no LCD is in the Life Support group. In order to function as-is, an LCD is required, not optional. This can still be made to work without an LCD by deleting the contents of the Render class and commenting the preceding lcd variable for now.
Kiithnaras 2019 年 9 月 15 日 下午 1:14 
Correction, that is a compile-time error. The script refuses to run outright, but processes once (toggles o2 generators and the like on/off) upon a recompile.
Kiithnaras 2019 年 9 月 15 日 下午 1:02 
Runtime error on script:
Index out of range. Must be non-negative and less than the size of the collection.
Parameter: Index
at System.ThrowHelper...
at Program.Render()
at Program.Main...
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.<>c__DisplayClass46_0.<ExecuteCode>b__0(IMyGridProgram program)
at Sandbox.Game.Entities.Blocks.MyProgrammableBlock.RunSandboxedProgramAction(Action`1 action, String& response)

It appears the script runs enough to process O2 generator logic once before halting at this error. Additionally, a number of compile-time warnings mention deprecated methods regarding LCDs and Displays.
jarhead 2019 年 6 月 22 日 下午 7:53 
I will try to upload a screenshot later.
I do remember that it was saying something about "can't be negative or less than ........"
Trekki  [作者] 2019 年 6 月 22 日 下午 12:16 
Can you describe in greater detail?
jarhead 2019 年 6 月 21 日 下午 9:22 
not working
Trekki  [作者] 2019 年 4 月 7 日 下午 6:44 
So... Assuming you want to turn them on when you are above threshold and off when you are below threshold you will want to put "hyTimer" and "-hyTimer" in the timers' custom data respectively.

If that doesn't work for you it could be a coding mistake on my end and if so, I won't be able to fix it right away unfortunately.
Buscemi3 2019 年 4 月 7 日 下午 5:59 
Hello, I'm trying to make this work with two timer blocks to turn on and off hydrogen engines as the hydrogen tanks refill and drain. It's not working. could it? Thanks.
Malaras 2019 年 3 月 14 日 下午 6:22 
Hello, Thanks for the reply. Think they new with 1.0? don't think i've seen them before. ( haven't played in awhile though) the big engines that convert Hydrogen to power. I always got to set the storage tank for hydrogen to store then release it so the engine converts it to power. other wise only getting 2.5 power from the engine instead of 5.0