Space Engineers

Space Engineers

EasyAPI
All In One Life Support System
I have seen several different scripts that I love that would make up a good all in one life support system but since I'm a newbie at C# (barely know anyting but picking up on things here and there) I don't know if it's possible to put these ideas into one script (or maybe two at most) using your EasyAPI.

1. Emergency Bulkheads
Essentially your script with a few modifications... Turn the door off after closing it and turn it on but don't open it... also output to an LCD display a list of rooms (based on the AirVents) and the current level of pressurization (maybe also have the script query the door states and display on the LCD which ones are locked by reading the OnOff state?)

2. Airlock
Simple airlock system to cycle the doors and pressurization/depressurization as well as change the color of a light in the airlock to indicate it's status (red vs green for depressurized vs pressurized). Output status of airlock doors and pressurization levels to LCD.

3. Oxygen management automation
Check levels of oxygen tanks and if they are set to stockpile or not. If levels of tanks NOT set to stockpile go below a certain level, turn on oxygen generators. If levels of tanks NOT set to stockpile go above a certain level, turn off oxygen generators. If generators are on but tank levels reach a dangerous level, turn off stockpile on stockpiled tanks. Also output status of generators and tanks (levels and stockpile settings) to an LCD panel.

This script should also only work on the ship or station it is on, not on docked vessels through connectors or merge blocks, so maybe have it query only blocks with a certain [Prefix] set by the user for that ship or staton.

I have another script idea but I will make a seperate discussion post for that. Thank you so much for your help in advance :D
< >
1-7 / 7 のコメントを表示
rockyjvec  [開発者] 2015年4月7日 8時30分 
@Hype365, Thanks, I don't have time to respond in detail right now but I think that will be possible in one script. I should have some time later today.
@rockyjvec Thank you so much :) If it helps, this https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=412848604 is the script i based the idea from.

In addition, having a group of sound blocks play and a group of lights activate and blink when oxygen levels in all tanks or a room get to low would be great. If it's possible to have the sound blocks and lights reset when a special light is turned off that would be awesome, the alarm could be activated manually via that light as well (either script or player activates light to sound alarm and deactivates light to silence/reset alarm).

I suppose the only way having the airlock system included in this would be to somehow make an exception for the airlock doors and vents that way the bulkhead system won't activate and set off the alarm.
最近の変更はAaron Tiganが行いました; 2015年4月7日 16時03分
Rereading this one too, would it be possible to have the airlock portion run multiple airlocks or would it run only one?

For the oxygen generators and tanks, when the tanks reach normal levels after being at dangerous, toggle stockpile tanks back to stockpile (maybe have to set a tag on the tanks for that so the script can ID them, I'm not sure though).
最近の変更はAaron Tiganが行いました; 2015年4月7日 20時10分
rockyjvec  [開発者] 2015年4月8日 0時29分 
The main limitations of what you can do in a script are the "complexity" of a script (how many things it does each time it is run), and how long the script is (how many characters it has in it). EasyAPI can get around the "complexity" issue by alternating what it does each run so that not everything is done every time it runs. The length could be an issue with very complicated scripts. I have planned on "minifying" EasyAPI if I ever start to have issues with the length.

I see no reason why all of what you described couldn't be combined into one script.

The Emergency Bulkheads feature would be very similar to my bulkhead door manager script as you said. I think it would just be a matter of removing a couple of lines of code to disable the opening of the doors and making it disable/enable the doors.

Once I get my menu code working, you could have multiple consoles on your ship that all give access to a LCD menu for the different statuses you mentioned. So from any terminal around your ship you could access the status of the emergency bulkheads, airlocks, and oxygen management by selecting that menu item.

Instead of using a prefix you could maybe just create a "Ship" group that contains all the blocks on your ship. That might save some time when naming blocks. You could do something similar with airlocks. So you could have a group named "Airlock 1" and another named "Airlock 2". The script could simply search for groups named like Airlock* and then in each of those find the components that make up the airlock, like the air vent and doors. Maybe tagging the doors with [inside] and [outside] or just adding [hull] to the outer door that has space on the other side so the script knows which doors to open/close. It could easily handle multiple airlocks.

It's pretty easy to play sounds or flash lights when certain events occur.

I haven't looked into reading the value of the oxygen stockpile yet but I'm sure it's possible. You can keep track of the current state of the tanks inside the script so there should be no reason you would need to change the tags on them other than to initially set them as stockpile tanks.

Everything you have mentioned adds up to a pretty complicated script. However, each individual piece is not that complicated. It might be best to at first create the three pieces separately (in different scripts) and then, once they are working, combine them into one script.

I hope that is helpful. I'm not sure what kind of help you are looking for but I'm happy to give some examples and answer any questions you have. I'm pretty busy during the week but I'll reply when I have time. Have you looked at my EasyAPI Documentation guide? That might be the best place to start. If you were hoping I would write the script for you I might be able to do that eventually since I am interested it something like this, but I have a bunch of features I am working on for EasyAPI so it will be a while before I have time to work on something like this.

@rockyjvec Again, thank you for your help. I will start with the alerts script to get a feel for coding with EasyAPI and then start work on each part for the life support. After reading your reply here I see we are on the same page with how your menus will be useful (see my reply in the other discussion). Could maybe even trigger events like toggling airlock cycles. Could you possibly write just the part where it scans the blocks in the "Ship" group and stores them? As I said in the other discussion, I'd be more than happy to credit you when the scripts are complete (I'd even make you a contributor) for all the help you're providing :)
rockyjvec  [開発者] 2015年4月8日 12時22分 
Sounds good. No credit necessary. If you don't mind, just mention that you used easy api. I'll give you example code for getting blocks in the ship group later today.
rockyjvec  [開発者] 2015年4月8日 23時25分 
Here is the basic code to find all blocks in a group named "Ship". A more complete example is the code I posted in your Alert system thread. Keep in mind that this code requires the easyapi script. So you need to replace the Example class at the top of the easyapi script with this code for it to work. Of course, it doesn't actually do anything other than get the list of blocks so a better example is the Alert system example. :-)

public class Example : EasyAPI { EasyBlocks shipBlocks; // This will store all the blocks in the "Ship" group so that we deal only // This function only runs the first time the programming block gets run after getting compiled. public Example(IMyGridTerminalSystem grid) : base(grid) { shipBlocks = Blocks.InGroupsNamed("Ship"); // Save off all of the blocks in the Ship group into the ship variable for use later in the script. } }
< >
1-7 / 7 のコメントを表示
ページ毎: 1530 50