Space Engineers

Space Engineers

Oxygen Sensor (Works in Vanilla SE - No mods needed)
58 Comments
Sagittarius 23 Nov, 2017 @ 11:29am 
Hey, could this be updated to the current patch state? Sadly theres a new error to the Line 47 Error
Parasocial 26 Feb, 2017 @ 12:20pm 
I have a problem witht this. This is the Error:
Program(50,67): Error: 'IMyBlockGroup' does not contain a definition for 'Blocks' and no extension method 'Blocks' accepting a first argument of type 'IMyBlockGroup' could be found(are you missing a using directive or an assembly reference?)
Please help because your idea is great!
Rikkavidu_GER 22 Sep, 2015 @ 9:39am 
Hi. Your Script has a Error. What with Blockgroups or so what.
Genius 13 Sep, 2015 @ 5:51pm 
You have to change "blockGroups = GridTerminalSystem.BlockGroups;"
to "GridTerminalSystem.GetBlockGroups(blockGroups);"
This script is obsolete.
That One R.O.B. 4 Aug, 2015 @ 8:49am 
i have an error on line 47 as well i also have a iscussion about it
WortexCZ 1 Aug, 2015 @ 10:15pm 
Same here. Error at line 47.
sir_evilfish 17 Jul, 2015 @ 12:55pm 
Hi! It seems the script does not work anymore after the last game update (from today, ver 1.091). There is a compile error at line 47. Anyone else has the same problem?
nogare321 14 Apr, 2015 @ 7:55pm 
Thanks!
Kesuke  [author] 14 Apr, 2015 @ 10:00am 
of course nogare321.
nogare321 12 Apr, 2015 @ 3:07pm 
I'm trying to learn how to program in C# for this game. That being said, I've noticed that sections of your code say what I'm trying to do. Would it be ok for me to use your sections (with me citing your steam name) in my scripts?
Kebabcp 6 Apr, 2015 @ 4:18am 
maybie a video showing how to set it up...
acheaen 2 Apr, 2015 @ 9:56pm 
can anyone check the script in the discussions board and see what i cant
[S7G] String 1 Apr, 2015 @ 2:28pm 
This isn't a mod its a script? Lol
So he is right when he says "No mods needed " :)
commander.bert 1 Apr, 2015 @ 1:40pm 
great idea and good program, I like it.
only thing, if you use it in the construction phase, you have to start the program new after adding some parts
DiabetiMark 31 Mar, 2015 @ 10:27pm 
I could try that one, thanks
@[K.I.] Freedom's Flame
Freedom's Flame 31 Mar, 2015 @ 8:49pm 
@Mark Perhaps rather than activating the blocks directly through the programmable block just have the script turn on a timer block that will activate a separate programmable block that then changes the state of all the lights each tick. Then when oxygen comes back have a script that will turn off that timer block and will activate another that turns all the flashing lights specifically to their "off" state, rather than just changing their state.
Kiba 31 Mar, 2015 @ 4:46pm 
Why not upload the script to steam workshop like others have done?
DiabetiMark 31 Mar, 2015 @ 11:09am 
One more question.

I've got Interior lights setup as Light Alarm <ZONE>
and tried to expand your awesome code a little : 3
didn't go that well haha.

I tried to setup to search (just like the "Air Vent") for blocks with Light Alarm in it,
then when a zone gets depressurized, the lights go on (and each light is setup to be flickering etc. ) So just OnOff_On & OnOff_Off had to be changed for each block containing Light Alarm
to turn on when depressurized, and off when pressurized.

anyone got a piece of code for me ^^
I would really appreciate it :)


- Mark
(:USstar:I love this piece of code :gmod:J :USstar: )
Kesuke  [author] 31 Mar, 2015 @ 10:30am 
Gherkin - This isn't a mod mate. This is all possible in Vanilla SE using the programmable block. The only thing uploaded is a savegame. You can do all this in your own worlds with the programmable block.
Kesuke  [author] 31 Mar, 2015 @ 10:28am 
Nice one Mark! Glad you got it sorted :ftlrebel:
Kesuke  [author] 31 Mar, 2015 @ 10:28am 
FiveSeveN - Tyco - A Walk
Paveway 31 Mar, 2015 @ 10:26am 
Im sorry to bother you, but what song was included in the video?
SioxerNikita 31 Mar, 2015 @ 7:03am 
#CluelessIsClueless, It's a world, a savegame, an Ingame script which is not a mod.
DiabetiMark 31 Mar, 2015 @ 4:40am 
It's working like a charm!
thanks for your help!
nicely done!

thanks for sharing :)

(it was the modded Air Vents which caused the problems ;))

- Mark
maxxal22 31 Mar, 2015 @ 2:08am 
i think he means no othert modded stuff needed
ethobat 31 Mar, 2015 @ 1:23am 
>no mods needed
>is a mod
Kesuke  [author] 30 Mar, 2015 @ 6:45pm 
It was indeed Tyco :)
Riparian 30 Mar, 2015 @ 6:32pm 
Brilliant and useful! Thank you for this, I will surely be implimenting this in my future ships. The song for the vid was by tyco right? Either way, great tutorial vid too, gave me a good understanding of how this whole thing works.
Mojo 30 Mar, 2015 @ 3:56pm 
@LVMPD Explorer Matt, I was playing around with a simple room, I mean simple, and I kept getting the reading there was a leak... for some reason angle blocks that were attached to glass was the leak...all vanilla..replaced angled with square no leak, put angles back leak..possible that it may be your issue?
[S7G] String 30 Mar, 2015 @ 3:54pm 
Can you also get it to toggle certain lights to flash red colour please would be pretty sweeet .
Nice work too with the sound block alarm script haha LCDs look great
DiabetiMark 30 Mar, 2015 @ 3:11pm 
That I haven't taught of that one before!
that might actually be it :/

I'm so sorry, and glad that you might have found the cause of the problem!
I'm going to give it a try tomorrow!
I'll let you know!

Anyway!
thanks for your help, time and awesome concept!


- Mark
Kesuke  [author] 30 Mar, 2015 @ 3:07pm 
Mark I suspect your issue might be from a modded block looking at the ship. Right now the oxygen system only seems to work properly with the vanilla blocks. The game seems to think some full height mod blocks that look like they should contain oxygen are actually empty. I suspect you've got a leak somewhere, probably from a mod block.

The door shouldn't be tricking the game. You could test your theory by adding a vent into the gap between the doors. I doubt it will fix your problem (because I don't think that is the problem). I think you have an air leak somewhere.
DiabetiMark 30 Mar, 2015 @ 2:23pm 
Hello Kesuke, thanks for your respond.

I hope I won't bother you too much.
the LCD's were already working at that time, maybe I wasn't that clear,
the LCD's do update when I change the name of a air vent (It shows the data on screen with how "All X zones are pressurized." and the "Life Support:" strings.)

only it doesn't respond to unpressurized rooms.

so it shows the amount of zones / pressurizers, but not when one gets depressurized / pressurized...

Thanks for your time, and sharing this cool concept of LCD with oxygen alarm ;)

M.Moose 30 Mar, 2015 @ 2:18pm 
I would but I can't, not until it's finished. Also I know for a fact that there is no hole. But I do have multiple pressurized rooms (connected by two doors). I think the problem is that when I open the door it makes the system think its not pressurized since it doesn't have an air vent inside of it. (the gap between the doors is 1 block).

But here is a reference model of what I have:

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=275097654

I built this but I am working on an FPS-Friendly version right now with an Oxygen system
(This is an old outdated ship without the proper insulation needed for an oxygen system)

Kesuke  [author] 30 Mar, 2015 @ 1:48pm 
Matt, if you like upload your world to the workshop and I'll take a look. Sounds like a hole somewhere in the ship design (you don't have a depressurized central corridor or something like that do you?).
M.Moose 30 Mar, 2015 @ 12:33pm 
Mine is now working properly. but I can't tell if this is a bug with the oxygen or the script, but it seems that everytime I open a door in my ship (that is pressurizedand leads to another pressurized area) it depressurizes every room in my ship and with the alarm going off and the doors closing on me it is starting to get a bit frustrating. Besides the Issues this is still a great script none the less.
Kesuke  [author] 30 Mar, 2015 @ 12:07pm 
Also, make sure you have put your LCD screens into a block group called Oxygen LCD panels (you can call the panels whatever you want individually, but they need to belong to a group with the name Oxygen LCD Panels - case sensitive as well so make sure it is spelt right)
Kesuke  [author] 30 Mar, 2015 @ 12:06pm 
Hi Mark, make sure you have set the LCD's to yourself as the block owner, the display public text and everybody-read only.

I have noticed that since Thursdays update sometimes the screens glitch out. This will probably be fixed next week. If that happens just recompile the script in the editor and it seems to fix it.
DiabetiMark 30 Mar, 2015 @ 11:06am 
Ok, got the timer to work ^^ (silly me)
but stil haven't figured out why the screens aren't showing, and the alarm doesn't ring when a zone with a configurd airvent doesn't work
DiabetiMark 30 Mar, 2015 @ 11:01am 
I tried it myself, boot and the same as LVMPD Explorer Matt. When I vented the oxygen of the zone, it doesn't show up on the LCD.

What I noticed though, is that the timer isn't being started automatically, which may point to the code not being fully executed. tried to figure it out myself, but couldn't find the problem. the programmable block doesn't give an error whilst manually updating it.
further I can say that when I add a airvent conveyor block, and name it Air Vent <ZONE NAME etc.> nothing happens on the LCD's, but when I manually execute the code (Through the programmable block and / or timer) it update's. Which may point that the code is incorrect / incomplete after the Air Vent increment count and before the restart timer piece.

I hope someone could figure this one for me ^^
and find a fix, where I couldn't.
thx for trying / helping me!
(Stil not sure if it is the code which is wrong or I)

(And Kesuke, thx for the code anyway :) )

- [Dangny] Mark
M.Moose 30 Mar, 2015 @ 8:36am 
For some reason when I went to vent out a room on my ship to see if it would work nothing seemed to happen on the screens. it said they were all pressurized even though the room had lost all oxygen. I'm pretty sure I set everything up right. Is there something I may have missed?
BoneHero 30 Mar, 2015 @ 8:35am 
Now that the game has those airtight hangar doors, is it possible to use this script to trigger "emergency seals" to seal off the hull breach from spesific room? Im quite sure it is but I have no idea how this programming works...
Trion3 30 Mar, 2015 @ 8:11am 
if only i am able to code
C3ntron 30 Mar, 2015 @ 3:07am 
I like it!

Works very well and I took the liberty to 'expand' your script to change an intererior light color to reflect the status of a room:


//Definition:
List<IMyTerminalBlock> airLight = SearchBlocksByName("Air Light");
//Add to vent-check loop
VentLocation = airVents[i].CustomName.Substring(8);

// Change light color to status:
// If( (IsDepressurizing) || etc etc )
LightColor = Color.Red;
// Else if (!IsDepressurizing)
LightColor = Color.Green;

// At the end of for-loop
SetColorOfLight(airLight, VentLocation, LightColor);

void SetColorOfLight(List<IMyTerminalBlock> blocks, string Location, Color color)
{ for (int i = 0; i < blocks.Count; i++)
{ IMyInteriorLight light = blocks[i] as IMyInteriorLight;
if( !(blocks[i].CustomName.IndexOf(Location) == -1)){
light.SetValue("Color", color);
}
}
}
Probably the search of the right interior light could have been nicer, but right now I only knew the 'for' loop as a solution ;-)
John Shepard 29 Mar, 2015 @ 10:33pm 
thsi is PREETY DAMN GOOD!!!!
TheCrazyCabbage 29 Mar, 2015 @ 1:11pm 
Added the section to close the doors, i keep getting an error; 'main Method not found, please add main method into script'
Kesuke  [author] 29 Mar, 2015 @ 9:08am 
Baron Samedi - Very, very easily. Find this part in the code;

if(pressureStatus == "Depressurized") {
alarm.GetActionWithName("PlaySound").Apply(alarm);
} else {
LCDText += " All " + airVents.Count + " zones are currently pressurised";
}

And change it to this;

if(pressureStatus == "Depressurized") {
alarm.GetActionWithName("PlaySound").Apply(alarm);
// Close all doors when pressure is lost
List<IMyTerminalBlock> allDoors = new List<IMyTerminalBlock>();
GridTerminalSystem.GetBlocksOfType<IMyDoor>(allDoors);
for (int i = 0; i < allDoors.Count; i++) {
allDoors .GetActionWithName("Open_Off").Apply(allDoors );
}
} else {
LCDText += " All " + airVents.Count + " zones are currently pressurised";
}

And that will close all doors on the ship when pressure is lost :)
Kesuke  [author] 29 Mar, 2015 @ 9:08am 
Candum - The timer doesn't need to trigger itself. The script triggers the timer when it completes. This is to prevent the timer trying to trigger the script if it is already in progress.

bill4725 - You can have as many (or few) vents and LCD's. You don't need to make the number of vents and LCDs match. The problem you had was probably that the ownership of the LCDs wasn't set to you and the public text wasn't set to "Everybody" and "read only". I'm glad you got it fixed. Let me know if you still have trouble and maybe upload it to the workshop.

kyrkbarron - If you want to exclude an air vent from this system simply give it a name that doesn't begin with "Air Vent".
jarhead 29 Mar, 2015 @ 6:21am 
I have not downloaded yet but when I do I am going totry to make this scallable so you can have 1 lcd with 20 vent s or the other way around.
sapper4725 29 Mar, 2015 @ 4:42am 
Got it working turns out if you have 5 vents you need 5 LCD's in the group I only had 4 added a fifth and it worked